1 |
commit: 477212f2d5063ef80d401d94ea2f68bb402a7e3d |
2 |
Author: Andreas Sturmlechner <andreas.sturmlechner <AT> gmail <DOT> com> |
3 |
AuthorDate: Sat Nov 26 12:17:26 2016 +0000 |
4 |
Commit: Michael Palimaka <kensington <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Nov 26 18:04:32 2016 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=477212f2 |
7 |
|
8 |
kde-apps/libkface: Fix build with >=media-libs/opencv-3.1.0-r6 |
9 |
|
10 |
media-libs/opencv-3.1.0-r6 is using a contrib snapshot from git master |
11 |
breaking API. |
12 |
|
13 |
Gentoo-bug: 600238 |
14 |
|
15 |
Package-Manager: portage-2.3.0 |
16 |
|
17 |
.../libkface-16.08.3-opencv3.2-gentoo-3.1.patch | 167 +++++++++++++++++++++ |
18 |
kde-apps/libkface/libkface-16.08.3.ebuild | 5 +- |
19 |
2 files changed, 170 insertions(+), 2 deletions(-) |
20 |
|
21 |
diff --git a/kde-apps/libkface/files/libkface-16.08.3-opencv3.2-gentoo-3.1.patch b/kde-apps/libkface/files/libkface-16.08.3-opencv3.2-gentoo-3.1.patch |
22 |
new file mode 100644 |
23 |
index 00000000..abba02d |
24 |
--- /dev/null |
25 |
+++ b/kde-apps/libkface/files/libkface-16.08.3-opencv3.2-gentoo-3.1.patch |
26 |
@@ -0,0 +1,167 @@ |
27 |
+diff --git a/src/recognition-opencv-lbph/facerec_borrowed.h b/src/recognition-opencv-lbph/facerec_borrowed.h |
28 |
+index 27ad77a..f197d22 100644 |
29 |
+--- a/src/recognition-opencv-lbph/facerec_borrowed.h |
30 |
++++ b/src/recognition-opencv-lbph/facerec_borrowed.h |
31 |
+@@ -125,6 +125,8 @@ public: |
32 |
+ */ |
33 |
+ void update(cv::InputArrayOfArrays src, cv::InputArray labels); |
34 |
+ |
35 |
++ |
36 |
++#if OPENCV_TEST_VERSION(3,1,0) |
37 |
+ /** |
38 |
+ * Predicts the label of a query image in src. |
39 |
+ */ |
40 |
+@@ -134,6 +136,13 @@ public: |
41 |
+ * Predicts the label and confidence for a given sample. |
42 |
+ */ |
43 |
+ void predict(cv::InputArray _src, int &label, double &dist) const; |
44 |
++#else |
45 |
++ using cv::face::FaceRecognizer::predict; |
46 |
++ /* |
47 |
++ * Predict |
48 |
++ */ |
49 |
++ void predict(cv::InputArray src, cv::Ptr<cv::face::PredictCollector> collector) const override; |
50 |
++#endif |
51 |
+ |
52 |
+ /** |
53 |
+ * See FaceRecognizer::load(). |
54 |
+diff --git a/src/recognition-opencv-lbph/facerec_borrowed.cpp b/src/recognition-opencv-lbph/facerec_borrowed.cpp |
55 |
+index 748691e..3c37ce2 100644 |
56 |
+--- a/src/recognition-opencv-lbph/facerec_borrowed.cpp |
57 |
++++ b/src/recognition-opencv-lbph/facerec_borrowed.cpp |
58 |
+@@ -36,6 +36,8 @@ |
59 |
+ * |
60 |
+ * ============================================================ */ |
61 |
+ |
62 |
++#define QT_NO_EMIT |
63 |
++ |
64 |
+ #include "facerec_borrowed.h" |
65 |
+ |
66 |
+ // C++ includes |
67 |
+@@ -375,7 +377,11 @@ void LBPHFaceRecognizer::train(InputArrayOfArrays _in_src, InputArray _inm_label |
68 |
+ } |
69 |
+ } |
70 |
+ |
71 |
++#if OPENCV_TEST_VERSION(3,1,0) |
72 |
+ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist) const |
73 |
++#else |
74 |
++void LBPHFaceRecognizer::predict(cv::InputArray _src, cv::Ptr<cv::face::PredictCollector> collector) const |
75 |
++#endif |
76 |
+ { |
77 |
+ if(m_histograms.empty()) |
78 |
+ { |
79 |
+@@ -394,8 +400,12 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist |
80 |
+ m_grid_y, /* grid size y */ |
81 |
+ true /* normed histograms */ |
82 |
+ ); |
83 |
++#if OPENCV_TEST_VERSION(3,1,0) |
84 |
+ minDist = DBL_MAX; |
85 |
+ minClass = -1; |
86 |
++#else |
87 |
++ collector->init((int)m_histograms.size()); |
88 |
++#endif |
89 |
+ |
90 |
+ // This is the standard method |
91 |
+ |
92 |
+@@ -406,11 +416,19 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist |
93 |
+ { |
94 |
+ double dist = compareHist(m_histograms[sampleIdx], query, CV_COMP_CHISQR); |
95 |
+ |
96 |
++#if OPENCV_TEST_VERSION(3,1,0) |
97 |
+ if((dist < minDist) && (dist < m_threshold)) |
98 |
+ { |
99 |
+ minDist = dist; |
100 |
+ minClass = m_labels.at<int>((int) sampleIdx); |
101 |
+ } |
102 |
++#else |
103 |
++ int label = m_labels.at<int>((int) sampleIdx); |
104 |
++ if (!collector->collect(label, dist)) |
105 |
++ { |
106 |
++ return; |
107 |
++ } |
108 |
++#endif |
109 |
+ } |
110 |
+ } |
111 |
+ |
112 |
+@@ -422,7 +440,7 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist |
113 |
+ // Create map "label -> vector of distances to all histograms for this label" |
114 |
+ std::map<int, std::vector<int> > distancesMap; |
115 |
+ |
116 |
+- for(size_t sampleIdx = 0; sampleIdx < m_histograms.size(); sampleIdx++) |
117 |
++ for(size_t sampleIdx = 0; sampleIdx < m_histograms.size(); sampleIdx++) |
118 |
+ { |
119 |
+ double dist = compareHist(m_histograms[sampleIdx], query, CV_COMP_CHISQR); |
120 |
+ std::vector<int>& distances = distancesMap[m_labels.at<int>((int) sampleIdx)]; |
121 |
+@@ -445,11 +463,18 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist |
122 |
+ double mean = sum / it->second.size(); |
123 |
+ s += QString::fromLatin1("%1: %2 - ").arg(it->first).arg(mean); |
124 |
+ |
125 |
++#if OPENCV_TEST_VERSION(3,1,0) |
126 |
+ if((mean < minDist) && (mean < m_threshold)) |
127 |
+ { |
128 |
+ minDist = mean; |
129 |
+ minClass = it->first; |
130 |
+ } |
131 |
++#else |
132 |
++ if (!collector->collect(it->first, mean)) |
133 |
++ { |
134 |
++ return; |
135 |
++ } |
136 |
++#endif |
137 |
+ } |
138 |
+ |
139 |
+ qCDebug(LIBKFACE_LOG) << s; |
140 |
+@@ -462,7 +487,7 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist |
141 |
+ // map "label -> number of histograms" |
142 |
+ std::map<int, int> countMap; |
143 |
+ |
144 |
+- for(size_t sampleIdx = 0; sampleIdx < m_histograms.size(); sampleIdx++) |
145 |
++ for(size_t sampleIdx = 0; sampleIdx < m_histograms.size(); sampleIdx++) |
146 |
+ { |
147 |
+ int label = m_labels.at<int>((int) sampleIdx); |
148 |
+ double dist = compareHist(m_histograms[sampleIdx], query, CV_COMP_CHISQR); |
149 |
+@@ -480,7 +505,9 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist |
150 |
+ scoreMap[it->second]++; |
151 |
+ } |
152 |
+ |
153 |
++#if OPENCV_TEST_VERSION(3,1,0) |
154 |
+ minDist = 0; |
155 |
++#endif |
156 |
+ QString s = QString::fromLatin1("Nearest Neighbor score: "); |
157 |
+ |
158 |
+ for (std::map<int,int>::iterator it = scoreMap.begin(); it != scoreMap.end(); ++it) |
159 |
+@@ -488,17 +515,26 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist |
160 |
+ double score = double(it->second) / countMap.at(it->first); |
161 |
+ s += QString::fromLatin1("%1/%2 %3 ").arg(it->second).arg(countMap.at(it->first)).arg(score); |
162 |
+ |
163 |
++#if OPENCV_TEST_VERSION(3,1,0) |
164 |
+ if (score > minDist) |
165 |
+ { |
166 |
+ minDist = score; |
167 |
+ minClass = it->first; |
168 |
+ } |
169 |
++#else |
170 |
++ // large is better thus it is -score. |
171 |
++ if (!collector->collect(it->first, -score)) |
172 |
++ { |
173 |
++ return; |
174 |
++ } |
175 |
++#endif |
176 |
+ } |
177 |
+ |
178 |
+ qCDebug(LIBKFACE_LOG) << s; |
179 |
+ } |
180 |
+ } |
181 |
+ |
182 |
++#if OPENCV_TEST_VERSION(3,1,0) |
183 |
+ int LBPHFaceRecognizer::predict(InputArray _src) const |
184 |
+ { |
185 |
+ int label; |
186 |
+@@ -506,6 +542,7 @@ int LBPHFaceRecognizer::predict(InputArray _src) const |
187 |
+ predict(_src, label, dummy); |
188 |
+ return label; |
189 |
+ } |
190 |
++#endif |
191 |
+ |
192 |
+ // Static method ---------------------------------------------------- |
193 |
+ |
194 |
|
195 |
diff --git a/kde-apps/libkface/libkface-16.08.3.ebuild b/kde-apps/libkface/libkface-16.08.3.ebuild |
196 |
index ea2fa95..5ae95e4 100644 |
197 |
--- a/kde-apps/libkface/libkface-16.08.3.ebuild |
198 |
+++ b/kde-apps/libkface/libkface-16.08.3.ebuild |
199 |
@@ -19,11 +19,12 @@ DEPEND=" |
200 |
$(add_qt_dep qtsql) |
201 |
$(add_qt_dep qtwidgets) |
202 |
$(add_qt_dep qtxml) |
203 |
- media-libs/opencv:=[contrib(+)] |
204 |
+ media-libs/opencv:= |
205 |
+ || ( <media-libs/opencv-3.0.0 >=media-libs/opencv-3.1.0-r6[contrib] ) |
206 |
" |
207 |
RDEPEND="${DEPEND}" |
208 |
|
209 |
-PATCHES=( "${FILESDIR}/${PN}-15.12.2-opencv3.1.patch" ) |
210 |
+PATCHES=( "${FILESDIR}/${PN}-16.08.3-opencv3.2-gentoo-3.1.patch" ) # not upstreamable like that |
211 |
|
212 |
src_configure() { |
213 |
local mycmakeargs=( |