http://sol.gfxile.net/code.html
I wrote this code (just place it in the same folder as escapi.dll from the escapi20.zip archive and make sure your camera is plugged in!), and all the function calls seem to work, but I just get black data (all zeroes) from the webcam after capture:
Code: Select all
; PB4...
Structure SimpleCapParams
mTargetBuf.l ; Must be at least mWidth * mHeight * SizeOf(int) of size!
mWidth.l
mHeight.l
EndStructure
camnum = 0 ; First device found; adjust to suit...
esc = OpenLibrary (#PB_Any, "escapi.dll")
If esc
initCOM = GetFunction (esc, "initCOM")
countCaptureDevices = GetFunction (esc, "countCaptureDevices")
initCapture = GetFunction (esc, "initCapture")
deinitCapture = GetFunction (esc, "deinitCapture")
doCapture = GetFunction (esc, "doCapture")
isCaptureDone = GetFunction (esc, "isCaptureDone")
getCaptureDeviceName = GetFunction (esc, "getCaptureDeviceName")
ESCAPIDLLVersion = GetFunction (esc, "ESCAPIDLLVersion")
CallFunctionFast (initCOM)
Debug "ESCAPIDLLVersion:"
Debug "$" + Hex (CallFunctionFast (ESCAPIDLLVersion))
Debug ""
Debug "countCaptureDevices:"
Debug CallFunctionFast (countCaptureDevices)
Debug ""
cam$ = Space (#MAX_PATH)
CallFunctionFast (getCaptureDeviceName, camnum, @cam$, #MAX_PATH)
Debug cam$
Debug ""
scp.SimpleCapParams
scp\mWidth = 320
scp\mHeight = 240
scp\mTargetBuf = AllocateMemory (scp\mWidth * scp\mHeight * 4)
Debug "initCapture:"
Debug CallFunctionFast (initCapture, camnum, @scp)
Debug ""
For a = 1 To 10
CallFunctionFast (doCapture, camnum)
Repeat
Delay (1)
Until CallFunctionFast (isCaptureDone, camnum)
Next
Debug "Size:"
Debug scp\mWidth
Debug scp\mHeight
image = CreateImage (#PB_Any, scp\mWidth, scp\mHeight)
StartDrawing (ImageOutput (image))
For y = 0 To scp\mHeight - 1
For x = 0 To scp\mWidth - 1
Plot (x, y, scp\mTargetBuf + count)
count = count + 1
Next
Next
StopDrawing ()
CallFunctionFast (deinitCapture, camnum)
CloseLibrary (esc)
EndIf
window = OpenWindow (#PB_Any, 320, 200, 320, 200, "ESCAPI 2")
CreateGadgetList (WindowID (window))
ImageGadget (#PB_Any, 0, 0, 320, 200, ImageID (image))
Repeat
Until WaitWindowEvent () = #PB_Event_CloseWindow
This also fails in BlitzMax (see my post here: http://www.blitzmax.com/Community/posts.php?topic=66505), yet the provided binary examples work fine, and it's just a simple C-style API.
Anyone got any ideas as to what might be wrong?
(Heh, spot the forum bug with ? in URLs!)
[/url]