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