head 1.3; access; symbols pkgsrc-2019Q3:1.2.0.32 pkgsrc-2019Q3-base:1.2 pkgsrc-2019Q2:1.2.0.30 pkgsrc-2019Q2-base:1.2 pkgsrc-2019Q1:1.2.0.28 pkgsrc-2019Q1-base:1.2 pkgsrc-2018Q4:1.2.0.26 pkgsrc-2018Q4-base:1.2 pkgsrc-2018Q3:1.2.0.24 pkgsrc-2018Q3-base:1.2 pkgsrc-2018Q2:1.2.0.22 pkgsrc-2018Q2-base:1.2 pkgsrc-2018Q1:1.2.0.20 pkgsrc-2018Q1-base:1.2 pkgsrc-2017Q4:1.2.0.18 pkgsrc-2017Q4-base:1.2 pkgsrc-2017Q3:1.2.0.16 pkgsrc-2017Q3-base:1.2 pkgsrc-2017Q2:1.2.0.12 pkgsrc-2017Q2-base:1.2 pkgsrc-2017Q1:1.2.0.10 pkgsrc-2017Q1-base:1.2 pkgsrc-2016Q4:1.2.0.8 pkgsrc-2016Q4-base:1.2 pkgsrc-2016Q3:1.2.0.6 pkgsrc-2016Q3-base:1.2 pkgsrc-2016Q2:1.2.0.4 pkgsrc-2016Q2-base:1.2 pkgsrc-2016Q1:1.2.0.2 pkgsrc-2016Q1-base:1.2 pkgsrc-2015Q4:1.1.0.2 pkgsrc-2015Q4-base:1.1; locks; strict; comment @// @; 1.3 date 2019.11.25.06.14.32; author markd; state dead; branches; next 1.2; commitid 1MPaIrAH3InFfcMB; 1.2 date 2016.03.29.10.14.05; author markd; state Exp; branches; next 1.1; commitid b7yTQB9g9nEjww0z; 1.1 date 2015.11.03.20.28.57; author markd; state Exp; branches; next ; commitid sGEI6dZKi8SdEGHy; desc @@ 1.3 log @libkface: remove - only used by old digikam @ text @$NetBSD: patch-libkface_recognition-opencv-lbph_facerec_borrowed.cpp,v 1.2 2016/03/29 10:14:05 markd Exp $ opencv3 support. https://bugs.kde.org/show_bug.cgi?id=349601 opencv3.1 - https://git.reviewboard.kde.org/r/126833/ with test reversed --- libkface/recognition-opencv-lbph/facerec_borrowed.cpp.orig 2015-09-03 21:22:44.000000000 +0000 +++ libkface/recognition-opencv-lbph/facerec_borrowed.cpp @@@@ -36,6 +36,8 @@@@ * * ============================================================ */ +#define QT_NO_EMIT + #include "facerec_borrowed.h" // C++ includes @@@@ -375,7 +377,11 @@@@ void LBPHFaceRecognizer::train(InputArra } } +#if OPENCV_VERSION < OPENCV_MAKE_VERSION(3,1,0) void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist) const +#else +void LBPHFaceRecognizer::predict(cv::InputArray _src, cv::Ptr collector, const int state) const +#endif { if(m_histograms.empty()) { @@@@ -394,8 +400,12 @@@@ void LBPHFaceRecognizer::predict(InputAr m_grid_y, /* grid size y */ true /* normed histograms */ ); +#if OPENCV_VERSION < OPENCV_MAKE_VERSION(3,1,0) minDist = DBL_MAX; minClass = -1; +#else + collector->init((int)m_histograms.size(), state); +#endif // This is the standard method @@@@ -406,11 +416,19 @@@@ void LBPHFaceRecognizer::predict(InputAr { double dist = compareHist(m_histograms[sampleIdx], query, CV_COMP_CHISQR); +#if OPENCV_VERSION < OPENCV_MAKE_VERSION(3,1,0) if((dist < minDist) && (dist < m_threshold)) { minDist = dist; minClass = m_labels.at((int) sampleIdx); } +#else + int label = m_labels.at((int) sampleIdx); + if (!collector->emit(label, dist, state)) + { + return; + } +#endif } } @@@@ -422,7 +440,7 @@@@ void LBPHFaceRecognizer::predict(InputAr // Create map "label -> vector of distances to all histograms for this label" std::map > distancesMap; - for(size_t sampleIdx = 0; sampleIdx < m_histograms.size(); sampleIdx++) + for(size_t sampleIdx = 0; sampleIdx < m_histograms.size(); sampleIdx++) { double dist = compareHist(m_histograms[sampleIdx], query, CV_COMP_CHISQR); std::vector& distances = distancesMap[m_labels.at((int) sampleIdx)]; @@@@ -445,11 +463,18 @@@@ void LBPHFaceRecognizer::predict(InputAr double mean = sum / it->second.size(); s += QString("%1: %2 - ").arg(it->first).arg(mean); +#if OPENCV_VERSION < OPENCV_MAKE_VERSION(3,1,0) if((mean < minDist) && (mean < m_threshold)) { minDist = mean; minClass = it->first; } +#else + if (!collector->emit(it->first, mean, state)) + { + return; + } +#endif } kDebug() << s; @@@@ -462,7 +487,7 @@@@ void LBPHFaceRecognizer::predict(InputAr // map "label -> number of histograms" std::map countMap; - for(size_t sampleIdx = 0; sampleIdx < m_histograms.size(); sampleIdx++) + for(size_t sampleIdx = 0; sampleIdx < m_histograms.size(); sampleIdx++) { int label = m_labels.at((int) sampleIdx); double dist = compareHist(m_histograms[sampleIdx], query, CV_COMP_CHISQR); @@@@ -480,7 +505,9 @@@@ void LBPHFaceRecognizer::predict(InputAr scoreMap[it->second]++; } +#if OPENCV_VERSION < OPENCV_MAKE_VERSION(3,1,0) minDist = 0; +#endif QString s("Nearest Neighbor score: "); for (std::map::iterator it = scoreMap.begin(); it != scoreMap.end(); ++it) @@@@ -488,17 +515,26 @@@@ void LBPHFaceRecognizer::predict(InputAr double score = double(it->second) / countMap.at(it->first); s += QString("%1/%2 %3 ").arg(it->second).arg(countMap.at(it->first)).arg(score); +#if OPENCV_VERSION < OPENCV_MAKE_VERSION(3,1,0) if (score > minDist) { minDist = score; minClass = it->first; } +#else + // large is better thus it is -score. + if (!collector->emit(it->first, -score, state)) + { + return; + } +#endif } kDebug() << s; } } +#if OPENCV_VERSION < OPENCV_MAKE_VERSION(3,1,0) int LBPHFaceRecognizer::predict(InputArray _src) const { int label; @@@@ -506,6 +542,7 @@@@ int LBPHFaceRecognizer::predict(InputArr predict(_src, label, dummy); return label; } +#endif // Static method ---------------------------------------------------- @@@@ -531,14 +568,16 @@@@ Ptr LBPHFaceRecogniz return ptr; } -CV_INIT_ALGORITHM(LBPHFaceRecognizer, "FaceRecognizer.LBPH-KFaceIface", - obj.info()->addParam(obj, "radius", obj.m_radius); - obj.info()->addParam(obj, "neighbors", obj.m_neighbors); - obj.info()->addParam(obj, "grid_x", obj.m_grid_x); - obj.info()->addParam(obj, "grid_y", obj.m_grid_y); - obj.info()->addParam(obj, "threshold", obj.m_threshold); - obj.info()->addParam(obj, "histograms", obj.m_histograms); // modification: Make Read/Write - obj.info()->addParam(obj, "labels", obj.m_labels); // modification: Make Read/Write - obj.info()->addParam(obj, "statistic", obj.m_statisticsMode)); // modification: Add parameter +#if OPENCV_VERSION <= OPENCV_MAKE_VERSION(2,4,11) + CV_INIT_ALGORITHM(LBPHFaceRecognizer, "FaceRecognizer.LBPH-KFaceIface", + obj.info()->addParam(obj, "radius", obj.m_radius); + obj.info()->addParam(obj, "neighbors", obj.m_neighbors); + obj.info()->addParam(obj, "grid_x", obj.m_grid_x); + obj.info()->addParam(obj, "grid_y", obj.m_grid_y); + obj.info()->addParam(obj, "threshold", obj.m_threshold); + obj.info()->addParam(obj, "histograms", obj.m_histograms); // modification: Make Read/Write + obj.info()->addParam(obj, "labels", obj.m_labels); // modification: Make Read/Write + obj.info()->addParam(obj, "statistic", obj.m_statisticsMode)); // modification: Add parameter +#endif } // namespace KFaceIface @ 1.2 log @Fix build with opencv3.1 https://git.reviewboard.kde.org/r/126833/ with test reversed @ text @d1 1 a1 1 $NetBSD: patch-libkface_recognition-opencv-lbph_facerec_borrowed.cpp,v 1.1 2015/11/03 20:28:57 markd Exp $ @ 1.1 log @Update to 4.13.0 (part of digikam 4.13.0) Apply upstream patches for opencv3. @ text @d1 1 a1 1 $NetBSD$ d4 1 d8 137 a144 1 @@@@ -531,14 +531,16 @@@@ Ptr LBPHFaceRecogniz @