Hello to all,
I posted some time ago to the ctypes mailing list that I am working on
implementing a fingerprint capture library on python, based on the
LScanEssentials toolkit from Crossmatch Technologies.
Basically I want to display what the fingerprint device is ‘seeing’ in some kind of windows window.
I already ported the whole headers to ctypes python via the conversion tools h2xml and xml2py.
Everything
is working great, for example the taking of the image generates
correctly the bitmap I expect, the initialization, device selection,
etc… is working great.
However I am not getting the realtime ‘capturing image’.
The API says you should create a window, then pass it’s handle and ‘display zone’ to the SDK so he can draw to it.
However I do not know how to do that.
I
created some wxpython window and used GetHandle to pass it. The SDK
won’t prompt for errors or whatever, but nothing shows at all on screen.
I
dont know if there is some kind of event handling or whatever to have
it preview the image. I also read about the opencv HighGUI component to
implement a live preview on this ‘more generic’ window.
Do someone has an idea of what could be wrong on my code or reasoning ?
FYI here is the acquiring workflow from the SDK:
···
Workflow to Acquire Images
The following shows a typical sequence of steps to perform to acquire images.
- Call LSCAN_Main_GetDeviceCount() to obtain number of detected devices.
- Call LSCAN_Main_GetDeviceInfo() to determine device index to use.
- Call LSCAN_Main_Initialize() to initialize device and get device handle for image acquisition.
- Call appropriate callback registration functions to retrieve required notifications.
- Call LSCAN_Visualization_SetWindow() to specify visualization area.
- Call LSCAN_Visualization_SetMode() to define visualization behavior.
- Call LSCAN_Capture_SetMode() to select correct acquisition type.
- Call LSCAN_Capture_Start() to start image acquisition.
- Result image acquisition is triggered automatically (Auto Capture) and/or manually by LSCAN_Capture_TakeResultImage()
- Result image is passed as ImageData to callback LSCAN_CallbackResultImage().
- Call LSCAN_Main_Release() when finished using the device.
For subsequent acquisitions please note the following:
If the device is still initialized then preconditional steps 1 to 4 must not be called again
Steps 5 and 6 are optional (e.g. to change visualization behavior)
Step 7 is only required when modifying acquisition image type
And about the SetWindow stuff I am doing this on my code:
def createDisplay(self, obj=None):
if not obj:
# we must create some basic standard window
pass
else:
print 'createdisplay got an object passed in'
# we have been passed a window, we must try to see if we get a HWND handle of it
self.display_handle = obj.GetHandle()
print 'display handle is '+str(self.display_handle)
def startVisualization(self, winobj=None):
print 'startvisualization'
if not self.display_handle:
self.createDisplay(winobj)
draw_area = lse.RECT()
draw_area.left = 10
draw_area.top = 10
draw_area.right = 510
draw_area.bottom = 510
res_visu = LSCAN_Visualization_SetWindow(self.device_handle, lse.HWND(self.display_handle), draw_area)
print 'lscanvisualizationsetwindow:'+str(res_visu)
res_mode = LSCAN_Visualization_SetMode(self.device_handle, lse.LSCAN_VIS_ALWAYS, lse.LSCAN_OPTION_VIS_FULL_IMAGE)
print 'lscanvisualizationsetmode:'+str(res_mode)
res_capmode = LSCAN_Capture_SetMode( self.device_handle,
lse.LSCAN_ROLL_SINGLE_FINGER, lse.LSCAN_IMAGE_RESOLUTION_500,
lse.LSCAN_IMAGE_INHERIT_LINE_ORDER, lse.LSCAN_OPTION_AUTO_OVERRIDE,
None, None, None, None)
print ‘LSCAN_Capture_SetMode:’+str(res_capmode)
ov = lse.HANDLE()
addov = LSCAN_Visualization_AddOverlayText(self.device_handle,
“blabla”, 10, 10, lse.COLORREF( 255 ), “Arial”, 10, False, ov)
print ‘addoverlay:’+str(addov)
print ‘ov:’+str(ov.value)
showov = LSCAN_Visualization_ShowOverlay(self.device_handle, ov, True)
print ‘showov:’+str(showov)
bgcolor = LSCAN_Visualization_SetBackgroundColor(self.device_handle, lse.COLORREF(123123))
# register a callback function
preview_context = c_void_p()
preview_callback = LSCAN_CallbackPreviewImage(self.callbackPreviewImage)
regcbpi = LSCAN_Capture_RegisterCallbackPreviewImage( self.device_handle, preview_callback, preview_context)
print 'regcbpi:'+str(regcbpi)
result_callback = LSCAN_CallbackResultImage(self.callbackResultImage)
regcbri = LSCAN_Capture_RegisterCallbackResultImage(self.device_handle, result_callback, preview_context)
print 'regcbri:'+str(regcbri)
res_startcap = LSCAN_Capture_Start(self.device_handle, 1)
#LSCAN_Controls_DisplayShowCaptureProgressScreen()
print 'startcap:'+str(res_startcap)
res_tpi = LSCAN_Capture_TakeResultImage(self.device_handle)
print 'res_tpi:'+str(res_tpi)
here with winobj being a frame of wxpython:
import App1
app = App1.BoaApp(0)
c.startVisualization(app.main)
app.MainLoop()
as defined here:
#!/usr/bin/env python
#Boa:App:BoaApp
import wx
import Frame2
modules ={‘Frame2’: [1, ‘Main frame of Application’, ‘none://Frame2.py’]}
class BoaApp(wx.App):
def OnInit(self):
self.main = Frame2.create(None)
self.main.Show()
self.SetTopWindow(self.main)
return True
def main():
application = BoaApp(0)
application.MainLoop()
if name == ‘main’:
main()
If someone has any thought I would really appreciate !
Thank you for your reading !
Patricio
Get news, entertainment and everything you care about at Live.com. Check it out!