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