]>
Commit | Line | Data |
---|---|---|
e028b4c5 JR |
1 | diff -urN digikam-4.13.0/core/app/utils/libopencv.h digikam-4.13.0-opencv3/core/app/utils/libopencv.h |
2 | --- digikam-4.13.0/core/app/utils/libopencv.h 2015-09-03 23:22:45.000000000 +0200 | |
3 | +++ digikam-4.13.0-opencv3/core/app/utils/libopencv.h 2016-03-22 17:06:26.155608182 +0100 | |
4 | @@ -7,7 +7,7 @@ | |
5 | * @date 2010-06-16 | |
6 | * @brief Wrapper for OpenCV header files | |
7 | * | |
8 | - * @author Copyright (C) 2012-2014 by Gilles Caulier | |
9 | + * @author Copyright (C) 2012-2015 by Gilles Caulier | |
10 | * <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a> | |
11 | * | |
12 | * This program is free software; you can redistribute it | |
13 | @@ -46,17 +46,19 @@ | |
14 | ||
15 | #define OPENCV_MAKE_VERSION(major,minor,patch) (((major) << 16) | ((minor) << 8) | (patch)) | |
16 | #define OPENCV_VERSION OPENCV_MAKE_VERSION(CV_MAJOR_VERSION,CV_MINOR_VERSION,CV_SUBMINOR_VERSION) | |
17 | -#define OPENCV_TEST_VERSION(major,minor,patch) ( OPENCV_VERSION >= OPENCV_MAKE_VERSION(major,minor,patch) ) | |
18 | +#define OPENCV_TEST_VERSION(major,minor,patch) ( OPENCV_VERSION < OPENCV_MAKE_VERSION(major,minor,patch) ) | |
19 | ||
20 | -#if OPENCV_TEST_VERSION(2,3,0) | |
21 | +#if OPENCV_TEST_VERSION(2,5,0) | |
22 | # include <opencv2/opencv.hpp> | |
23 | # include <opencv2/legacy/compat.hpp> | |
24 | # include <opencv/cvaux.h> | |
25 | +# include <opencv2/imgproc/imgproc.hpp> | |
26 | #else | |
27 | # include <opencv/cv.h> | |
28 | # include <opencv/cvaux.h> | |
29 | # include <opencv/cxcore.h> | |
30 | # include <opencv/highgui.h> | |
31 | +# include <opencv2/imgproc.hpp> | |
32 | #endif | |
33 | ||
34 | // Restore warnings | |
35 | diff -urN digikam-4.13.0/core/CMakeLists.txt digikam-4.13.0-opencv3/core/CMakeLists.txt | |
36 | --- digikam-4.13.0/core/CMakeLists.txt 2015-09-03 23:22:45.000000000 +0200 | |
37 | +++ digikam-4.13.0-opencv3/core/CMakeLists.txt 2016-03-22 17:06:26.155608182 +0100 | |
38 | @@ -12,6 +12,7 @@ | |
39 | ||
40 | option(ENABLE_INTERNALMYSQL "Build digiKam with internal MySQL server executable (default=OFF)" OFF) | |
41 | option(ENABLE_LCMS2 "Build digiKam with LCMS2 instead LCMS1 (default=OFF)" OFF) | |
42 | +option(ENABLE_OPENCV3 "Build digiKam with OpenCV3 instead OpenCV2 (default=OFF)" OFF) | |
43 | option(ENABLE_BALOOSUPPORT "Build digiKam with Baloo support (default=ON)" ON) | |
44 | option(ENABLE_KDEPIMLIBSSUPPORT "Build digiKam with Kdepimlibs support (default=OFF)" OFF) | |
45 | ||
46 | @@ -122,8 +123,13 @@ | |
47 | ||
48 | # -- check OpenCV -------------------------------------------------------------------------------- | |
49 | ||
50 | -set(OPENCV_MIN_VERSION "2.4.9") | |
51 | -DETECT_OPENCV(${OPENCV_MIN_VERSION} core highgui objdetect contrib legacy imgproc) | |
52 | +if (ENABLE_OPENCV3) | |
53 | + set(OPENCV_MIN_VERSION "3.0.0") | |
54 | + DETECT_OPENCV(${OPENCV_MIN_VERSION} core face highgui objdetect imgproc) | |
55 | +else() | |
56 | + set(OPENCV_MIN_VERSION "2.4.9") | |
57 | + DETECT_OPENCV(${OPENCV_MIN_VERSION} core highgui objdetect contrib legacy imgproc) | |
58 | +endif() | |
59 | ||
60 | # -- check the libkdcraw version ----------------------------------------------------------------- | |
61 | ||
62 | diff -urN digikam-4.13.0/core/libs/database/imgqsort/imgqsort.cpp digikam-4.13.0-opencv3/core/libs/database/imgqsort/imgqsort.cpp | |
63 | --- digikam-4.13.0/core/libs/database/imgqsort/imgqsort.cpp 2015-09-03 23:22:45.000000000 +0200 | |
64 | +++ digikam-4.13.0-opencv3/core/libs/database/imgqsort/imgqsort.cpp 2016-03-22 17:06:26.155608182 +0100 | |
65 | @@ -282,10 +282,15 @@ | |
66 | ||
67 | MixerFilter mixer(&d->image, 0L, settings); | |
68 | mixer.startFilterDirectly(); | |
69 | - | |
70 | d->image.putImageData(mixer.getTargetImage().bits()); | |
71 | + | |
72 | +#if OPENCV_TEST_VERSION(3,0,0) | |
73 | d->src = cvCreateMat(d->image.numPixels(), 3, CV_8UC3); // Create a matrix containing the pixel values of original image | |
74 | d->src_gray = cvCreateMat(d->image.numPixels(), 1, CV_8UC1); // Create a matrix containing the pixel values of grayscaled image | |
75 | +#else | |
76 | + d->src = Mat(d->image.numPixels(), 3, CV_8UC3); // Create a matrix containing the pixel values of original image | |
77 | + d->src_gray = Mat(d->image.numPixels(), 1, CV_8UC1); // Create a matrix containing the pixel values of grayscaled image | |
78 | +#endif | |
79 | ||
80 | if (d->imq.detectNoise) | |
81 | { | |
82 | @@ -655,7 +660,12 @@ | |
83 | int countblocks = 0; | |
84 | int number_of_blocks = 0; | |
85 | int sum = 0; | |
86 | + | |
87 | +#if OPENCV_TEST_VERSION(3,0,0) | |
88 | vector<int> average_bottom, average_middle, average_top; | |
89 | +#else | |
90 | + std::vector<int> average_bottom, average_middle, average_top; | |
91 | +#endif | |
92 | ||
93 | // Go through 8 blocks at a time horizontally | |
94 | // iterating through columns. | |
95 | @@ -792,7 +802,13 @@ | |
96 | int ImgQSort::exposureamount() const | |
97 | { | |
98 | /// Separate the image in 3 places ( B, G and R ) | |
99 | + | |
100 | +#if OPENCV_TEST_VERSION(3,0,0) | |
101 | vector<Mat> bgr_planes; | |
102 | +#else | |
103 | + std::vector<Mat> bgr_planes; | |
104 | +#endif | |
105 | + | |
106 | split(d->src, bgr_planes); | |
107 | ||
108 | /// Establish the number of bins | |
109 | diff -urN digikam-4.13.0/core/README digikam-4.13.0-opencv3/core/README | |
110 | --- digikam-4.13.0/core/README 2015-09-03 23:22:45.000000000 +0200 | |
111 | +++ digikam-4.13.0-opencv3/core/README 2016-03-22 17:06:26.155608182 +0100 | |
112 | @@ -122,6 +122,9 @@ | |
113 | Use CMake "-DENABLE_LCMS2=on" flag to compile digiKam source code using lcms2 instead lcms1 (disabled by default). | |
114 | Use CMake "-DENABLE_BALOOSUPPORT=on" flag to compile digiKam with Baloo support (disabled by default). | |
115 | Use CMake "-DENABLE_KDEPIMLIBSSUPPORT=on" flag to compile digiKam with KdePimLibs support (disabled by default). | |
116 | +Use CMake "-DENABLE_OPENCV3=on" flag to compile libkface source code using OpenCV3 instead OpenCV2 (disabled by default). | |
117 | + OpenCV3 support needs extra contrib modules package, especially 'face' | |
118 | + and 'legacy' components. | |
119 | ||
120 | Mysql support options (experimental): | |
121 | ||
122 | diff -urN digikam-4.13.0/extra/kipi-plugins/CMakeLists.txt digikam-4.13.0-opencv3/extra/kipi-plugins/CMakeLists.txt | |
123 | --- digikam-4.13.0/extra/kipi-plugins/CMakeLists.txt 2015-09-03 23:22:45.000000000 +0200 | |
124 | +++ digikam-4.13.0-opencv3/extra/kipi-plugins/CMakeLists.txt 2016-03-22 17:06:26.155608182 +0100 | |
125 | @@ -1,4 +1,3 @@ | |
126 | -cmake_minimum_required(VERSION 2.8.9) | |
127 | # | |
128 | # Copyright (c) 2010-2015, Gilles Caulier, <caulier dot gilles at gmail dot com> | |
129 | # | |
130 | @@ -11,16 +10,18 @@ | |
131 | message(STATUS "----------------------------------------------------------------------------------") | |
132 | message(STATUS "Starting CMake configuration for: kipi-plugins") | |
133 | ||
134 | +option(ENABLE_OPENCV3 "Build kipi-plugins with OpenCV3 instead OpenCV2 (default=OFF)" OFF) | |
135 | + | |
136 | # ======================================================= | |
137 | # Information to update before to release this package. | |
138 | ||
139 | # kipi-plugins version | |
140 | set(KIPIPLUGINS_MAJOR_VERSION "4") | |
141 | -set(KIPIPLUGINS_MINOR_VERSION "13") | |
142 | +set(KIPIPLUGINS_MINOR_VERSION "14") | |
143 | set(KIPIPLUGINS_PATCH_VERSION "0") | |
144 | ||
145 | # kipi-plugins release date | |
146 | -set(KIPIPLUGINS_RELEASE_DATE "2015-08-30") | |
147 | +set(KIPIPLUGINS_RELEASE_DATE "2015-09-27") | |
148 | ||
149 | # Suffix to add at end of version string. Usual values are: | |
150 | # "-git" : alpha code unstable from git. Do not use in production | |
151 | @@ -165,8 +166,14 @@ | |
152 | ||
153 | include(MacroUtils) | |
154 | include(MacroOpenCV) | |
155 | - set(OPENCV_MIN_VERSION "2.4.9") | |
156 | - DETECT_OPENCV(${OPENCV_MIN_VERSION} core highgui objdetect contrib legacy imgproc) | |
157 | + | |
158 | + if (ENABLE_OPENCV3) | |
159 | + set(OPENCV_MIN_VERSION "3.0.0") | |
160 | + DETECT_OPENCV(${OPENCV_MIN_VERSION} core face highgui objdetect imgproc) | |
161 | + else() | |
162 | + set(OPENCV_MIN_VERSION "2.4.9") | |
163 | + DETECT_OPENCV(${OPENCV_MIN_VERSION} core highgui objdetect contrib legacy imgproc) | |
164 | + endif() | |
165 | ||
166 | include(MacroOptionalDependPackage) | |
167 | ||
168 | diff -urN digikam-4.13.0/extra/kipi-plugins/README digikam-4.13.0-opencv3/extra/kipi-plugins/README | |
169 | --- digikam-4.13.0/extra/kipi-plugins/README 2015-09-03 23:22:45.000000000 +0200 | |
170 | +++ digikam-4.13.0-opencv3/extra/kipi-plugins/README 2016-03-22 17:06:26.155608182 +0100 | |
171 | @@ -140,6 +140,12 @@ | |
172 | ||
173 | -- INSTALL ------------------------------------------------------------ | |
174 | ||
175 | +CMake compilation options to custom digiKam: | |
176 | + | |
177 | +Use CMake "-DENABLE_OPENCV3=on" flag to compile kipi-plugins source code using OpenCV3 instead OpenCV2 (disabled by default). | |
178 | + OpenCV3 support needs extra contrib modules package, especially 'face' | |
179 | + and 'legacy' components. | |
180 | + | |
181 | In order to compile, especially when QT3/Qt4 are installed at the same time, | |
182 | just use something like that: | |
183 | ||
184 | diff -urN digikam-4.13.0/extra/kipi-plugins/removeredeyes/CMakeLists.txt digikam-4.13.0-opencv3/extra/kipi-plugins/removeredeyes/CMakeLists.txt | |
185 | --- digikam-4.13.0/extra/kipi-plugins/removeredeyes/CMakeLists.txt 2015-09-03 23:22:45.000000000 +0200 | |
186 | +++ digikam-4.13.0-opencv3/extra/kipi-plugins/removeredeyes/CMakeLists.txt 2016-03-22 17:06:26.155608182 +0100 | |
187 | @@ -1,5 +1,5 @@ | |
188 | # | |
189 | -# Copyright (c) 2010-2014, Gilles Caulier, <caulier dot gilles at gmail dot com> | |
190 | +# Copyright (c) 2010-2015, Gilles Caulier, <caulier dot gilles at gmail dot com> | |
191 | # | |
192 | # Redistribution and use is allowed according to the terms of the BSD license. | |
193 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. | |
194 | diff -urN digikam-4.13.0/extra/kipi-plugins/removeredeyes/detection/locators/haarclassifier/haarclassifierlocator.cpp digikam-4.13.0-opencv3/extra/kipi-plugins/removeredeyes/detection/locators/haarclassifier/haarclassifierlocator.cpp | |
195 | --- digikam-4.13.0/extra/kipi-plugins/removeredeyes/detection/locators/haarclassifier/haarclassifierlocator.cpp 2015-09-03 23:22:45.000000000 +0200 | |
196 | +++ digikam-4.13.0-opencv3/extra/kipi-plugins/removeredeyes/detection/locators/haarclassifier/haarclassifierlocator.cpp 2016-03-22 17:06:26.155608182 +0100 | |
197 | @@ -90,6 +90,15 @@ | |
198 | ||
199 | // -------------------------------------------------------- | |
200 | ||
201 | +#if !(OPENCV_TEST_VERSION(2,5,0)) | |
202 | + | |
203 | +static void cvFillImage(CvArr* const mat, double color) | |
204 | +{ | |
205 | + cvSet(mat, cvColorToScalar(color, cvGetElemType(mat)), 0); | |
206 | +} | |
207 | + | |
208 | +#endif | |
209 | + | |
210 | int HaarClassifierLocator::findPossibleEyes(double csf, int ngf, const char* classifierFile) | |
211 | { | |
212 | // eyes sequence will reside in the storage | |
213 | diff -urN digikam-4.13.0/extra/kipi-plugins/removeredeyes/plugin/libopencv.h digikam-4.13.0-opencv3/extra/kipi-plugins/removeredeyes/plugin/libopencv.h | |
214 | --- digikam-4.13.0/extra/kipi-plugins/removeredeyes/plugin/libopencv.h 2015-09-03 23:22:45.000000000 +0200 | |
215 | +++ digikam-4.13.0-opencv3/extra/kipi-plugins/removeredeyes/plugin/libopencv.h 2016-03-22 17:06:26.155608182 +0100 | |
216 | @@ -7,7 +7,7 @@ | |
217 | * @date 2010-06-16 | |
218 | * @brief Wrapper for OpenCV header files | |
219 | * | |
220 | - * @author Copyright (C) 2012-2014 by Gilles Caulier | |
221 | + * @author Copyright (C) 2012-2015 by Gilles Caulier | |
222 | * <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a> | |
223 | * | |
224 | * This program is free software; you can redistribute it | |
225 | @@ -53,12 +53,13 @@ | |
226 | ||
227 | #define OPENCV_MAKE_VERSION(major,minor,patch) (((major) << 16) | ((minor) << 8) | (patch)) | |
228 | #define OPENCV_VERSION OPENCV_MAKE_VERSION(CV_MAJOR_VERSION,CV_MINOR_VERSION,CV_SUBMINOR_VERSION) | |
229 | -#define OPENCV_TEST_VERSION(major,minor,patch) ( OPENCV_VERSION >= OPENCV_MAKE_VERSION(major,minor,patch) ) | |
230 | +#define OPENCV_TEST_VERSION(major,minor,patch) ( OPENCV_VERSION < OPENCV_MAKE_VERSION(major,minor,patch) ) | |
231 | ||
232 | -#if OPENCV_TEST_VERSION(2,3,0) | |
233 | +#include <opencv2/core/core_c.h> | |
234 | + | |
235 | +#if OPENCV_TEST_VERSION(2,5,0) | |
236 | #include <opencv2/opencv.hpp> | |
237 | #include <opencv2/highgui/highgui_c.h> | |
238 | -#include <opencv2/core/core_c.h> | |
239 | #include <opencv2/legacy/compat.hpp> | |
240 | #include <opencv/cvaux.h> | |
241 | #else | |
242 | diff -urN digikam-4.13.0/extra/kipi-plugins/removeredeyes/test/CMakeLists.txt digikam-4.13.0-opencv3/extra/kipi-plugins/removeredeyes/test/CMakeLists.txt | |
243 | --- digikam-4.13.0/extra/kipi-plugins/removeredeyes/test/CMakeLists.txt 2015-09-03 23:22:45.000000000 +0200 | |
244 | +++ digikam-4.13.0-opencv3/extra/kipi-plugins/removeredeyes/test/CMakeLists.txt 2016-03-22 17:06:26.155608182 +0100 | |
245 | @@ -1,10 +1,10 @@ | |
246 | # | |
247 | -# Copyright (c) 2010-2014, Gilles Caulier, <caulier dot gilles at gmail dot com> | |
248 | +# Copyright (c) 2010-2015, Gilles Caulier, <caulier dot gilles at gmail dot com> | |
249 | # | |
250 | # Redistribution and use is allowed according to the terms of the BSD license. | |
251 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. | |
252 | ||
253 | -if(NOT WIN32) | |
254 | +if(NOT WIN32 AND (${OpenCV_VERSION} VERSION_LESS 3.0.0)) | |
255 | ||
256 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../plugin | |
257 | ${CMAKE_CURRENT_SOURCE_DIR}/../libcvblobs | |
258 | diff -urN digikam-4.13.0/extra/libkface/CMakeLists.txt digikam-4.13.0-opencv3/extra/libkface/CMakeLists.txt | |
259 | --- digikam-4.13.0/extra/libkface/CMakeLists.txt 2015-09-03 23:22:44.000000000 +0200 | |
260 | +++ digikam-4.13.0-opencv3/extra/libkface/CMakeLists.txt 2016-03-22 17:06:26.155608182 +0100 | |
261 | @@ -10,6 +10,8 @@ | |
262 | message(STATUS "----------------------------------------------------------------------------------") | |
263 | message(STATUS "Starting CMake configuration for: libkface") | |
264 | ||
265 | +option(ENABLE_OPENCV3 "Build libkface with OpenCV3 instead OpenCV2 (default=OFF)" OFF) | |
266 | + | |
267 | find_package(Qt4 4.6.0 REQUIRED) | |
268 | find_package(KDE4 REQUIRED) | |
269 | ||
270 | @@ -30,7 +32,12 @@ | |
271 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) | |
272 | ||
273 | include(MacroOpenCV) | |
274 | -DETECT_OPENCV(2.4.9 core highgui objdetect contrib legacy imgproc) | |
275 | + | |
276 | +if (ENABLE_OPENCV3) | |
277 | + DETECT_OPENCV(3.0.0 core face highgui objdetect imgproc) | |
278 | +else() | |
279 | + DETECT_OPENCV(2.4.9 core highgui objdetect contrib legacy imgproc) | |
280 | +endif() | |
281 | ||
282 | include_directories(${OpenCV_INCLUDE_DIRS}) | |
283 | ||
284 | diff -urN digikam-4.13.0/extra/libkface/libkface/CMakeLists.txt digikam-4.13.0-opencv3/extra/libkface/libkface/CMakeLists.txt | |
285 | --- digikam-4.13.0/extra/libkface/libkface/CMakeLists.txt 2015-09-03 23:22:44.000000000 +0200 | |
286 | +++ digikam-4.13.0-opencv3/extra/libkface/libkface/CMakeLists.txt 2016-03-22 17:06:26.155608182 +0100 | |
287 | @@ -1,5 +1,5 @@ | |
288 | # | |
289 | -# Copyright (c) 2010-2014, Gilles Caulier, <caulier dot gilles at gmail dot com> | |
290 | +# Copyright (c) 2010-2015, Gilles Caulier, <caulier dot gilles at gmail dot com> | |
291 | # | |
292 | # Redistribution and use is allowed according to the terms of the BSD license. | |
293 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file. | |
294 | diff -urN digikam-4.13.0/extra/libkface/libkface/detection/opencvfacedetector.cpp digikam-4.13.0-opencv3/extra/libkface/libkface/detection/opencvfacedetector.cpp | |
295 | --- digikam-4.13.0/extra/libkface/libkface/detection/opencvfacedetector.cpp 2015-09-03 23:22:44.000000000 +0200 | |
296 | +++ digikam-4.13.0-opencv3/extra/libkface/libkface/detection/opencvfacedetector.cpp 2016-03-22 17:06:26.155608182 +0100 | |
297 | @@ -18,7 +18,7 @@ | |
298 | * <a href="alexjironkin at gmail dot com">alexjironkin at gmail dot com</a> | |
299 | * @author Copyright (C) 2010 by Aditya Bhatt | |
300 | * <a href="adityabhatt at gmail dot com">adityabhatt at gmail dot com</a> | |
301 | - * @author Copyright (C) 2010-2014 by Gilles Caulier | |
302 | + * @author Copyright (C) 2010-2015 by Gilles Caulier | |
303 | * <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a> | |
304 | * @author Copyright (C) 2010-2013 by Marcel Wiesweg | |
305 | * <a href="mailto:marcel dot wiesweg at gmx dot de">marcel dot wiesweg at gmx dot de</a> | |
306 | @@ -136,13 +136,14 @@ | |
307 | ||
308 | cv::Size getOriginalWindowSize() const | |
309 | { | |
310 | +#if OPENCV_VERSION <= OPENCV_MAKE_VERSION(2,4,11) | |
311 | // This is a HACK which may break any time. Work around the fact that getOriginalWindowSize() | |
312 | // always returns (0,0) and we need these values. | |
313 | if (oldCascade) | |
314 | { | |
315 | return oldCascade->orig_window_size; | |
316 | } | |
317 | - | |
318 | +#endif | |
319 | return cv::Size(0, 0); | |
320 | } | |
321 | ||
322 | diff -urN digikam-4.13.0/extra/libkface/libkface/libopencv.h.cmake.in digikam-4.13.0-opencv3/extra/libkface/libkface/libopencv.h.cmake.in | |
323 | --- digikam-4.13.0/extra/libkface/libkface/libopencv.h.cmake.in 2015-09-03 23:22:44.000000000 +0200 | |
324 | +++ digikam-4.13.0-opencv3/extra/libkface/libkface/libopencv.h.cmake.in 2016-03-22 17:06:26.155608182 +0100 | |
325 | @@ -7,7 +7,7 @@ | |
326 | * @date 2010-06-16 | |
327 | * @brief Wrapper for OpenCV header files | |
328 | * | |
329 | - * @author Copyright (C) 2012-2014 by Gilles Caulier | |
330 | + * @author Copyright (C) 2012-2015 by Gilles Caulier | |
331 | * <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a> | |
332 | * | |
333 | * This program is free software; you can redistribute it | |
334 | @@ -31,16 +31,16 @@ | |
335 | ||
336 | // Pragma directives to reduce warnings from OpenCV header files. | |
337 | #if not defined(__APPLE__) && defined(__GNUC__) | |
338 | -#pragma GCC diagnostic push | |
339 | -#pragma GCC diagnostic ignored "-Wnon-virtual-dtor" | |
340 | -#pragma GCC diagnostic ignored "-Woverloaded-virtual" | |
341 | +# pragma GCC diagnostic push | |
342 | +# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" | |
343 | +# pragma GCC diagnostic ignored "-Woverloaded-virtual" | |
344 | #endif | |
345 | ||
346 | #if defined(__APPLE__) && defined(__clang__) | |
347 | -#pragma clang diagnostic push | |
348 | -#pragma clang diagnostic ignored "-Wnon-virtual-dtor" | |
349 | -#pragma clang diagnostic ignored "-Woverloaded-virtual" | |
350 | -#pragma clang diagnostic ignored "-Wcast-align" | |
351 | +# pragma clang diagnostic push | |
352 | +# pragma clang diagnostic ignored "-Wnon-virtual-dtor" | |
353 | +# pragma clang diagnostic ignored "-Woverloaded-virtual" | |
354 | +# pragma clang diagnostic ignored "-Wcast-align" | |
355 | #endif | |
356 | ||
357 | // OpenCV includes | |
358 | @@ -51,23 +51,30 @@ | |
359 | #define OPENCV_VERSION OPENCV_MAKE_VERSION(CV_MAJOR_VERSION,CV_MINOR_VERSION,CV_SUBMINOR_VERSION) | |
360 | #define OPENCV_TEST_VERSION(major,minor,patch) ( OPENCV_VERSION >= OPENCV_MAKE_VERSION(major,minor,patch) ) | |
361 | ||
362 | -#include <opencv2/core/core.hpp> | |
363 | -#include <opencv2/core/internal.hpp> | |
364 | -#include <opencv2/contrib/contrib.hpp> | |
365 | +#if OPENCV_TEST_VERSION(3,0,0) | |
366 | +# include <opencv2/face.hpp> | |
367 | +# include <opencv2/core.hpp> | |
368 | +#else | |
369 | +# include <opencv2/core/core.hpp> | |
370 | +# include <opencv2/core/internal.hpp> | |
371 | +# include <opencv2/contrib/extra/libkface/contrib.hpp> | |
372 | +#endif | |
373 | ||
374 | // for old-style code | |
375 | +#if OPENCV_VERSION <= OPENCV_MAKE_VERSION(2,4,11) | |
376 | +# include <opencv2/legacy/compat.hpp> | |
377 | +#endif | |
378 | #include <opencv2/opencv.hpp> | |
379 | -#include <opencv2/legacy/compat.hpp> | |
380 | #include <opencv2/highgui/highgui_c.h> | |
381 | #include <opencv/cvaux.h> | |
382 | ||
383 | // Restore warnings | |
384 | #if not defined(__APPLE__) && defined(__GNUC__) | |
385 | -#pragma GCC diagnostic pop | |
386 | +# pragma GCC diagnostic pop | |
387 | #endif | |
388 | ||
389 | #if defined(__APPLE__) && defined(__clang__) | |
390 | -#pragma clang diagnostic pop | |
391 | +# pragma clang diagnostic pop | |
392 | #endif | |
393 | ||
394 | #endif // LIB_OPEN_CV_H | |
395 | diff -urN digikam-4.13.0/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.cpp digikam-4.13.0-opencv3/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.cpp | |
396 | --- digikam-4.13.0/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.cpp 2015-09-03 23:22:44.000000000 +0200 | |
397 | +++ digikam-4.13.0-opencv3/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.cpp 2016-03-22 17:06:39.782444479 +0100 | |
398 | @@ -36,6 +36,8 @@ | |
399 | * | |
400 | * ============================================================ */ | |
401 | ||
402 | +#define QT_NO_EMIT | |
403 | + | |
404 | #include "facerec_borrowed.h" | |
405 | ||
406 | // C++ includes | |
407 | @@ -375,7 +377,11 @@ | |
408 | } | |
409 | } | |
410 | ||
411 | +#if !OPENCV_TEST_VERSION(3,1,0) | |
412 | void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist) const | |
413 | +#else | |
414 | +void LBPHFaceRecognizer::predict(cv::InputArray _src, cv::Ptr<cv::face::PredictCollector> collector, const int state) const | |
415 | +#endif | |
416 | { | |
417 | if(m_histograms.empty()) | |
418 | { | |
419 | @@ -394,8 +400,12 @@ | |
420 | m_grid_y, /* grid size y */ | |
421 | true /* normed histograms */ | |
422 | ); | |
423 | +#if !OPENCV_TEST_VERSION(3,1,0) | |
424 | minDist = DBL_MAX; | |
425 | minClass = -1; | |
426 | +#else | |
427 | + collector->init((int)m_histograms.size(), state); | |
428 | +#endif | |
429 | ||
430 | // This is the standard method | |
431 | ||
432 | @@ -406,11 +416,19 @@ | |
433 | { | |
434 | double dist = compareHist(m_histograms[sampleIdx], query, CV_COMP_CHISQR); | |
435 | ||
436 | +#if !OPENCV_TEST_VERSION(3,1,0) | |
437 | if((dist < minDist) && (dist < m_threshold)) | |
438 | { | |
439 | minDist = dist; | |
440 | minClass = m_labels.at<int>((int) sampleIdx); | |
441 | } | |
442 | +#else | |
443 | + int label = m_labels.at<int>((int) sampleIdx); | |
444 | + if (!collector->emit(label, dist, state)) | |
445 | + { | |
446 | + return; | |
447 | + } | |
448 | +#endif | |
449 | } | |
450 | } | |
451 | ||
452 | @@ -422,7 +440,7 @@ | |
453 | // Create map "label -> vector of distances to all histograms for this label" | |
454 | std::map<int, std::vector<int> > distancesMap; | |
455 | ||
456 | - for(size_t sampleIdx = 0; sampleIdx < m_histograms.size(); sampleIdx++) | |
457 | + for(size_t sampleIdx = 0; sampleIdx < m_histograms.size(); sampleIdx++) | |
458 | { | |
459 | double dist = compareHist(m_histograms[sampleIdx], query, CV_COMP_CHISQR); | |
460 | std::vector<int>& distances = distancesMap[m_labels.at<int>((int) sampleIdx)]; | |
461 | @@ -445,11 +463,18 @@ | |
462 | double mean = sum / it->second.size(); | |
463 | s += QString("%1: %2 - ").arg(it->first).arg(mean); | |
464 | ||
465 | +#if !OPENCV_TEST_VERSION(3,1,0) | |
466 | if((mean < minDist) && (mean < m_threshold)) | |
467 | { | |
468 | minDist = mean; | |
469 | minClass = it->first; | |
470 | } | |
471 | +#else | |
472 | + if (!collector->emit(it->first, mean, state)) | |
473 | + { | |
474 | + return; | |
475 | + } | |
476 | +#endif | |
477 | } | |
478 | ||
479 | kDebug() << s; | |
480 | @@ -462,7 +487,7 @@ | |
481 | // map "label -> number of histograms" | |
482 | std::map<int, int> countMap; | |
483 | ||
484 | - for(size_t sampleIdx = 0; sampleIdx < m_histograms.size(); sampleIdx++) | |
485 | + for(size_t sampleIdx = 0; sampleIdx < m_histograms.size(); sampleIdx++) | |
486 | { | |
487 | int label = m_labels.at<int>((int) sampleIdx); | |
488 | double dist = compareHist(m_histograms[sampleIdx], query, CV_COMP_CHISQR); | |
489 | @@ -480,7 +505,9 @@ | |
490 | scoreMap[it->second]++; | |
491 | } | |
492 | ||
493 | +#if !OPENCV_TEST_VERSION(3,1,0) | |
494 | minDist = 0; | |
495 | +#endif | |
496 | QString s("Nearest Neighbor score: "); | |
497 | ||
498 | for (std::map<int,int>::iterator it = scoreMap.begin(); it != scoreMap.end(); ++it) | |
499 | @@ -488,17 +515,26 @@ | |
500 | double score = double(it->second) / countMap.at(it->first); | |
501 | s += QString("%1/%2 %3 ").arg(it->second).arg(countMap.at(it->first)).arg(score); | |
502 | ||
503 | +#if !OPENCV_TEST_VERSION(3,1,0) | |
504 | if (score > minDist) | |
505 | { | |
506 | minDist = score; | |
507 | minClass = it->first; | |
508 | } | |
509 | +#else | |
510 | + // large is better thus it is -score. | |
511 | + if (!collector->emit(it->first, -score, state)) | |
512 | + { | |
513 | + return; | |
514 | + } | |
515 | +#endif | |
516 | } | |
517 | ||
518 | kDebug() << s; | |
519 | } | |
520 | } | |
521 | ||
522 | +#if !OPENCV_TEST_VERSION(3,1,0) | |
523 | int LBPHFaceRecognizer::predict(InputArray _src) const | |
524 | { | |
525 | int label; | |
526 | @@ -506,6 +542,7 @@ | |
527 | predict(_src, label, dummy); | |
528 | return label; | |
529 | } | |
530 | +#endif | |
531 | ||
532 | // Static method ---------------------------------------------------- | |
533 | ||
534 | @@ -531,14 +568,16 @@ | |
535 | return ptr; | |
536 | } | |
537 | ||
538 | -CV_INIT_ALGORITHM(LBPHFaceRecognizer, "FaceRecognizer.LBPH-KFaceIface", | |
539 | - obj.info()->addParam(obj, "radius", obj.m_radius); | |
540 | - obj.info()->addParam(obj, "neighbors", obj.m_neighbors); | |
541 | - obj.info()->addParam(obj, "grid_x", obj.m_grid_x); | |
542 | - obj.info()->addParam(obj, "grid_y", obj.m_grid_y); | |
543 | - obj.info()->addParam(obj, "threshold", obj.m_threshold); | |
544 | - obj.info()->addParam(obj, "histograms", obj.m_histograms); // modification: Make Read/Write | |
545 | - obj.info()->addParam(obj, "labels", obj.m_labels); // modification: Make Read/Write | |
546 | - obj.info()->addParam(obj, "statistic", obj.m_statisticsMode)); // modification: Add parameter | |
547 | +#if OPENCV_VERSION <= OPENCV_MAKE_VERSION(2,4,11) | |
548 | + CV_INIT_ALGORITHM(LBPHFaceRecognizer, "FaceRecognizer.LBPH-KFaceIface", | |
549 | + obj.info()->addParam(obj, "radius", obj.m_radius); | |
550 | + obj.info()->addParam(obj, "neighbors", obj.m_neighbors); | |
551 | + obj.info()->addParam(obj, "grid_x", obj.m_grid_x); | |
552 | + obj.info()->addParam(obj, "grid_y", obj.m_grid_y); | |
553 | + obj.info()->addParam(obj, "threshold", obj.m_threshold); | |
554 | + obj.info()->addParam(obj, "histograms", obj.m_histograms); // modification: Make Read/Write | |
555 | + obj.info()->addParam(obj, "labels", obj.m_labels); // modification: Make Read/Write | |
556 | + obj.info()->addParam(obj, "statistic", obj.m_statisticsMode)); // modification: Add parameter | |
557 | +#endif | |
558 | ||
559 | } // namespace KFaceIface | |
560 | diff -urN digikam-4.13.0/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.h digikam-4.13.0-opencv3/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.h | |
561 | --- digikam-4.13.0/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.h 2015-09-03 23:22:44.000000000 +0200 | |
562 | +++ digikam-4.13.0-opencv3/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.h 2016-03-22 17:06:39.782444479 +0100 | |
563 | @@ -45,7 +45,11 @@ | |
564 | namespace KFaceIface | |
565 | { | |
566 | ||
567 | +#if OPENCV_TEST_VERSION(3,0,0) | |
568 | +class LBPHFaceRecognizer : public cv::face::FaceRecognizer | |
569 | +#else | |
570 | class LBPHFaceRecognizer : public cv::FaceRecognizer | |
571 | +#endif | |
572 | { | |
573 | public: | |
574 | ||
575 | @@ -99,8 +103,13 @@ | |
576 | ||
577 | ~LBPHFaceRecognizer() {} | |
578 | ||
579 | +#if OPENCV_TEST_VERSION(3,0,0) | |
580 | + using cv::face::FaceRecognizer::save; | |
581 | + using cv::face::FaceRecognizer::load; | |
582 | +#else | |
583 | using cv::FaceRecognizer::save; | |
584 | using cv::FaceRecognizer::load; | |
585 | +#endif | |
586 | ||
587 | 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); | |
588 | ||
589 | @@ -116,6 +125,8 @@ | |
590 | */ | |
591 | void update(cv::InputArrayOfArrays src, cv::InputArray labels); | |
592 | ||
593 | + | |
594 | +#if !OPENCV_TEST_VERSION(3,1,0) | |
595 | /** | |
596 | * Predicts the label of a query image in src. | |
597 | */ | |
598 | @@ -125,6 +136,13 @@ | |
599 | * Predicts the label and confidence for a given sample. | |
600 | */ | |
601 | void predict(cv::InputArray _src, int &label, double &dist) const; | |
602 | +#else | |
603 | + using cv::face::FaceRecognizer::predict; | |
604 | + /* | |
605 | + * Predict | |
606 | + */ | |
607 | + void predict(cv::InputArray src, cv::Ptr<cv::face::PredictCollector> collector, const int state = 0) const override; | |
608 | +#endif | |
609 | ||
610 | /** | |
611 | * See FaceRecognizer::load(). | |
612 | @@ -139,6 +157,34 @@ | |
613 | /** | |
614 | * Getter functions. | |
615 | */ | |
616 | +#if OPENCV_TEST_VERSION(3,0,0) | |
617 | + | |
618 | + int getNeighbors() const { return m_neighbors; } | |
619 | + void setNeighbors(int _neighbors) { m_neighbors = _neighbors; } | |
620 | + | |
621 | + int getRadius() const { return m_radius; } | |
622 | + void setRadius(int radius) { m_radius = radius; } | |
623 | + | |
624 | + int getGrid_x() const { return m_grid_x; } | |
625 | + void setGrid_x(int _grid_x) { m_grid_x = _grid_x; } | |
626 | + | |
627 | + int getGrid_y() const { return m_grid_y; } | |
628 | + void setGrid_y(int _grid_y) { m_grid_y = _grid_y; } | |
629 | + | |
630 | + double getThreshold() const { return m_threshold; } | |
631 | + void setThreshold(double _threshold) { m_threshold = _threshold; } | |
632 | + | |
633 | + void setHistograms(std::vector<cv::Mat> _histograms) { m_histograms = _histograms; } | |
634 | + std::vector<cv::Mat> getHistograms() const { return m_histograms; } | |
635 | + | |
636 | + void setLabels(cv::Mat _labels) { m_labels = _labels; } | |
637 | + cv::Mat getLabels() const { return m_labels; } | |
638 | + | |
639 | + void setStatistic(int _statistic) { m_statisticsMode = _statistic; } | |
640 | + int getStatistic() const { return m_statisticsMode; } | |
641 | + | |
642 | +#else | |
643 | + | |
644 | int neighbors() const { return m_neighbors; } | |
645 | int radius() const { return m_radius; } | |
646 | int grid_x() const { return m_grid_x; } | |
647 | @@ -147,6 +193,8 @@ | |
648 | // NOTE: Implementation done through CV_INIT_ALGORITHM macro from OpenCV. | |
649 | cv::AlgorithmInfo* info() const; | |
650 | ||
651 | +#endif | |
652 | + | |
653 | private: | |
654 | ||
655 | /** Computes a LBPH model with images in src and | |
656 | diff -urN digikam-4.13.0/extra/libkface/libkface/recognition-opencv-lbph/lbphfacemodel.cpp digikam-4.13.0-opencv3/extra/libkface/libkface/recognition-opencv-lbph/lbphfacemodel.cpp | |
657 | --- digikam-4.13.0/extra/libkface/libkface/recognition-opencv-lbph/lbphfacemodel.cpp 2015-09-03 23:22:44.000000000 +0200 | |
658 | +++ digikam-4.13.0-opencv3/extra/libkface/libkface/recognition-opencv-lbph/lbphfacemodel.cpp 2016-03-22 17:06:26.155608182 +0100 | |
659 | @@ -61,7 +61,11 @@ | |
660 | : cv::Ptr<LBPHFaceRecognizer>(LBPHFaceRecognizer::create()), | |
661 | databaseId(0) | |
662 | { | |
663 | +#if OPENCV_TEST_VERSION(3,0,0) | |
664 | + ptr()->setThreshold(100.0); | |
665 | +#else | |
666 | ptr()->set("threshold", 100.0); | |
667 | +#endif | |
668 | } | |
669 | ||
670 | LBPHFaceModel::~LBPHFaceModel() | |
671 | @@ -80,9 +84,13 @@ | |
672 | ||
673 | const LBPHFaceRecognizer* LBPHFaceModel::ptr() const | |
674 | { | |
675 | +#if OPENCV_TEST_VERSION(3,0,0) | |
676 | + const LBPHFaceRecognizer* const ptr = cv::Ptr<LBPHFaceRecognizer>::operator KFaceIface::LBPHFaceRecognizer*(); | |
677 | +#else | |
678 | const LBPHFaceRecognizer* const ptr = cv::Ptr<LBPHFaceRecognizer>::operator const KFaceIface::LBPHFaceRecognizer*(); | |
679 | +#endif | |
680 | ||
681 | - if (!ptr) | |
682 | + if (!ptr) | |
683 | kWarning() << "LBPHFaceRecognizer pointer is null"; | |
684 | ||
685 | return ptr; | |
686 | @@ -90,47 +98,83 @@ | |
687 | ||
688 | int LBPHFaceModel::radius() const | |
689 | { | |
690 | +#if OPENCV_TEST_VERSION(3,0,0) | |
691 | + return ptr()->getRadius(); | |
692 | +#else | |
693 | return ptr()->get<int>("radius"); | |
694 | +#endif | |
695 | } | |
696 | ||
697 | void LBPHFaceModel::setRadius(int radius) | |
698 | { | |
699 | +#if OPENCV_TEST_VERSION(3,0,0) | |
700 | + ptr()->setRadius(radius); | |
701 | +#else | |
702 | ptr()->set("radius", radius); | |
703 | +#endif | |
704 | } | |
705 | ||
706 | int LBPHFaceModel::neighbors() const | |
707 | { | |
708 | +#if OPENCV_TEST_VERSION(3,0,0) | |
709 | + return ptr()->getNeighbors(); | |
710 | +#else | |
711 | return ptr()->get<int>("neighbors"); | |
712 | +#endif | |
713 | } | |
714 | ||
715 | void LBPHFaceModel::setNeighbors(int neighbors) | |
716 | { | |
717 | +#if OPENCV_TEST_VERSION(3,0,0) | |
718 | + ptr()->setNeighbors(neighbors); | |
719 | +#else | |
720 | ptr()->set("neighbors", neighbors); | |
721 | +#endif | |
722 | } | |
723 | ||
724 | int LBPHFaceModel::gridX() const | |
725 | { | |
726 | +#if OPENCV_TEST_VERSION(3,0,0) | |
727 | + return ptr()->getGrid_x(); | |
728 | +#else | |
729 | return ptr()->get<int>("grid_x"); | |
730 | +#endif | |
731 | } | |
732 | ||
733 | void LBPHFaceModel::setGridX(int grid_x) | |
734 | { | |
735 | +#if OPENCV_TEST_VERSION(3,0,0) | |
736 | + ptr()->setGrid_x(grid_x); | |
737 | +#else | |
738 | ptr()->set("grid_x", grid_x); | |
739 | +#endif | |
740 | } | |
741 | ||
742 | int LBPHFaceModel::gridY() const | |
743 | { | |
744 | +#if OPENCV_TEST_VERSION(3,0,0) | |
745 | + return ptr()->getGrid_y(); | |
746 | +#else | |
747 | return ptr()->get<int>("grid_y"); | |
748 | +#endif | |
749 | } | |
750 | ||
751 | void LBPHFaceModel::setGridY(int grid_y) | |
752 | { | |
753 | +#if OPENCV_TEST_VERSION(3,0,0) | |
754 | + ptr()->setGrid_y(grid_y); | |
755 | +#else | |
756 | ptr()->set("grid_y", grid_y); | |
757 | +#endif | |
758 | } | |
759 | ||
760 | OpenCVMatData LBPHFaceModel::histogramData(int index) const | |
761 | { | |
762 | +#if OPENCV_TEST_VERSION(3,0,0) | |
763 | + return OpenCVMatData(ptr()->getHistograms().at(index)); | |
764 | +#else | |
765 | return OpenCVMatData(ptr()->get<std::vector<cv::Mat> >("histograms").at(index)); | |
766 | +#endif | |
767 | } | |
768 | ||
769 | QList<LBPHistogramMetadata> LBPHFaceModel::histogramMetadata() const | |
770 | @@ -168,12 +212,24 @@ | |
771 | m_histogramMetadata << metadata; | |
772 | } | |
773 | ||
774 | +#if OPENCV_TEST_VERSION(3,0,0) | |
775 | + std::vector<cv::Mat> currentHistograms = ptr()->getHistograms(); | |
776 | + cv::Mat currentLabels = ptr()->getLabels(); | |
777 | +#else | |
778 | std::vector<cv::Mat> currentHistograms = ptr()->get<std::vector<cv::Mat> >("histograms"); | |
779 | cv::Mat currentLabels = ptr()->get<cv::Mat>("labels"); | |
780 | +#endif | |
781 | + | |
782 | currentHistograms.insert(currentHistograms.end(), newHistograms.begin(), newHistograms.end()); | |
783 | currentLabels.push_back(newLabels); | |
784 | + | |
785 | +#if OPENCV_TEST_VERSION(3,0,0) | |
786 | + ptr()->setHistograms(currentHistograms); | |
787 | + ptr()->setLabels(currentLabels); | |
788 | +#else | |
789 | ptr()->set("histograms", currentHistograms); | |
790 | - ptr()->set("labels", currentLabels); | |
791 | + ptr()->set("labels", currentLabels); | |
792 | +#endif | |
793 | ||
794 | /* | |
795 | //Most cumbersome and inefficient way through a file storage which we were forced to use if we used standard OpenCV | |
796 | @@ -215,7 +271,11 @@ | |
797 | ||
798 | // Update local information | |
799 | // We assume new labels are simply appended | |
800 | +#if OPENCV_TEST_VERSION(3,0,0) | |
801 | + cv::Mat currentLabels = ptr()->getLabels(); | |
802 | +#else | |
803 | cv::Mat currentLabels = ptr()->get<cv::Mat>("labels"); | |
804 | +#endif | |
805 | ||
806 | for (int i = m_histogramMetadata.size() ; i < currentLabels.rows ; i++) | |
807 | { | |
808 | diff -urN digikam-4.13.0/extra/libkface/README digikam-4.13.0-opencv3/extra/libkface/README | |
809 | --- digikam-4.13.0/extra/libkface/README 2015-09-03 23:22:44.000000000 +0200 | |
810 | +++ digikam-4.13.0-opencv3/extra/libkface/README 2016-03-22 17:06:26.155608182 +0100 | |
811 | @@ -21,6 +21,11 @@ | |
812 | libkde >= 4.4.x http://www.kde.org | |
813 | libopencv >= 2.4.9 http://opencv.willowgarage.com/wiki (with opencv 'haarcascades' data files) | |
814 | ||
815 | +CMake compilation options to custom libkface: | |
816 | + | |
817 | +Use CMake "-DENABLE_OPENCV3=on" flag to compile libkface source code using OpenCV3 instead OpenCV2 (disabled by default). | |
818 | + OpenCV3 support needs extra contrib modules package, especially 'face' ands 'legacy' components. | |
819 | + | |
820 | -- INSTALL ------------------------------------------------------------ | |
821 | ||
822 | In order to compile, especially when QT3/Qt4 are installed at the same time, |