Commit 3118053b5b576b1b91cdfafefa9898a915c3f45f

Authored by Josh Klontz
1 parent e2bec600

NEC Latent wrapper

.gitignore
1 1 ### Repository Specific ###
2 2 build*
  3 +3rdparty/LatentSDK*
3 4 3rdparty/pittpatt*
4 5  
5 6 ### Generic ###
... ...
CMakeLists.txt
... ... @@ -18,6 +18,12 @@ set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md")
18 18 set(CMAKE_MODULE_PATH "${BR_SHARE_DIR}/cmake" ${CMAKE_MODULE_PATH})
19 19 set(PACKAGE_YEAR 2012)
20 20  
  21 +if(${CMAKE_SIZEOF_VOID_P} MATCHES 8)
  22 + set(BITNESS 64)
  23 +else()
  24 + set(BITNESS 32)
  25 +endif()
  26 +
21 27 # Define resources
22 28 if(WIN32)
23 29 set(CPACK_PACKAGE_ICON "${BR_SHARE_DIR}\\\\openbr-small.png")
... ...
sdk/plugins/neclatent1.cmake 0 โ†’ 100644
  1 +set(BR_WITH_NECLATENT1 OFF CACHE BOOL "Build with NEC Latent SDK 1")
  2 +
  3 +if(${BR_WITH_NECLATENT1})
  4 + find_package(NECLATENT1 REQUIRED)
  5 + set(BR_THIRDPARTY_SRC ${BR_THIRDPARTY_SRC} plugins/neclatent1.cpp)
  6 + set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${NECLATENT1_LIBS})
  7 + install(DIRECTORY ${NECLATENT1_BIN_DIR}/ DESTINATION bin)
  8 +endif()
... ...
sdk/plugins/neclatent1.cpp 0 โ†’ 100644
  1 +#include <openbr_plugin.h>
  2 +#include <LatentEFS.h>
  3 +
  4 +// necessary to allocate a large memory though the actual template size
  5 +// may be much smaller
  6 +#define MAX_TEMPLATE_SIZE 400000
  7 +
  8 +namespace br
  9 +{
  10 +
  11 +/*!
  12 + * \ingroup initializers
  13 + * \brief Initialize the NEC Latent SDK wrapper.
  14 + * \author Josh Klontz \cite jklontz
  15 + */
  16 +class NECLatent1Initialier : public Initializer
  17 +{
  18 + Q_OBJECT
  19 +
  20 + void initialize() const
  21 + {
  22 + Globals->abbreviations.insert("NECLatent1", "Open+Cvt(Gray)+NECLatent1Enroll:NECLatent1Compare");
  23 + }
  24 +};
  25 +
  26 +BR_REGISTER(Initializer, NECLatent1Initialier)
  27 +
  28 +/*!
  29 + * \ingroup transforms
  30 + * \brief Enroll an NEC latent fingerprint.
  31 + * \author Josh Klontz \cite jklontz
  32 + */
  33 +class NECLatent1EnrollTransform : public UntrainableTransform
  34 +{
  35 + Q_OBJECT
  36 +
  37 + void project(const Template &src, Template &dst) const
  38 + {
  39 + if (src.m().type() != CV_8UC1) qFatal("Requires 8UC1 data!");
  40 + unsigned char *data = new unsigned char[MAX_TEMPLATE_SIZE];
  41 + int size = 0;
  42 + int error = NEC_LFML_ExtractLatent(src.m().data, src.m().rows, src.m().cols, 500, data, &size);
  43 + if (!error) {
  44 + cv::Mat n(1, size, CV_8UC1);
  45 + memcpy(n.data, data, size);
  46 + dst.m() = n;
  47 + } else {
  48 + qWarning("NECLatent1EnrollTransform error %d for file %s.", error, qPrintable(src.file.flat()));
  49 + dst.m() = cv::Mat();
  50 + dst.file.set("FTE", true);
  51 + }
  52 +
  53 + delete[] data;
  54 + }
  55 +};
  56 +
  57 +BR_REGISTER(Transform, NECLatent1EnrollTransform)
  58 +
  59 +/*!
  60 + * \ingroup distances
  61 + * \brief Compare two NEC latent fingerprints
  62 + * \author Josh Klontz \cite jklontz
  63 + */
  64 +class NECLatent1CompareDistance : public Distance
  65 +{
  66 + Q_OBJECT
  67 +
  68 + float compare(const Template &a, const Template &b) const
  69 + {
  70 + if (!a.m().data || !b.m().data) return -std::numeric_limits<float>::max();
  71 + int score;
  72 + NEC_LFML_Verify(b.m().data, b.m().total(), a.m().data, a.m().total(), &score);
  73 + return score;
  74 + }
  75 +};
  76 +
  77 +BR_REGISTER(Distance, NECLatent1CompareDistance)
  78 +
  79 +} // namespace br
  80 +
  81 +#include "neclatent1.moc"
... ...
share/openbr/cmake/FindNECLatent1.cmake 0 โ†’ 100644
  1 +find_path(NECLATENT1_DIR include/LatentEFS.h ${CMAKE_SOURCE_DIR}/3rdparty/*)
  2 +
  3 +set(NECLATENT1_SUBDIR /win/${BITNESS})
  4 +set(NECLATENT1_LIB_DIR ${NECLATENT1_DIR}/lib${NECLATENT1_SUBDIR})
  5 +set(NECLATENT1_BIN_DIR ${NECLATENT1_DIR}/bin${NECLATENT1_SUBDIR})
  6 +
  7 +include_directories(${NECLATENT1_DIR}/include)
  8 +link_directories(${NECLATENT1_LIB_DIR})
  9 +
  10 +if(MSVC)
  11 + file(GLOB NECLATENT1_LIBS ${NECLATENT1_LIB_DIR}/*.lib)
  12 +else()
  13 + file(GLOB NECLATENT1_LIBS ${NECLATENT1_BIN_DIR}/*.dll)
  14 +endif()
... ...
share/openbr/cmake/InstallDependencies.cmake
... ... @@ -75,11 +75,7 @@ function(install_compiler_libraries)
75 75 if(${BR_INSTALL_DEPENDENCIES} AND MINGW)
76 76 set(MINGW_DIR "MINGW_DIR-NOTFOUND" CACHE PATH "MinGW Path")
77 77 get_filename_component(MINGW_DIR ${CMAKE_CXX_COMPILER} PATH)
78   - if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
79   - install(FILES ${MINGW_DIR}/libgcc_s_sjlj-1.dll ${MINGW_DIR}/libstdc++-6.dll DESTINATION bin)
80   - else()
81   - install(FILES ${MINGW_DIR}/libgcc_s_dw2-1.dll ${MINGW_DIR}/libstdc++-6.dll DESTINATION bin)
82   - endif()
  78 + install(FILES ${MINGW_DIR}/libgcc_s_sjlj-1.dll ${MINGW_DIR}/libstdc++-6.dll DESTINATION bin)
83 79 endif()
84 80 endfunction()
85 81  
... ...