|
From: Fred L. <ff...@ab...> - 2006-03-20 17:15:44
|
On Monday 20 Mar 2006 16:37, Fred Labrosse wrote:
> 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
Sorry, actually:
warning : tried to push onto a full message queue
error : tried to push 1/1 from/onto 40/0
>
> while trying to get the second image.
Should have added that this is if option "save 1" in the config file is
commented out.
Fred
|