Laex / Delphi-OpenCV

Project Delphi-OpenCV. Translation of OpenCV library header files in Delphi
501 stars 226 forks source link

TocvCameraSource can not get picture in ocx(Delphi XE8 and delphi 2010 ) #60

Closed zzsczz closed 7 years ago

zzsczz commented 7 years ago

I can use the TocvCameraSource and TocvView in win32 windows application. They work well

I put TocvCameraSource and TocvView in ocx( activexform in avtivexlib ), then activate the ocx in container . But the TocvCameraSource's OnImage can not be trigged when the physical camera's led is powe on(by enable the TocvCameraSource).

I can get the picture form camera in ocx only by using api of opencv

I use the class TocvCameraSource(in unit ocv.comp.Source)

:

ocvCameraSource2 := cvCreateCameraCapture(0); //activate the camera

then use a timer to pull the picture

:

procedure Tax4cv8.Timer1Timer(Sender: TObject); var m_img: pIplImage;

img2: Graphics.TBitmap;

m_img_o: IocvImage;

mybitmap: Graphics.TBitmap;

begin //

m_img := cvQueryFrame(ocvCameraSource2);

mybitmap := TBitmap.Create;

mybitmap.PixelFormat := pf24bit;

IplImage2Bitmap(m_img, mybitmap);

self.Image1.width := mybitmap.width;
self.Image1.height := mybitmap.height;
self.Image1.canvas.StretchDraw(self.Image1.canvas.ClipRect, mybitmap);

self.Invalidate;

mybitmap.Destroy;

end;

how to make the TocvCameraSource works well in ocx???

the attach files contain project in xe8 ( use opencv version 2.4.13) app6: normal windows app ax9: ocx with component can not get pictue; Project4axlib9: gui client for ax9 ax8: ocx with api works well Project4axlib8:gui client for ax8

ws4opencv_delphi.zip