From: Fred L. <ff...@ab...> - 2006-03-15 17:32:27
|
All, I'm having a strange problem, which I think is a bug in javaclient2... Here is a bit of code, mostly coming from an example for 1.6.5 modified for 2.0 (we actually use a recent (1.5 weeks ago about) cvs version): static byte[] imageData; PlayerClient robot = new PlayerClient("localhost", 6665); CameraInterface cam = robot.requestInterfaceCamera(0, PlayerConstants.PLAYER_OPEN_MODE); PlayerCameraData camdata = new PlayerCameraData(); camdata = cam.getData(); int width = camdata.getWidth (); int height = camdata.getHeight (); int isize = camdata.getImage_count(); imageData = camdata.getImage (); saveImage (imageData, isize, width, height, "/tmp/camera"+i+".pnm"); with save image containing (and other stuff as well): for (int i = 0; i < isize; i++) file.write(imageData[i]); When the images are saved, only the top quarter of the image contains data (the remaining being black) and that top part contains 4 almost copies of the image (there are slight variations). The slight variations seem to say that the interlacing of the data is wrong. The fact that 3 quarters of it is black (but there, isize being right) seems to show that it's missing a lot of data. The former problem is easy enough to solve (just coordinates manipulation) but the latter is not... It's not coming from player because when the driver (camerav4l) is started with the option "save 1", the saved images are correct. All the values in the camera interface seem correct (width and height are 200, isize is 120000 (not always though, see below), format is 5 (RGB888) and compress is 0 (no compression). What is going on? Also, sometimes, the size (getImage_count()) of the image is 0 (but not systematically) and player outputs loads of warnings and errors related to full queues (don't have the exact messages with me at the moment). These (but not the 0 size) disappear when images are saved by player (presumably slowing it down). This is with a recent cvs version of player. The following might be the culprit (haven't tried): robot.runThreaded (-1, -1); Any suggestions? Cheers, Fred P.S. Please reply to all so that the CC gets it as well. Thanks. |
From: Radu B. R. <ru...@cs...> - 2006-03-16 10:24:12
Attachments:
smime.p7s
|
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 (); ... Also, please check the version of the CameraInterface.java file. The latest should be 1.6 (available in 2.0.1 and in CVS). Basically, the problem is with receiving big amounts of data on the wire (which is always the case with video data). In the newest version of it, I replaced: /* Old way of dealing with camera data: * int totalBytes = 28; * int bytes; * while (totalBytes < header.getSize ()) * { * // read the compressed image data * bytes = is.read (buffer, totalBytes - 28, header.getSize () - totalBytes); * totalBytes += bytes; * } */ ...with... is.readFully (buffer, 0, imageCount); Which should do the same thing, but looks neater. Best, Radu. Fred Labrosse wrote: >All, > >I'm having a strange problem, which I think is a bug in javaclient2... > >Here is a bit of code, mostly coming from an example for 1.6.5 modified >for 2.0 (we actually use a recent (1.5 weeks ago about) cvs version): > >static byte[] imageData; > >PlayerClient robot = new PlayerClient("localhost", 6665); >CameraInterface cam > = robot.requestInterfaceCamera(0, > PlayerConstants.PLAYER_OPEN_MODE); >PlayerCameraData camdata = new PlayerCameraData(); > >camdata = cam.getData(); >int width = camdata.getWidth (); >int height = camdata.getHeight (); >int isize = camdata.getImage_count(); > >imageData = camdata.getImage (); >saveImage (imageData, isize, width, height, "/tmp/camera"+i+".pnm"); > >with save image containing (and other stuff as well): > >for (int i = 0; i < isize; i++) > file.write(imageData[i]); > >When the images are saved, only the top quarter of the image contains data >(the remaining being black) and that top part contains 4 almost copies of >the image (there are slight variations). > >The slight variations seem to say that the interlacing of the data is >wrong. The fact that 3 quarters of it is black (but there, isize being >right) seems to show that it's missing a lot of data. The former problem >is easy enough to solve (just coordinates manipulation) but the latter is >not... > >It's not coming from player because when the driver (camerav4l) is started >with the option "save 1", the saved images are correct. > >All the values in the camera interface seem correct (width and height are >200, isize is 120000 (not always though, see below), format is 5 (RGB888) >and compress is 0 (no compression). > >What is going on? > >Also, sometimes, the size (getImage_count()) of the image is 0 (but not >systematically) and player outputs loads of warnings and errors related to >full queues (don't have the exact messages with me at the moment). These >(but not the 0 size) disappear when images are saved by player (presumably >slowing it down). This is with a recent cvs version of player. The >following might be the culprit (haven't tried): > > robot.runThreaded (-1, -1); > >Any suggestions? > >Cheers, > >Fred > >P.S. Please reply to all so that the CC gets it as well. Thanks. > > > > >------------------------------------------------------- >This SF.Net email is sponsored by xPML, a groundbreaking scripting language >that extends applications into web and mobile media. Attend the live webcast >and join the prime developer group breaking into this new coding territory! >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 >_______________________________________________ >Java-player-users mailing list >Jav...@li... >https://lists.sourceforge.net/lists/listinfo/java-player-users > > -- | Radu Bogdan Rusu | http://rbrusu.com/ | http://www9.cs.tum.edu/people/rusu/ | Intelligent Autonomous Systems | Technische Universitaet Muenchen |
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 |
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 |
From: Radu B. R. <ru...@cs...> - 2006-03-27 22:35:31
Attachments:
smime.p7s
|
Hi Fred, Going to do some tests with some live cameras this week and fix this. I also noticed that by encoding the color in Java byte format (signed, -127..128), the colors could get messed up, as normally they should be unsigned (0..255). I will try to change everything to integer and then test. If that works ok, I'll patch the library and let you know. Best, Radu. 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 > >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 > > >------------------------------------------------------- >This SF.Net email is sponsored by xPML, a groundbreaking scripting language >that extends applications into web and mobile media. Attend the live webcast >and join the prime developer group breaking into this new coding territory! >http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 >_______________________________________________ >Java-player-users mailing list >Jav...@li... >https://lists.sourceforge.net/lists/listinfo/java-player-users > > -- | Radu Bogdan Rusu | http://rbrusu.com/ | http://www9.cs.tum.edu/people/rusu/ | Intelligent Autonomous Systems | Technische Universitaet Muenchen |
From: krike <kri...@gm...> - 2006-05-24 00:41:17
|
Hi, i'm new here and i'm working with javaclient2 and player 2.0.1. So far I'm doing all right except for a little problem. The code works well, and I get an image but when I try to get the second image, it is the same as the first one. I don't know what's wrong. Anyone can help? Thanks. /************************************************************************************** int width, height, bpp, format, compr, isize; PlayerCameraData CamData = null; PlayerClient robot = null; CameraInterface cam = null; try { robot = new PlayerClient (ip, port); cam = robot.requestInterfaceCamera (IDCamera, PlayerConstants.PLAYER_OPEN_MODE); } catch (PlayerException e) { System.err.println ("Camera module: -> ERROR: "); System.err.println (" [ " + e.toString() + " ]"); System.exit (1); } robot.runThreaded (-1, -1); //Wait connection. while (!cam.isDataReady ()) { try { Thread.sleep (100); } catch (Exception e) {} } CamData = cam.getData(); width = CamData.getWidth (); height = CamData.getHeight (); bpp = CamData.getBpp (); format = CamData.getFormat (); compr = CamData.getCompression (); isize = CamData.getImage_count (); //bpp*width*height int countFrame = 0; while (true) { imageData = CamData.getImage(); writeJPG(imageData, "frame_" + countFrame + ".jpg"); countFrame++; } -- View this message in context: http://www.nabble.com/Missing+data+in+images--t1286033.html#a4533431 Sent from the java-player-users forum at Nabble.com. |
From: Radu B. R. <ru...@cs...> - 2006-05-27 08:13:47
Attachments:
smime.p7s
|
krike wrote: > while (true) > { > always check for isDataReady() before getting an image, especially in an infinite while loop. > imageData = CamData.getImage(); > writeJPG(imageData, "frame_" + countFrame + ".jpg"); > countFrame++; > } > -- | Radu Bogdan Rusu | http://rbrusu.com/ | http://www9.cs.tum.edu/people/rusu/ | Intelligent Autonomous Systems | Technische Universitaet Muenchen |