diff --git a/openbr/plugins/nec3.cmake b/openbr/plugins/nec3.cmake deleted file mode 100644 index 95cdd24..0000000 --- a/openbr/plugins/nec3.cmake +++ /dev/null @@ -1,7 +0,0 @@ -set(BR_WITH_NEC3 OFF CACHE BOOL "Build with NEC NeoFaceSDK 3") - -if(${BR_WITH_NEC3}) - find_package(NEC3 REQUIRED) - set(BR_THIRDPARTY_SRC ${BR_THIRDPARTY_SRC} plugins/nec3.cpp) - set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${NEC3_LIBS}) -endif() diff --git a/openbr/plugins/nec3.cpp b/openbr/plugins/nec3.cpp deleted file mode 100644 index 34a36e5..0000000 --- a/openbr/plugins/nec3.cpp +++ /dev/null @@ -1,179 +0,0 @@ -#ifdef WIN32 -#include -#endif - -#include - -#include "openbr_internal.h" -#include "openbr/core/resource.h" - -using namespace br; - -/*! - * \ingroup initializers - * \brief Initialize NEC3 - * \author Josh Klontz \cite jklontz - * \author Scott Klum \cite sklum - * \warning Needs a maintainer - */ -class NEC3Initializer : public Initializer -{ - Q_OBJECT - - void initialize() const - { - int result = NeoFacePro::Initialize(); - if (result != NFP_SUCCESS) qWarning("NEC3 Initialize error [%d]", result); - Globals->abbreviations.insert("NEC3", "Open!NEC3Enroll:NEC3Compare"); - } - - void finalize() const - { - int result = NeoFacePro::Terminate(); - if (result != NFP_SUCCESS) qWarning("NEC3 Finalize error [%d]", result); - } -}; - -BR_REGISTER(Initializer, NEC3Initializer) - -/*! - * \brief NEC3 Context - * \author Scott Klum \cite sklum - */ - -struct NEC3Context -{ - NeoFacePro::CFaceInfo faceInfo; - NeoFacePro::CFaceFeature faceFeature; - - NEC3Context() { - faceInfo.SetParamAlgorithm(NFP_ALGORITHM003); - faceInfo.SetParamEyesRoll(15); - faceInfo.SetParamEyesMaxWidth(1000); - faceInfo.SetParamEyesMinWidth(30); - faceInfo.SetParamMaxFace(1); - faceInfo.SetParamReliability(0); - - faceFeature.SetParamFeatureType(NFP_FEATURE_S14); - } -}; - -/*! - * \ingroup transforms - * \brief Enroll a face image in NEC NeoFace 3 - * \author Josh Klontz \cite jklontz - * \author Scott Klum \cite sklum - * \warning Needs a maintainer - */ -class NEC3Enroll : public UntrainableTransform -{ - Q_OBJECT - Q_PROPERTY(bool detectOnly READ get_detectOnly WRITE set_detectOnly RESET reset_detectOnly STORED false) - BR_PROPERTY(bool, detectOnly, false) - - Resource contexts; - QSharedPointer flip; - - void init() - { - contexts.setMaxResources(1); - flip = QSharedPointer(Transform::make("Flip(X)")); - } - - void project(const Template &src, Template &dst) const - { - if (src.m().type() != CV_8UC3) qFatal("NEC3Enroll requires 8UC3 images."); - - // Bitmaps are stored upside down - Template flipped; - flip->project(src, flipped); - - cv::Mat input = flipped.m(); - input = input(cv::Rect(0, 0, (input.cols/4)*4, (input.rows/4)*4)).clone(); // For whatever reason, NEC requires images with 4 pixel alignment... - - BITMAPINFO binfo; - binfo.bmiHeader.biWidth = input.cols; - binfo.bmiHeader.biHeight = input.rows; - binfo.bmiHeader.biBitCount = 24; - - NEC3Context *context = contexts.acquire(); - int result = context->faceInfo.FindFace(binfo, input.data); - context->faceInfo.LocateEyes(); - - if (result == NFP_CANNOT_FIND_FACE) { - if (Globals->verbose) qDebug("NEC3Enroll face not found for file %s", qPrintable(src.file.flat())); - } else if (result != NFP_SUCCESS) { - qWarning("NEC3Enroll FindFace error %d for file %s", result, qPrintable(src.file.flat())); - } - - QList landmarks; - for (int i=0; ifaceInfo.GetFaceMax(); i++) { - if (context->faceInfo.SetFaceIndex(i) != NFP_SUCCESS) - continue; - POINT right = context->faceInfo.GetRightEye(); - POINT left = context->faceInfo.GetLeftEye(); - landmarks.append(QPointF(right.x, right.y)); - landmarks.append(QPointF(left.x, left.y)); - - if (detectOnly) { - dst += src.m(); - } else { - result = context->faceFeature.SetFeature(&context->faceInfo); - if (result != NFP_SUCCESS) { - qWarning("NEC3Enroll SetFeature error %d for file %s", result, qPrintable(src.file.flat())); - continue; - } - - void *data; - long size; - result = context->faceFeature.Serialize(&data, &size); - if (result != NFP_SUCCESS) { - qWarning("NEC3Enroll Serialize error %d for file %s", result, qPrintable(src.file.flat())); - continue; - } - - dst += cv::Mat(1, size, CV_8UC1, data).clone(); - NeoFacePro::CFaceFeature::FreeSerializeData(data); - } - - if (src.file.get("ForceEnrollment", false) && !dst.isEmpty()) break; - } - dst.file.appendPoints(landmarks); - - contexts.release(context); - - if (!src.file.get("enrollAll", false) && dst.isEmpty()) dst += cv::Mat(); - } -}; - -BR_REGISTER(Transform, NEC3Enroll) - -/*! - * \ingroup distances - * \brief Compare faces with NEC NeoFace 3 SDK - * \author Josh Klontz \cite jklontz - * \author Scott Klum \cite sklum - * \warning Needs a maintainer - */ -class NEC3Compare : public Distance -{ - Q_OBJECT - - Resource verifierResource; - - float compare(const Template &a, const Template &b) const - { - float score = -std::numeric_limits::max(); - if (a.m().data && b.m().data) { - NeoFacePro::CVerifier *verifier = verifierResource.acquire(); - int result = verifier->Verify(a.m().data, b.m().data, &score); - if (result != NFP_SUCCESS) qWarning("NEC3Compare verify error [%d]", result); - verifierResource.release(verifier); - } - return score; - } -}; - -BR_REGISTER(Distance, NEC3Compare) - -#include "nec3.moc" diff --git a/openbr/plugins/neclatent1.cmake b/openbr/plugins/neclatent1.cmake deleted file mode 100644 index c77bd11..0000000 --- a/openbr/plugins/neclatent1.cmake +++ /dev/null @@ -1,8 +0,0 @@ -set(BR_WITH_NECLATENT1 OFF CACHE BOOL "Build with NEC Latent SDK 1") - -if(${BR_WITH_NECLATENT1}) - find_package(NECLATENT1 REQUIRED) - set(BR_THIRDPARTY_SRC ${BR_THIRDPARTY_SRC} plugins/neclatent1.cpp) - set(BR_THIRDPARTY_LIBS ${BR_THIRDPARTY_LIBS} ${NECLATENT1_LIBS}) - install(DIRECTORY ${NECLATENT1_BIN_DIR}/ DESTINATION bin) -endif() diff --git a/openbr/plugins/neclatent1.cpp b/openbr/plugins/neclatent1.cpp deleted file mode 100644 index ea7b741..0000000 --- a/openbr/plugins/neclatent1.cpp +++ /dev/null @@ -1,132 +0,0 @@ -#include - -#include "openbr_internal.h" - -// Necessary to allocate a large memory though the actual template size may be much smaller -#define MAX_TEMPLATE_SIZE 400000 - -namespace br -{ - -/*! - * \ingroup initializers - * \brief Initialize the NEC Latent SDK wrapper. - * \author Josh Klontz \cite jklontz - */ -class NECLatent1Initialier : public Initializer -{ - Q_OBJECT - - void initialize() const - { - Globals->abbreviations.insert("NECTenprintLFML", "Open+Cvt(Gray)+NECLatent1Enroll(false,LFML):NECLatent1Compare(LFML)"); - Globals->abbreviations.insert("NECTenprintELFT", "Open+Cvt(Gray)+NECLatent1Enroll(false,ELFT):NECLatent1Compare(ELFT)"); - Globals->abbreviations.insert("NECTenprintELFTM", "Open+Cvt(Gray)+NECLatent1Enroll(false,ELFT_M):NECLatent1Compare(ELFT_M)"); - Globals->abbreviations.insert("NECLatentLFML", "Open+Cvt(Gray)+NECLatent1Enroll(true,LFML):NECLatent1Compare(LFML)"); - Globals->abbreviations.insert("NECLatentELFT", "Open+Cvt(Gray)+NECLatent1Enroll(true,ELFT):NECLatent1Compare(ELFT)"); - Globals->abbreviations.insert("NECLatentELFTM", "Open+NECLatent1Enroll(true,ELFT_M):NECLatent1Compare(ELFT_M)"); - } -}; - -BR_REGISTER(Initializer, NECLatent1Initialier) - -/*! - * \ingroup transforms - * \brief Enroll an NEC latent fingerprint. - * \author Josh Klontz \cite jklontz - * \warning Applications using this transform must have their working directory be the 'bin/win/32' folder of the NEC Latent SDK. - */ -class NECLatent1EnrollTransform : public UntrainableTransform -{ - Q_OBJECT - Q_ENUMS(Algorithm) - Q_PROPERTY(bool latent READ get_latent WRITE set_latent RESET reset_latent STORED false) - Q_PROPERTY(Algorithm algorithm READ get_algorithm WRITE set_algorithm RESET reset_algorithm STORED false) - -public: - enum Algorithm { LFML, - ELFT, - ELFT_M }; - -private: - BR_PROPERTY(bool, latent, false) - BR_PROPERTY(Algorithm, algorithm, LFML) - - void project(const Template &src, Template &dst) const - { - static QMutex mutex; - QMutexLocker locker(&mutex); // It seems that most of the API is not reentrant - - if (src.m().type() != CV_8UC1) qFatal("Requires 8UC1 data!"); - uchar *data = src.m().data; - const int rows = src.m().rows; - const int columns = src.m().cols; - - uchar buff[MAX_TEMPLATE_SIZE]; - uchar* pBuff = NULL; - int size, error; - if (latent) { - if (algorithm == LFML) error = NEC_LFML_ExtractLatent(data, rows, columns, 500, buff, &size); - else if (algorithm == ELFT) error = NEC_ELFT_ExtractLatent(data, rows, columns, 500, 32, buff, &size); - else error = NEC_ELFT_M_ExtractLatent(data, columns, 5, &pBuff, &size); - } else { - if (algorithm == LFML) error = NEC_LFML_ExtractTenprint(data, rows, columns, 500, buff, &size); - else if (algorithm == ELFT) error = NEC_ELFT_ExtractTenprint(data, rows, columns, 500, 8, buff, &size); - else error = NEC_ELFT_M_ExtractTenprint(data, rows, columns, 500, 5, &pBuff, &size); - } - - if (!error) { - cv::Mat n(1, size, CV_8UC1); - memcpy(n.data, pBuff ? pBuff : buff, size); - dst.m() = n; - } else { - qWarning("NECLatent1EnrollTransform error %d for file %s.", error, qPrintable(src.file.flat())); - dst.m() = cv::Mat(); - dst.file.set("FTE", true); - } - - if (pBuff != NULL) NEC_ELFT_M_FreeTemplate(&pBuff); - } -}; - -BR_REGISTER(Transform, NECLatent1EnrollTransform) - -/*! - * \ingroup distances - * \brief Compare two NEC latent fingerprints - * \author Josh Klontz \cite jklontz - */ -class NECLatent1CompareDistance : public Distance -{ - Q_OBJECT - Q_ENUMS(Algorithm) - Q_PROPERTY(Algorithm algorithm READ get_algorithm WRITE set_algorithm RESET reset_algorithm STORED false) - -public: - enum Algorithm { LFML, - ELFT, - ELFT_M }; - -private: - BR_PROPERTY(Algorithm, algorithm, LFML) - - float compare(const Template &a, const Template &b) const - { - uchar *aData = a.m().data; - uchar *bData = b.m().data; - if (!a.m().data || !b.m().data) return -std::numeric_limits::max(); - int score, error; - if (algorithm == LFML) error = NEC_LFML_Verify(bData, b.m().total(), aData, a.m().total(), &score); - else if (algorithm == ELFT) error = NEC_ELFT_Verify(bData, aData, &score, 1); - else error = NEC_ELFT_M_Verify(bData, aData, &score, 1); - if (error) - qWarning("NECLatent1CompareDistance error %d", error); - return score; - } -}; - -BR_REGISTER(Distance, NECLatent1CompareDistance) - -} // namespace br - -#include "neclatent1.moc" diff --git a/share/openbr/cmake/FindNEC3.cmake b/share/openbr/cmake/FindNEC3.cmake deleted file mode 100644 index 118a202..0000000 --- a/share/openbr/cmake/FindNEC3.cmake +++ /dev/null @@ -1,6 +0,0 @@ -find_path(NEC3_DIR Include/NeoFacePro.h ${CMAKE_SOURCE_DIR}/3rdparty/*) - -include_directories(${NEC3_DIR}/Include) -link_directories(${NEC3_DIR}/Lib) - -set(NEC3_LIBS NeoFacePro) diff --git a/share/openbr/cmake/FindNECLatent1.cmake b/share/openbr/cmake/FindNECLatent1.cmake deleted file mode 100644 index 9942104..0000000 --- a/share/openbr/cmake/FindNECLatent1.cmake +++ /dev/null @@ -1,14 +0,0 @@ -find_path(NECLATENT1_DIR include/LatentEFS.h ${CMAKE_SOURCE_DIR}/3rdparty/*) - -set(NECLATENT1_SUBDIR /win/${BITNESS}) -set(NECLATENT1_LIB_DIR ${NECLATENT1_DIR}/lib${NECLATENT1_SUBDIR}) -set(NECLATENT1_BIN_DIR ${NECLATENT1_DIR}/bin${NECLATENT1_SUBDIR}) - -include_directories(${NECLATENT1_DIR}/include) -link_directories(${NECLATENT1_LIB_DIR}) - -if(MSVC) - file(GLOB NECLATENT1_LIBS ${NECLATENT1_LIB_DIR}/*.lib) -else() - file(GLOB NECLATENT1_LIBS ${NECLATENT1_BIN_DIR}/*.dll) -endif()