diff options
author | markd <markd@pkgsrc.org> | 2016-03-29 10:14:05 +0000 |
---|---|---|
committer | markd <markd@pkgsrc.org> | 2016-03-29 10:14:05 +0000 |
commit | 1549c5d9948c01cb45e3c37404fe3bb0a3c908ca (patch) | |
tree | db3762ee182ff3cf19bc848d730e79a1ec438b34 | |
parent | 525b29407dfaaa2c5debf013e8f3a59e2f1c3ef7 (diff) | |
download | pkgsrc-1549c5d9948c01cb45e3c37404fe3bb0a3c908ca.tar.gz |
Fix build with opencv3.1
https://git.reviewboard.kde.org/r/126833/ with test reversed
4 files changed, 171 insertions, 10 deletions
diff --git a/graphics/libkface/Makefile b/graphics/libkface/Makefile index 57ff701cb5f..cf3ab020ec3 100644 --- a/graphics/libkface/Makefile +++ b/graphics/libkface/Makefile @@ -1,8 +1,8 @@ -# $NetBSD: Makefile,v 1.29 2016/03/05 11:27:49 jperkin Exp $ +# $NetBSD: Makefile,v 1.30 2016/03/29 10:14:05 markd Exp $ # PKGNAME= libkface-4.13.0 -PKGREVISION= 1 +PKGREVISION= 2 DISTNAME= digikam-4.13.0 CATEGORIES= graphics MASTER_SITES= ${MASTER_SITE_KDE:=digikam/} diff --git a/graphics/libkface/distinfo b/graphics/libkface/distinfo index f355ede6752..d749df1547a 100644 --- a/graphics/libkface/distinfo +++ b/graphics/libkface/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.6 2015/11/03 20:28:57 markd Exp $ +$NetBSD: distinfo,v 1.7 2016/03/29 10:14:05 markd Exp $ SHA1 (digikam-4.13.0.tar.bz2) = d696ac88dcb3bcbd3a5da83b0fbe5e7315a43f92 RMD160 (digikam-4.13.0.tar.bz2) = 11d6aa15a94cd38acca79f2a31f65393a01a2b0b @@ -9,6 +9,6 @@ SHA1 (patch-README) = 520dd6ee6562b708fb96adf6bf209056adb5d159 SHA1 (patch-libkface_CMakeLists.txt) = d183bcfa09244984350fa0ae2957d877618b2d0d SHA1 (patch-libkface_detection_opencvfacedetector.cpp) = e8a31a469df3f0bc4d3f3bb2c3864a0913985fab SHA1 (patch-libkface_libopencv.h.cmake.in) = 354103b0be8e202630059dc438af9d03837bed72 -SHA1 (patch-libkface_recognition-opencv-lbph_facerec_borrowed.cpp) = d66bbb999105426df7b1281f0e5082f755864c73 -SHA1 (patch-libkface_recognition-opencv-lbph_facerec_borrowed.h) = a69318610fd96dd13e177c7bb93cf22bf9c4768d +SHA1 (patch-libkface_recognition-opencv-lbph_facerec_borrowed.cpp) = 29d390a44a52daf15e7bfd8f2b7e7ee73d59f45a +SHA1 (patch-libkface_recognition-opencv-lbph_facerec_borrowed.h) = 96e28212344df9bd749ed8db69d877a0aba3c140 SHA1 (patch-libkface_recognition-opencv-lbph_lbphfacemodel.cpp) = c181d1b94948f7988081b09e3c2bf3190eaf046e diff --git a/graphics/libkface/patches/patch-libkface_recognition-opencv-lbph_facerec_borrowed.cpp b/graphics/libkface/patches/patch-libkface_recognition-opencv-lbph_facerec_borrowed.cpp index d1b81f42ddb..792ad25b0f7 100644 --- a/graphics/libkface/patches/patch-libkface_recognition-opencv-lbph_facerec_borrowed.cpp +++ b/graphics/libkface/patches/patch-libkface_recognition-opencv-lbph_facerec_borrowed.cpp @@ -1,10 +1,147 @@ -$NetBSD: patch-libkface_recognition-opencv-lbph_facerec_borrowed.cpp,v 1.1 2015/11/03 20:28:57 markd Exp $ +$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 -@@ -531,14 +531,16 @@ Ptr<LBPHFaceRecognizer> LBPHFaceRecogniz +@@ -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<cv::face::PredictCollector> 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>((int) sampleIdx); + } ++#else ++ int label = m_labels.at<int>((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<int, std::vector<int> > 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<int>& distances = distancesMap[m_labels.at<int>((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<int, int> 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>((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<int,int>::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<LBPHFaceRecognizer> LBPHFaceRecogniz return ptr; } diff --git a/graphics/libkface/patches/patch-libkface_recognition-opencv-lbph_facerec_borrowed.h b/graphics/libkface/patches/patch-libkface_recognition-opencv-lbph_facerec_borrowed.h index 435a8a2aec3..a156006a49b 100644 --- a/graphics/libkface/patches/patch-libkface_recognition-opencv-lbph_facerec_borrowed.h +++ b/graphics/libkface/patches/patch-libkface_recognition-opencv-lbph_facerec_borrowed.h @@ -1,6 +1,7 @@ -$NetBSD: patch-libkface_recognition-opencv-lbph_facerec_borrowed.h,v 1.1 2015/11/03 20:28:57 markd Exp $ +$NetBSD: patch-libkface_recognition-opencv-lbph_facerec_borrowed.h,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.h.orig 2015-09-03 21:22:44.000000000 +0000 +++ libkface/recognition-opencv-lbph/facerec_borrowed.h @@ -30,7 +31,30 @@ opencv3 support. https://bugs.kde.org/show_bug.cgi?id=349601 static cv::Ptr<LBPHFaceRecognizer> create(int radius=1, int neighbors=8, int grid_x=8, int grid_y=8, double threshold = DBL_MAX, PredictionStatistics statistics = NearestNeighbor); -@@ -139,6 +148,34 @@ public: +@@ -116,6 +125,8 @@ public: + */ + void update(cv::InputArrayOfArrays src, cv::InputArray labels); + ++ ++#if OPENCV_VERSION < OPENCV_MAKE_VERSION(3,1,0) + /** + * Predicts the label of a query image in src. + */ +@@ -125,6 +136,13 @@ public: + * Predicts the label and confidence for a given sample. + */ + void predict(cv::InputArray _src, int &label, double &dist) const; ++#else ++ using cv::face::FaceRecognizer::predict; ++ /* ++ * Predict ++ */ ++ void predict(cv::InputArray src, cv::Ptr<cv::face::PredictCollector> collector, const int state = 0) const override; ++#endif + + /** + * See FaceRecognizer::load(). +@@ -139,6 +157,34 @@ public: /** * Getter functions. */ @@ -65,7 +89,7 @@ opencv3 support. https://bugs.kde.org/show_bug.cgi?id=349601 int neighbors() const { return m_neighbors; } int radius() const { return m_radius; } int grid_x() const { return m_grid_x; } -@@ -147,6 +184,8 @@ public: +@@ -147,6 +193,8 @@ public: // NOTE: Implementation done through CV_INIT_ALGORITHM macro from OpenCV. cv::AlgorithmInfo* info() const; |