Using 5dpo lazarus / 39-Graphics ---------------------------------------------------------------------- l_netwalker · 2011-02-04 19:55 Hi all, I try to use the 5dbo V4l Component to read images from my USB Cam. I did a v4l-info and found out that the cam produces JPG images. Code: [Select]video capture     VIDIOC_ENUM_FMT(0,VIDEO_CAPTURE)         index                   : 0         type                    : VIDEO_CAPTURE         flags                   : 1         description             : "JPEG"         pixelformat             : 0x4745504a [JPEG]     VIDIOC_G_FMT(VIDEO_CAPTURE)         type                    : VIDEO_CAPTURE         fmt.pix.width           : 176         fmt.pix.height          : 144         fmt.pix.pixelformat     : 0x4745504a [JPEG]         fmt.pix.field           : NONE         fmt.pix.bytesperline    : 176         fmt.pix.sizeimage       : 10094         fmt.pix.colorspace      : JPEG         fmt.pix.priv            : 1 so I thought  the following way I should get an image ( it's the modified example ) Code: [Select] procedure TFMain.VideoFrame(Sender: TObject; FramePtr: PByte); begin   FrameRate:=round(1/((GetTickCount-FrameTime)/1000)*0.5 + FrameRate*0.5);   FrameTime:=GetTickCount;   Caption:= 'SdpoVideo4L2 '+IntToStr(FrameRate)+'fps';   TEMPGraphic := TJpegImage.Create;   //TEMPGraphic.LoadFromFile('/home/hartmut/Documents/Pictures/hucky- 100x137.jpg');   TEMPGraphic.Height := Video.Height;   TEMPGraphic.Width := Video.Width;   JPGPointer := pointer(TEMPGraphic);   Move(FramePtr,JPGPointer , SizeOf(TEMPGraphic));   TEMPBitmap := TBitmap.Create;   TEMPBitmap.Height := Video.Height;   TEMPBitmap.Width := Video.Width;   TEMPBitmap.Canvas.Draw(0,0,TEMPGraphic);   Image1.Picture.Graphic := TEMPBitmap;   TEMPGraphic.Free; end; As far as I understood the example, the procedure  TFMain.VideoFrame is called with every new frame from the camera, with FramePtr as a pointer to this actual JPEG encode frame. To get it to the screen I first generate a JPEG image, which I the copy with the move command to a TImage. But all I get is grahical garbage. It's my first work with Lazarus and I have no ideas how to get this up and working. Any suggestions or hints on a solution ? Thanks Hartmut ---------------------------------------------------------------------- Marc · 2011-02-05 15:41 why do you think moving framebuffer data over the TJpegImage class suddenly decodes a jpeg image ? Pit the framedata in a memorystream and let the TEMPGraphic read it. ---------------------------------------------------------------------- circular · 2011-02-06 01:28 That's right, you are erasing the objet structure with bitmap data. Bitmap data is a stream whereas an object is a dynamic structures containing pointers to active memory. ---------------------------------------------------------------------- prof7bit · 2011-05-06 09:06 In the latest svn version of 5dpo (svn release >= 101) there is now a property UseLibV4l, if you set it to True it will access the device though the libv4l wrapper (part of the v4l-utils, should be installed already, its part of the official v4l2 infrastructure). This will do format conversion transparently on the fly. All cams will gain the ability to support: RGB24 BGR24 YUV240 even if they do not support this format natively (very likely since all format conversion, decompression, etc. has been removed from the kernel drivers and moved into libv4l). Bernd