From: Fred L. <ff...@ab...> - 2006-03-20 16:38:09
|
Hello, Finally found some time... On Thursday 16 Mar 2006 10:24, Radu Bogdan Rusu wrote: > Hey Fred, > > If nobody else figures it out, I will try to do something about it on > the plane. In general though, it is better to: > - first, test if the data is ready, using the > <CameraInterface>.isDataReady () method > - then try to actually read the data from CameraInterface's buffer. > > Example: > PlayerCameraData camdata = new PlayerCameraData (); > > if (camdata.isDataReady ()) > camdata = cam.getData (); I've done: System.out.println("Waiting for image to be ready"); while (!cam.isDataReady()) { // Do nothing, just wait for the data to be ready. } System.out.println("Getting image"); camdata = cam.getData(); and that indeed (almost) solves the problem I was reporting. Only almost because to save the image I have to do: for (int h = 0; h < height ; h++) for (int w = 0; w < width; w++) { file.write(data[(w * 3) + (h * width * 3) + 1]); // Red file.write(data[(w * 3) + (h * width * 3) + 2]); // Green file.write(data[(w * 3) + (h * width * 3) + 0]); // Blue } in order to get the colours right. The interesting bit is that v4l normally creates BGR pixels (i.e. blue and red swapped). However, I seem to be getting BRG pixels from the CameraInterface. But that's easy enough to fix. Finally, is the isDataReady()/getData() pair is in a loop, it hangs on the second isDataReady() (or am I not supposed to be using it as I do? Also, at the same time I do get loads of warning : tried to push onto a full message queue error : tried to push 2/1 from/onto 4/0 while trying to get the second image. This is with version 2.0.1 of javaclient and a fairly recent cvs version of player. Cheers, Fred |