| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- #include "stdafx.h"
- #include "JZT998APBDevCtrl.h"
- CDevDllLoad::CDevDllLoad(char * dllpath)
- {
- /**********************************************************************/
- Dl_info path_info;
- dladdr("CDevDllLoad",&path_info);
- char str_FilePath[256]{0};
- memcpy(str_FilePath,path_info.dli_fname,strlen(path_info.dli_fname));
- //printf("first_str_FilePath=%s\n",str_FilePath);
- char *pLastSlath=strrchr(str_FilePath,'/');
- *pLastSlath=0;
- memset(m_dllpath,0x00,sizeof(m_dllpath));
- strcpy(m_dllpath,str_FilePath);
- //strncpy(m_dllpath, dllpath, sizeof(m_dllpath));
- char *a="/keba/";
- strncat(m_dllpath,a,strlen(a));
- strncat(m_dllpath, dllpath, strlen(dllpath));
- // LOG4VTM(INFO,("CDevDllLoad creat function()!"));
- if(!InitDLL())
- {
- //记日志
- return;
- }
- }
- CDevDllLoad::~CDevDllLoad()
- {
- FreeDLL();
- }
- int CDevDllLoad::InitDLL()
- {
- if(nullptr != dp_dev)
- {
- FreeDLL();
- }
- dp_dev = dlopen(m_dllpath, RTLD_LAZY);
- if (nullptr == dp_dev)
- {
- //记日志
- return false;
- }
- apiFPIGetErrorInfo = (char* (*)(int))dlsym(dp_dev, "WELLGetErrorInfo");
- apiFPIDeviceInit = (int (*)(void))dlsym(dp_dev, "WELLDeviceInit");
- apiFPIDeviceClose = (int (*)(void))dlsym(dp_dev, "WELLDeviceClose");
- apiFPIGetFingerprintAndMatch = (int (*)( char *, int ))dlsym(dp_dev, "WELLGetFingerprintAndMatch");
- apiFPIGetFeature = (int (*)(int , int , char *))dlsym(dp_dev, "WELLGetFeature");
- apiFPIGetTemplate = (int (*)(int , int , char *))dlsym(dp_dev, "WELLGetTemplate");
- apiFPIFingerImageDecompress = (int (*)(char *, int,char *))dlsym(dp_dev, "WELLFingerImageDecompress");
- apiFPIGetVersion = (int (*)(char *, char *))dlsym(dp_dev, "WELLGetVersion");
- apiFPIMatch = (int (*)(char *, char *, int))dlsym(dp_dev, "WELLMatch");
- apiFPIImg2Bmp = (int (*)(int, char *))dlsym(dp_dev, "WELLImg2Bmp");
- apiFPIBmp2Feature = (int (*)(int, char *, char *, int *))dlsym(dp_dev, "WELLBmp2Feature");
- apiFPIBmp2Template = (int (*)(int, char *, char *, char *, char *, int *))dlsym(dp_dev, "WELLBmp2Template");
- apiFPICancel = (void (*)())dlsym(dp_dev, "WELLCancel");
- if (nullptr == apiFPIGetErrorInfo || nullptr == apiFPIDeviceInit || nullptr == apiFPIDeviceClose || nullptr == apiFPIGetFingerprintAndMatch ||
- nullptr == apiFPIGetFeature || nullptr == apiFPIGetTemplate || nullptr == apiFPIFingerImageDecompress || nullptr == apiFPIMatch)
- {
- //记日志
- return false;
- }
- return true;
- }
- int CDevDllLoad::FreeDLL()
- {
- dlclose(dp_dev);
- return true;
- }
- int CDevDllLoad::FPIDeviceInit()
- {
- if (apiFPIDeviceInit==nullptr)
- {
- return -3;
- }
- return apiFPIDeviceInit();
- }
- int CDevDllLoad::FPIDeviceClose()
- {
- if (apiFPIDeviceClose==nullptr)
- {
- return -3;
- }
- return apiFPIDeviceClose();
- }
- char* CDevDllLoad::FPIGetErrorInfo(int nRetCode)
- {
- if (apiFPIGetErrorInfo==nullptr)
- {
- return nullptr;
- }
- return apiFPIGetErrorInfo(nRetCode);
- }
- int CDevDllLoad::FPIGetVersion(char *psRegBuf, char *psVerBuf)
- {
- if (apiFPIGetVersion==nullptr)
- {
- return -3;
- }
- return apiFPIGetVersion(psRegBuf,psVerBuf);
- }
- int CDevDllLoad::FPIImg2Bmp(char *psImgPath)
- {
- if (apiFPIImg2Bmp==nullptr)
- {
- return -3;
- }
- return apiFPIImg2Bmp(0,psImgPath);
- }
- int CDevDllLoad::FPIBmp2Feature(char *psImgPath, char *psTZ, int *lpLength)
- {
- if (apiFPIBmp2Feature==nullptr)
- {
- return -3;
- }
- return apiFPIBmp2Feature(0x63, psImgPath, psTZ, lpLength);
- }
- int CDevDllLoad::FPIBmp2Template(char *psImgPath1, char *psImgPath2, char *psImgPath3, char *psMB, int *lpLength)
- {
- if (apiFPIBmp2Template==nullptr)
- {
- return -3;
- }
- return apiFPIBmp2Template( 0x63, psImgPath1, psImgPath2, psImgPath3, psMB, lpLength);
- }
- int CDevDllLoad::FPIMatch(char *psMB,char *psTZ, int iLevel)
- {
- if (apiFPIMatch==nullptr)
- {
- return -3;
- }
- return apiFPIMatch(psMB, psTZ, iLevel);
- }
- int CDevDllLoad::FPICancel()
- {
- if (apiFPICancel==nullptr)
- {
- return -3;
- }
- apiFPICancel();
- return 1;
- }
|