Open CV: live webcam
Posted: Mon Nov 14, 2011 2:16 pm
This example works in Windows, try it in Linux.
In Windows you will need in openCV1.0 libraries:
highgui100.dll
cxcore100.dll
libguide40.dll
In Windows you will need in openCV1.0 libraries:
highgui100.dll
cxcore100.dll
libguide40.dll
Code: Select all
; Live webcam with OpenCV
; AAT, 2011
;------------------------
#CV_WINDOW_AUTOSIZE = 1
Structure IplImage
nSize.i
id.i
nChannels.i
alphaChannel.i
depth.i
colorModel.b[4]
channelSeq.b[4]
dataOrder.i
origin.i
align.i
width.i
height.i
*roi.l
*maskROI.l
*imageId.l
*tileInfo.l
imageSize.i
*imageData.l
widthStep.i
BorderMode.i[4]
BorderConst.i[4]
*imageDataOrigin.l
EndStructure
;-- highgui --
Prototype.l ProtocvNamedWindow(name.s, flags.l = #CV_WINDOW_AUTOSIZE)
Prototype.l ProtocvDestroyWindow(name.s)
Prototype.l ProtocvShowImage(name.s, image.l)
Prototype.l ProtocvWaitKey(delay.l = 0)
;-- video in highgui --
Prototype.l ProtocvCreateCameraCapture(Index.i)
Prototype.l ProtocvGrabFrame(CapturePtr.l );
Prototype.l ProtocvQueryFrame(CapturePtr.l);
Prototype.l ProtocvReleaseCapture(*CvCapture.l)
;------------
If OpenLibrary(1, "highgui100.dll")
pcvNamedWindow.ProtocvNamedWindow = GetFunction(1, "cvNamedWindow")
pcvDestroyWindow.ProtocvDestroyWindow = GetFunction(1, "cvDestroyWindow")
PcvShowImage.ProtocvShowImage = GetFunction(1, "cvShowImage")
PcvWaitKey.ProtocvWaitKey = GetFunction(1, "cvWaitKey")
cvCreateCameraCapture.ProtocvCreateCameraCapture = GetFunction(1,"cvCreateCameraCapture")
cvQueryFrame.ProtocvQueryFrame = GetFunction(1,"cvQueryFrame")
cvReleaseCapture.ProtocvReleaseCapture = GetFunction(1,"cvReleaseCapture")
EndIf
win.i = pcvNamedWindow("Live Camera", #CV_WINDOW_AUTOSIZE)
*capture.l = cvCreateCameraCapture(0);
While(1)
*Image.IplImage = cvQueryFrame(*capture);
If *Image
ret.i = pcvShowImage("Live Camera", *Image)
If ret = 0 ; Window is closed
Break
EndIf
If pcvWaitKey(33) = 27 ; Until Esc key pressed
Break
EndIf
Else
Break
EndIf
Wend
cvReleaseCapture(@*capture)
pcvDestroyWindow("Live Camera")