Gentoo Archives: gentoo-commits

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