From: Radu B. R. <ru...@cs...> - 2006-03-16 10:24:12
|
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 |