It crashes at:
I just want this to work with my Carmine 1.09 webcam. I need to turn it into a DLL so it can work with more than just Purebasic.*Image.IplImage = cvQueryFrame(*capture)
I need the live image to be applied to a texture.
PLEASE NOTE:
This requires the following OpenCV libraries:
- highgui100.dll
cxcore100.dll
libguide40.dll 
http://sourceforge.net/projects/opencvl ... v-win/1.0/
Download the file: "OpenCV_1.0.exe" & go to the following directory to find the above library files:
"OpenCV\bin"
and put all 3 of the above DLL files into the same directory as where the below source is, then open the source file you saved from below, and compile it.
NOTE: Uses PB 5.11 & higher!
Webcam.pb:
Code: Select all
; Live webcam with OpenCV
; AAT, 2011
;------------------------
InitSprite()
InitKeyboard()
OpenWindow(0, 0, 0, 1, 1, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0), 0, 0, 800, 600, 1, 0, 0, 0)
HideWindow(0, 1)
#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
   *maskROI
   *imageId
   *tileInfo
   imageSize.i
   *imageData
   widthStep.i
   BorderMode.i[4]
   BorderConst.i[4]
   *imageDataOrigin
 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)
;------------
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 = cvCreateCameraCapture(0)
ExamineKeyboard()
While Not KeyboardPushed(#PB_Key_Escape)
  *Image.IplImage = cvQueryFrame(*capture)
  If *Image
    ret.i = pcvShowImage("Live Camera", *Image) 
    If ret = 0                                    ; Window is closed
      Break
    EndIf  
  EndIf
Wend   
cvReleaseCapture(@*capture)
pcvDestroyWindow("Live Camera")
EndMythros


