help with Escapi 3.0 DLL
BlitzMax Forums/BlitzMax Programming/help with Escapi 3.0 DLL
| ||
this is a working example for escapi 2.1 (that is working with 2.1 dll)
Type SimpleCapParams
Field mTargetBuf:Byte Ptr ' Must be at least mWidth * mHeight * SizeOf(Int) of size!
Field mWidth
Field mHeight
End Type
Global InitCOM () "C"
Global CountCaptureDevices () "C"
Global OpenCaptureDevice (device, scp:Byte Ptr) "C"
Global CloseCaptureDevice (device) "C"
Global GetCapture (device) "C"
Global CaptureDone (device) "C"
Global CaptureDeviceName (device, name:Byte Ptr, namelen) "C"
Global ESCAPIDLLVersion () "C"
Function SetupESCAPI ()
esc = LoadLibraryA ("escapi.dll") 'with escapi 2.1 everything works.. with escapi 3.0 ... NOT
InitCOM = GetProcAddress (esc, "initCOM")
CountCaptureDevices = GetProcAddress (esc, "countCaptureDevices")
OpenCaptureDevice = GetProcAddress (esc, "initCapture")
CloseCaptureDevice = GetProcAddress (esc, "deinitCapture")
GetCapture = GetProcAddress (esc, "doCapture")
CaptureDone = GetProcAddress (esc, "isCaptureDone")
CaptureDeviceName = GetProcAddress (esc, "getCaptureDeviceName")
ESCAPIDLLVersion = GetProcAddress (esc, "ESCAPIDLLVersion")
If InitCOM = Null Or CountCaptureDevices = Null Or OpenCaptureDevice = Null Or..
CloseCaptureDevice = Null Or GetCapture = Null Or CaptureDone = Null Or..
CaptureDeviceName = Null Or ESCAPIDLLVersion = Null
DebugLog "Function missing!"
Return 0
EndIf
InitCOM ()
Return 1
End Function
Function CaptureDevice$ (device)
Local cam:Byte [1024]
CaptureDeviceName (device, cam, 1024)
Return String.FromCString (cam)
End Function
If SetupESCAPI () = 0
Notify "Error! Make sure escapi.dll is in same folder and capture device plugged in!"
End
EndIf
For num = 0 Until CountCaptureDevices ()
Print "Capture device [" + num + "] name: " + CaptureDevice (num)
Next
device = 0
width = 320
height = 240
AppTitle = "Using " + CaptureDevice (device) + "..."
Graphics width, height', 32
' Data structure...
Local scp:SimpleCapParams = New SimpleCapParams
' A PixMap for captured data...
pix:TPixmap = CreatePixmap (width, height, PF_BGRA8888)
' Stick pixmap memory pointer into data structure...
scp.mTargetBuf = PixmapPixelPtr (pix)
scp.mWidth = width
scp.mHeight = height
' Start capture process...
If OpenCaptureDevice (device, scp) = 0
Print "Failed to initialise capture device!"
End
EndIf
Repeat
GetCapture (device)
Repeat
If KeyHit (KEY_ESCAPE) Then quit = True
Plot Rand(320),Rand(240) 'some random noise on background to be sure that app is working
Flip 0 'this to draw noise
Delay(10) 'decrease cpu usage
Until CaptureDone (device)
DrawPixmap pix, 0, 0 'app don't reach this points because the capturedone is NOT DONE
Flip 'this to draw everything if there is a camera image... (but i think there is no image)
Until quit = True
CloseCaptureDevice (device)
End
if the dll is replaced by 3.0 version ... i can't receive the image from CAM. any idea on how to fix this? Escapi sources: http://sol.gfxile.net/escapi/index.html |
| ||
This works with 3.0 for me:
Type SimpleCapParams
Field mTargetBuf:Byte Ptr ' Must be at least mWidth * mHeight * SizeOf(Int) of size!
Field mWidth
Field mHeight
End Type
Global InitCOM () "C"
Global CountCaptureDevices () "C"
Global OpenCaptureDevice (device, scp:Byte Ptr) "C"
Global CloseCaptureDevice (device) "C"
Global GetCapture (device) "C"
Global CaptureDone (device) "C"
Global CaptureDeviceName (device, name:Byte Ptr, namelen) "C"
Global ESCAPIDLLVersion () "C"
Global quit:Int
Function SetupESCAPI ()
Global esc:Int = LoadLibraryA ("escapi.dll")
If esc
InitCOM = GetProcAddress (esc, "initCOM")
CountCaptureDevices = GetProcAddress (esc, "countCaptureDevices")
OpenCaptureDevice = GetProcAddress (esc, "initCapture")
CloseCaptureDevice = GetProcAddress (esc, "deinitCapture")
GetCapture = GetProcAddress (esc, "doCapture")
CaptureDone = GetProcAddress (esc, "isCaptureDone")
CaptureDeviceName = GetProcAddress (esc, "getCaptureDeviceName")
ESCAPIDLLVersion = GetProcAddress (esc, "ESCAPIDLLVersion")
If InitCOM = Null Or CountCaptureDevices = Null Or OpenCaptureDevice = Null Or..
CloseCaptureDevice = Null Or GetCapture = Null Or CaptureDone = Null Or..
CaptureDeviceName = Null Or ESCAPIDLLVersion = Null
DebugLog "Function missing!"
Return 0
EndIf
InitCOM ()
If ESCAPIDLLVersion () < $200
DebugLog "Old DLL (needs version 2.0+)"
Return 0
EndIf
Else
DebugLog "Failed to open DLL"
Return 0
EndIf
Return 1
End Function
Function CaptureDevice$ (device)
Local cam:Byte [1024]
CaptureDeviceName (device, cam, 1024)
Return String.FromCString (cam)
End Function
If SetupESCAPI () = 0
Notify "Error! Make sure escapi.dll is in same folder and capture device plugged in!"
End
EndIf
Global num:Int
For num = 0 Until CountCaptureDevices ()
Print "Capture device [" + num + "] name: " + CaptureDevice (num)
Next
Global device:Int = 0
' To list/select devices...
'Repeat
' device = Int (Input ("Enter capture device number: "))
'Until device > -1 And device < CountCaptureDevices ()
' Preferred target width/height (ESCAPI scales capture data to this)...
Global width:Int = 320
Global height:Int= 240
AppTitle = "Using " + CaptureDevice (device) + "..."
Graphics width, height', 32
' Data structure...
Local scp:SimpleCapParams = New SimpleCapParams
' A PixMap for captured data...
Global pix:TPixmap = CreatePixmap (width, height, PF_BGRA8888)
' Stick pixmap memory pointer into data structure...
scp.mTargetBuf = PixmapPixelPtr (pix)
scp.mWidth = width
scp.mHeight = height
' Start capture process...
If OpenCaptureDevice (device, scp) = 0
Print "Failed to initialise capture device!"
End
EndIf
Repeat
Cls
GetCapture (device)
Repeat
If KeyHit (KEY_ESCAPE) Then quit = True
Until CaptureDone (device)
DrawPixmap pix, 0, 0
Flip
Until quit = True
' Stop capture process...
CloseCaptureDevice (device)
End
|
| ||
| wait.. is the same demo from Escapi sources? or you have made some changes? EDIT: maybe i've found my issue.. i've downloaded the Escapi3 the release day (october) and the DLL is marked by date: 28-10-2015 .... after the use of this DLL (just 1 time) the Escapi 3 from latest download (.. that has date 15-11-2015) doesn't works (black screen) .. (i need to reboot W10-PC to make the 15-11 version working...) OMG why the dll is not marked 3.01 or 3.1 if there are differences from 28-10 and 15-11 versions ??? (grrr) btw, thank xlsior for your help! |