Author Topic: Using 5dpo  (Read 6235 times)


  • Newbie
  • Posts: 2
Using 5dpo
« on: February 04, 2011, 08:55:51 pm »
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
        index                   : 0
        type                    : VIDEO_CAPTURE
        flags                   : 1
        description             : "JPEG"
        pixelformat             : 0x4745504a [JPEG]
        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);
  FrameRate:=round(1/((GetTickCount-FrameTime)/1000)*0.5 + FrameRate*0.5);
  Caption:= 'SdpoVideo4L2 '+IntToStr(FrameRate)+'fps';
  TEMPGraphic := TJpegImage.Create;
  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;
  Image1.Picture.Graphic := TEMPBitmap;

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 ?



  • Administrator
  • Hero Member
  • *
  • Posts: 2514
Re: Using 5dpo
« Reply #1 on: February 05, 2011, 04:41:13 pm »
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.
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker


  • Hero Member
  • *****
  • Posts: 3579
    • Personal webpage
Re: Using 5dpo
« Reply #2 on: February 06, 2011, 02:28:13 am »
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.
Conscience is the debugger of the mind


  • New Member
  • *
  • Posts: 22
Re: Using 5dpo
« Reply #3 on: May 06, 2011, 11:06:39 am »
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:


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).



TinyPortal © 2005-2018