| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- #include "FingerDev.h"
- #include "log4vendor.h"
- FingerDev::FingerDev()
- {
- m_hDll = NULL;
- }
- FingerDev::~FingerDev()
- {
- if(m_hDll != NULL)
- {
- UnLoad_so();
- m_hDll = NULL;
- }
- }
- int FingerDev::Open(const char* sPathFile)
- {
- if(!Load_so(sPathFile))
- return LS_ERROR_DEVICE_NOT_INIT;
- return pWELLDeviceInit();
- }
- int FingerDev::Close()
- {
- int iRt = LS_ERROR_SUCCESS;
- iRt = pWELLDeviceClose();
- return iRt;
- }
- int FingerDev::Reset()
- {
- return LS_ERROR_SUCCESS;
- }
- int FingerDev::GetFPIImg2Bmp(char *psImgPath)
- {
- int iRt = LS_ERROR_SUCCESS;
- int timeOut = 2;
- iRt = pWELLImg2Bmp(timeOut, psImgPath);
- return iRt;
- }
- int FingerDev::GetFPIBmp2Feature(const char* imagePath, LPBYTE lpbFeature, int &iLength)
- {
- int iRt = LS_ERROR_SUCCESS;
- //数据类型,1-0x30格式 2-BASE64格式
- iRt = pWELLBmp2Feature(0x63, (char*)imagePath, (char*)lpbFeature,&iLength);
- // iRt = pWELLGetFeature(0x10, 1, (char*)lpbFeature);
- // if(iRt == LS_ERROR_SUCCESS)
- // {
- // iRt = pWELLImg2Bmp(1, (char*)imagePath);
- // iLength = strlen((char*)lpbFeature);
- // }
- return iRt;
- }
- int FingerDev::GetFPIBmp2Template(const char* imagePath1, const char* imagePath2, const char* imagePath3, LPBYTE lpbTemplate, int &iLength)
- {
- int iRt = LS_ERROR_SUCCESS;
- //数据类型,1-0x30格式 2-BASE64格式
- iRt = pWELLBmp2Template(0x63, (char*)imagePath1, (char*)imagePath2, (char*)imagePath3, (char*)lpbTemplate,&iLength);
- return iRt;
- }
- int FingerDev::FPIMatch(LPBYTE lpbTemplate, LPBYTE lbpFeature, int level)
- {
- int iRt = LS_ERROR_SUCCESS;
- iRt = pWELLMatch((char*)lpbTemplate, (char*)lbpFeature, level);
- return iRt;
- }
- int FingerDev::Cancel()
- {
- int iRt = LS_ERROR_SUCCESS;
- pWELLCancel();
- return iRt;
- }
- int FingerDev::GetErrInfo(char* errMsg, int iRet)
- {
- errMsg = pWELLGetErrorInfo(iRet);
- return LS_ERROR_SUCCESS;
- }
- int FingerDev::GetVersion(char* ver)
- {
- int iRt = LS_ERROR_SUCCESS;
- char sDevInfo[64+1] = {0};
- char sID[1024] = {0};
- iRt = pWELLGetVersion(sDevInfo, sID);
- strcpy(ver, sDevInfo);
- return iRt;
- }
- int FingerDev::UnLoad_so()
- {
- // if(m_hDll)
- // {
- // //m_hDll.unload();
- // m_hDll = NULL;
- // }
- return true;
- }
- int FingerDev::Load_so(const char* sPathFile)
- {
- m_hDll = dlopen(sPathFile, RTLD_LAZY); //load so
- if (m_hDll != NULL)
- {
- CMB_LOG_BODY(CMB_LOG_INFO, "load library successed!");
- pWELLGetErrorInfo = (WELLGetErrorInfo)dlsym(m_hDll, "WELLGetErrorInfo");
- if(!pWELLGetErrorInfo)
- {
- CMB_LOG_BODY(CMB_LOG_INFO, "load'WELLGetErrorInfo()'failed!");
- return false;
- }
- pWELLDeviceInit = (WELLDeviceInit)dlsym(m_hDll, "WELLDeviceInit");
- pWELLDeviceClose = (WELLDeviceClose)dlsym(m_hDll, "WELLDeviceClose");
- // pWELLGetFingerprintAndMatch = (WELLGetFingerprintAndMatch)dlsym(m_hDll, "WELLGetFingerprintAndMatch");
- pWELLGetFeature = (WELLGetFeature)dlsym(m_hDll, "WELLGetFeature");
- pWELLGetTemplate = (WELLGetTemplate)dlsym(m_hDll, "WELLGetTemplate");
- pWELLGetVersion = (WELLGetVersion)dlsym(m_hDll, "WELLGetVersion");
- pWELLMatch = (WELLMatch)dlsym(m_hDll, "WELLMatch");
- pWELLImg2Bmp = (WELLImg2Bmp)dlsym(m_hDll, "WELLImg2Bmp");
- pWELLBmp2Feature = (WELLBmp2Feature)dlsym(m_hDll, "WELLBmp2Feature");
- pWELLBmp2Template = (WELLBmp2Template)dlsym(m_hDll, "WELLBmp2Template");
- pWELLCancel = (WELLCancel)dlsym(m_hDll, "WELLCancel");
- }
- else
- {
- CMB_LOG_BODY(CMB_LOG_INFO, "load library failed!");
- return false;
- }
- return true;
- }
|