123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- #include "stdafx.h"
- #include "YituLiveSDK.h"
- #include "VTMSDK.h"
- typedef int (*tPfnInit)(VTM_InitParam* param);
- typedef int (*tPfnUninit)();
- typedef int (*tPfnStartCapture)(int nType);
- typedef int (*tpfnStopCapture)();
- typedef int (*tpfnAppendFrame)(VTM_ImageData* pData);
- typedef int (*tpfnGetImage)(BITMAP* pbitmap);
- typedef int (*tpfnHasHackInSession)(bool* bHasHack);
- typedef int (*tpfnGetLiveImageCount)(int* nLiveCount);
- typedef int (*tpfnGetLiveImage)(int nLiveImage,BITMAP* pbitmap,int* nLivenessType);
- typedef int (*tpfnGetTrackCount)(int nCameraID,int* nCount);
- typedef int (*tpfnGetTrackData)(int nCameraID,int nIndex,TrackData* pData);
- HINSTANCE h = NULL;
- tPfnInit _Init = NULL;
- tPfnUninit _Uninit = NULL;
- tPfnStartCapture _StartCapture = NULL;
- tpfnStopCapture _StopCapture = NULL;
- tpfnAppendFrame _AppendFrame = NULL;
- tpfnGetImage _GetImage = NULL;
- tpfnHasHackInSession _HasHackInSession = NULL;
- tpfnGetLiveImageCount _GetLiveImageCount = NULL;
- tpfnGetLiveImage _GetLiveImage = NULL;
- tpfnGetTrackCount _GetTrackCount = NULL;
- tpfnGetTrackData _GetTrackData = NULL;
- int YituLiveSDK::YituInit(const char *pszDLLPath, YituLiveSDK::Yitu_InitParam* param)
- {
- HINSTANCE h = ::LoadLibrary(pszDLLPath);
- if (!h)
- {
- return GetLastError();
- }
- _Init = (tPfnInit)GetProcAddress(h,"?Init@@YAHPAUVTM_InitParam@@@Z");
- _Uninit = (tPfnUninit)GetProcAddress(h,"?Uninit@@YAHXZ");
- _StartCapture = (tPfnStartCapture)GetProcAddress(h,"?StartCapture@@YAHH@Z");
- _StopCapture = (tpfnStopCapture)GetProcAddress(h,"?StopCapture@@YAHXZ");
- _AppendFrame = (tpfnAppendFrame)GetProcAddress(h,"?AppendFrame@@YAHPAUVTM_ImageData@@@Z");
- _GetImage = (tpfnGetImage)GetProcAddress(h,"?GetImage@@YAHPAUtagBITMAP@@@Z");
- _HasHackInSession = (tpfnHasHackInSession)GetProcAddress(h,"?HasHackInSession@@YAHPA_N@Z");
- _GetLiveImageCount = (tpfnGetLiveImageCount)GetProcAddress(h,"?GetLiveImageCount@@YAHPAH@Z");
- _GetLiveImage = (tpfnGetLiveImage)GetProcAddress(h,"?GetLiveImage@@YAHHPAUtagBITMAP@@PAH@Z");
- _GetTrackCount = (tpfnGetTrackCount)GetProcAddress(h,"?GetTrackCount@@YAHHPAH@Z");
- _GetTrackData = (tpfnGetTrackData)GetProcAddress(h,"?GetTrackData@@YAHHHPAUTrackData@@@Z");
- if (!(_Init&&_Uninit&&_StartCapture&&_StopCapture&&_AppendFrame&&_GetImage&&
- _HasHackInSession&&_GetLiveImageCount&&_GetLiveImage&&_GetTrackCount&&_GetTrackData))
- {
- int rtn = GetLastError();
- ::FreeLibrary(h);
- return rtn;
- }
- return _Init((VTM_InitParam*)param);
- }
- int YituLiveSDK::YituUninit()
- {
- int bRet1 = 0;
- BOOL bRet2 = TRUE;
- if (_Uninit)
- {
- bRet1 = _Uninit();
- }
- if (h)
- {
- bRet2 = ::FreeLibrary(h);
- }
- h = NULL;
- _Init = NULL;
- _Uninit = NULL;
- _StartCapture = NULL;
- _StopCapture = NULL;
- _AppendFrame = NULL;
- _GetImage = NULL;
- _HasHackInSession = NULL;
- _GetLiveImageCount = NULL;
- _GetLiveImage = NULL;
- _GetTrackCount = NULL;
- _GetTrackData = NULL;
- if (!bRet1&&bRet2)
- {
- return 0;
- }
- return 1;
- }
- int YituLiveSDK::YituStartCapture(int nType)
- {
- if (!_StartCapture)
- {
- return 1;
- }
- return _StartCapture(nType);
- }
- int YituLiveSDK::YituStopCapture()
- {
- if (!_StopCapture)
- {
- return 1;
- }
- return _StopCapture();
- }
- int YituLiveSDK::YituAppendFrame(YituLiveSDK::Yitu_ImageData* pData)
- {
- if (!_AppendFrame)
- {
- return 1;
- }
- return _AppendFrame((VTM_ImageData*)pData);
- }
- int YituLiveSDK::YituGetImage(BITMAP* pbitmap)
- {
- if (!_GetImage)
- {
- return 1;
- }
- return _GetImage(pbitmap);
- }
- int YituLiveSDK::YituHasHackInSession(bool* bHasHack)
- {
- if (!_HasHackInSession)
- {
- return 1;
- }
- return _HasHackInSession(bHasHack);
- }
- int YituLiveSDK::YituGetLiveImageCount(int* nLiveCount)
- {
- if (!_GetLiveImageCount)
- {
- return 1;
- }
- return _GetLiveImageCount(nLiveCount);
- }
- int YituLiveSDK::YituGetLiveImage(int nLiveImage,BITMAP* pbitmap,int* nLivenessType)
- {
- if (!_GetLiveImage)
- {
- return 1;
- }
- return _GetLiveImage(nLiveImage,pbitmap,nLivenessType);
- }
- int YituLiveSDK::YituGetTrackCount(int nCameraID,int* nCount)
- {
- if (!_GetTrackCount)
- {
- return 1;
- }
- return _GetTrackCount(nCameraID,nCount);
- }
- int YituLiveSDK::YituGetTrackData(int nCameraID,int nIndex,YituLiveSDK::Yitu_TrackData* pData)
- {
- if (!_GetTrackData)
- {
- return 1;
- }
- return _GetTrackData(nCameraID,nIndex,(TrackData*)pData);
- }
|