Hi everyone,
I'm testing an optical fingerprint device which has an asynchronous operation with a flow like the following:
1) LoadFG() - This will initialize device, camera, etc
2) SetProp() - Set frame grabber properties like LED, capture modes, etc
3) StartCapture() - This functions returns immediately but it triggers asynchrounous operation capturing images at intervals "in the background" untill StopCapture() is called.
StartCapture() takes the following callback functions as parameters
1) OnImage
2) OnFinger
3) OnError
I just want to write a simple test in my main function. How do I handle the async operations so that my main doesn't terminate before I stop the async operation properly.
I'm using Visual Studio 2008.
Pardon my noob question, I'm not a professional, just a lone business operator trying to get things done within budget and without going out of business. Any tips?Code:#include "stdafx.h" #include <iostream> #include <Windows.h> //This header defines all the data structures #include "Devicevcdefs.h" //The DLL header #include "Devicevc.h" #pragma comment(lib, "Device.lib") using namespace std; /////////////////////////Callback Functions ////////////////////////// // The Image Event void OnImage( int nFGHandle, unsigned int nChannel, DRM_VC_BYTE* pImage, void* pClientData ) { cout<< "OnImage" << endl; } // The finger event void OnFinger( int nFGHandle, unsigned int nChannelNo, int nType, DRM_VC_BYTE* pImage, void* pClientData ) { cout << "OnFinger" << endl; } // The error event void OnError( int nFGHandle, unsigned int nChannel, const char* szErrMsg, void* pClientData ) { cout << "Error: " << szErrMsg << endl; } // The warning event void OnWarning( int nFGHandle, unsigned int nChannel, const char* szWarningMsg, void* pClientData ) { cout << "Warning: " << szWarningMsg << endl; } //////////////////////////End Callback Functions/////////////////////// int _tmain(int argc, _TCHAR* argv[]) { int nFGHandle; // Load the frame grabber from the dl which in turns initialize the device //FG_PLS1 is device type enum loadFGStatus = LoadFG(FG_PLS1, nFGHandle); if(loadFGStatus == DEVICE_NOERROR){ //Output 0 which is OK cout << loadFGStatus << endl; //Output 1 which is OK cout << nFGHandle << endl; //Set The device LED to green SetFGProperty (nFGHandle, FG_GREEN_LED, 1); //I'm stuck here! //The asynchrounous operation, this method returns immediately but //triggers image capture intervals in the background //Will only stop after issuing StopCapture() StartCapture( nFGHandle, 1, PLAIN_FINGER , OnImage , OnFinger , OnError , OnWarning , NULL ); //Next Steps here.... } system("pause"); return 0; }
Thank you in advanced!



LinkBack URL
About LinkBacks


