FingerDev.cpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #include "FingerDev.h"
  2. #include "log4vendor.h"
  3. FingerDev::FingerDev()
  4. {
  5. m_hDll = NULL;
  6. }
  7. FingerDev::~FingerDev()
  8. {
  9. if(m_hDll != NULL)
  10. {
  11. UnLoad_so();
  12. m_hDll = NULL;
  13. }
  14. }
  15. int FingerDev::Open(const char* sPathFile)
  16. {
  17. if(!Load_so(sPathFile))
  18. return LS_ERROR_DEVICE_NOT_INIT;
  19. return pWELLDeviceInit();
  20. }
  21. int FingerDev::Close()
  22. {
  23. int iRt = LS_ERROR_SUCCESS;
  24. iRt = pWELLDeviceClose();
  25. return iRt;
  26. }
  27. int FingerDev::Reset()
  28. {
  29. return LS_ERROR_SUCCESS;
  30. }
  31. int FingerDev::GetFPIImg2Bmp(char *psImgPath)
  32. {
  33. int iRt = LS_ERROR_SUCCESS;
  34. int timeOut = 2;
  35. iRt = pWELLImg2Bmp(timeOut, psImgPath);
  36. return iRt;
  37. }
  38. int FingerDev::GetFPIBmp2Feature(const char* imagePath, LPBYTE lpbFeature, int &iLength)
  39. {
  40. int iRt = LS_ERROR_SUCCESS;
  41. //数据类型,1-0x30格式 2-BASE64格式
  42. iRt = pWELLBmp2Feature(0x63, (char*)imagePath, (char*)lpbFeature,&iLength);
  43. // iRt = pWELLGetFeature(0x10, 1, (char*)lpbFeature);
  44. // if(iRt == LS_ERROR_SUCCESS)
  45. // {
  46. // iRt = pWELLImg2Bmp(1, (char*)imagePath);
  47. // iLength = strlen((char*)lpbFeature);
  48. // }
  49. return iRt;
  50. }
  51. int FingerDev::GetFPIBmp2Template(const char* imagePath1, const char* imagePath2, const char* imagePath3, LPBYTE lpbTemplate, int &iLength)
  52. {
  53. int iRt = LS_ERROR_SUCCESS;
  54. //数据类型,1-0x30格式 2-BASE64格式
  55. iRt = pWELLBmp2Template(0x63, (char*)imagePath1, (char*)imagePath2, (char*)imagePath3, (char*)lpbTemplate,&iLength);
  56. return iRt;
  57. }
  58. int FingerDev::FPIMatch(LPBYTE lpbTemplate, LPBYTE lbpFeature, int level)
  59. {
  60. int iRt = LS_ERROR_SUCCESS;
  61. iRt = pWELLMatch((char*)lpbTemplate, (char*)lbpFeature, level);
  62. return iRt;
  63. }
  64. int FingerDev::Cancel()
  65. {
  66. int iRt = LS_ERROR_SUCCESS;
  67. pWELLCancel();
  68. return iRt;
  69. }
  70. int FingerDev::GetErrInfo(char* errMsg, int iRet)
  71. {
  72. errMsg = pWELLGetErrorInfo(iRet);
  73. return LS_ERROR_SUCCESS;
  74. }
  75. int FingerDev::GetVersion(char* ver)
  76. {
  77. int iRt = LS_ERROR_SUCCESS;
  78. char sDevInfo[64+1] = {0};
  79. char sID[1024] = {0};
  80. iRt = pWELLGetVersion(sDevInfo, sID);
  81. strcpy(ver, sDevInfo);
  82. return iRt;
  83. }
  84. int FingerDev::UnLoad_so()
  85. {
  86. // if(m_hDll)
  87. // {
  88. // //m_hDll.unload();
  89. // m_hDll = NULL;
  90. // }
  91. return true;
  92. }
  93. int FingerDev::Load_so(const char* sPathFile)
  94. {
  95. m_hDll = dlopen(sPathFile, RTLD_LAZY); //load so
  96. if (m_hDll != NULL)
  97. {
  98. CMB_LOG_BODY(CMB_LOG_INFO, "load library successed!");
  99. pWELLGetErrorInfo = (WELLGetErrorInfo)dlsym(m_hDll, "WELLGetErrorInfo");
  100. if(!pWELLGetErrorInfo)
  101. {
  102. CMB_LOG_BODY(CMB_LOG_INFO, "load'WELLGetErrorInfo()'failed!");
  103. return false;
  104. }
  105. pWELLDeviceInit = (WELLDeviceInit)dlsym(m_hDll, "WELLDeviceInit");
  106. pWELLDeviceClose = (WELLDeviceClose)dlsym(m_hDll, "WELLDeviceClose");
  107. // pWELLGetFingerprintAndMatch = (WELLGetFingerprintAndMatch)dlsym(m_hDll, "WELLGetFingerprintAndMatch");
  108. pWELLGetFeature = (WELLGetFeature)dlsym(m_hDll, "WELLGetFeature");
  109. pWELLGetTemplate = (WELLGetTemplate)dlsym(m_hDll, "WELLGetTemplate");
  110. pWELLGetVersion = (WELLGetVersion)dlsym(m_hDll, "WELLGetVersion");
  111. pWELLMatch = (WELLMatch)dlsym(m_hDll, "WELLMatch");
  112. pWELLImg2Bmp = (WELLImg2Bmp)dlsym(m_hDll, "WELLImg2Bmp");
  113. pWELLBmp2Feature = (WELLBmp2Feature)dlsym(m_hDll, "WELLBmp2Feature");
  114. pWELLBmp2Template = (WELLBmp2Template)dlsym(m_hDll, "WELLBmp2Template");
  115. pWELLCancel = (WELLCancel)dlsym(m_hDll, "WELLCancel");
  116. }
  117. else
  118. {
  119. CMB_LOG_BODY(CMB_LOG_INFO, "load library failed!");
  120. return false;
  121. }
  122. return true;
  123. }