Accepting request 365844 from KDE:Extra
This is the update for digikam to make it build with the newer openCV 3.1. This should be in the same staging area as OpenCV !! OBS-URL: https://build.opensuse.org/request/show/365844 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/digikam?expand=0&rev=146
This commit is contained in:
commit
13f4238d6c
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Mar 3 13:45:53 UTC 2016 - tittiatcoke@gmail.com
|
||||
|
||||
- Add fix_opencv3.patch in order to build the internal libkface
|
||||
with openCV 3.x
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Wed Feb 17 10:17:03 UTC 2016 - tittiatcoke@gmail.com
|
||||
|
||||
|
@ -33,6 +33,8 @@ Patch0: digikam-buildtime.patch
|
||||
Patch3: remove-gplv2-only.patch
|
||||
# PATCH-FIX-UPSTREAM digikam-4.4.0.no-kdcraw.version-check.patch -- version check for libkdcraw currently broken
|
||||
Patch6: digikam-4.4.0.no-kdcraw.version-check.patch
|
||||
# PATCH-FIX-OPENSUSE fix_opencv3.patch -- Fix the internal libkface to work with openCV version 3.0. This is based on upstream changes
|
||||
Patch100: fix_opencv3.patch
|
||||
BuildRequires: ImageMagick-devel
|
||||
BuildRequires: bison
|
||||
BuildRequires: boost-devel
|
||||
@ -224,7 +226,6 @@ Requires: digikam-libs
|
||||
Requires: kipi-plugin-icons
|
||||
%endif
|
||||
|
||||
|
||||
%description -n kipi-plugins
|
||||
A set of plug-ins for the KDE KIPI interface, used by some KDE imaging
|
||||
applications.
|
||||
@ -266,6 +267,7 @@ required for digikam to run. Upstream these libraries have moved to KF5, but dig
|
||||
%patch0
|
||||
%patch3
|
||||
%patch6 -p1
|
||||
%patch100 -p1
|
||||
|
||||
# Remove build time references so build-compare can do its work
|
||||
FAKE_BUILDDATE=$(LC_ALL=C date -u -r %{_sourcedir}/%{name}.changes '+%%b %%e %%Y')
|
||||
@ -289,7 +291,7 @@ EXTRA_FLAGS+=" -DDIGIKAMSC_COMPILE_LIBKIPI=ON -DDIGIKAMSC_COMPILE_LIBKEXIV2=ON -
|
||||
EXTRA_FLAGS+=" -DDIGIKAMSC_COMPILE_LIBKSANE=ON -DDIGIKAMSC_COMPILE_LIBKFACE=ON"
|
||||
EXTRA_FLAGS+=" -DDIGIKAMSC_COMPILE_LIBKGEOMAP=ON -DDIGIKAMSC_COMPILE_LIBMEDIAWIKI=ON"
|
||||
%endif
|
||||
%cmake_kde4 -d build -- -DENABLE_MYSQLSUPPORT=TRUE -DENABLE_INTERNALMYSQL=FALSE -DENABLE_KDEPIMLIBSSUPPORT=TRUE $EXTRA_FLAGS
|
||||
%cmake_kde4 -d build -- -DENABLE_OPENCV3=ON -DENABLE_MYSQLSUPPORT=TRUE -DENABLE_INTERNALMYSQL=FALSE -DENABLE_KDEPIMLIBSSUPPORT=TRUE $EXTRA_FLAGS
|
||||
|
||||
# there are files in there that are so heavy to the compiler, that one is enough
|
||||
%make_jobs VERBOSE=1
|
||||
|
541
fix_opencv3.patch
Normal file
541
fix_opencv3.patch
Normal file
@ -0,0 +1,541 @@
|
||||
diff -urNB a/extra/libkface/CMakeLists.txt b/extra/libkface/CMakeLists.txt
|
||||
--- a/extra/libkface/CMakeLists.txt 2015-09-03 23:22:44.000000000 +0200
|
||||
+++ b/extra/libkface/CMakeLists.txt 2016-03-04 07:53:19.390177947 +0100
|
||||
@@ -29,8 +29,33 @@
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
||||
|
||||
+# OpenCV detection
|
||||
include(MacroOpenCV)
|
||||
-DETECT_OPENCV(2.4.9 core highgui objdetect contrib legacy imgproc)
|
||||
+
|
||||
+if(ENABLE_OPENCV3)
|
||||
+
|
||||
+ set(OPENCV_MIN_VERSION "3.0.0")
|
||||
+ DETECT_OPENCV(${OPENCV_MIN_VERSION} core face highgui objdetect imgproc)
|
||||
+
|
||||
+ if(${OpenCV_FOUND})
|
||||
+ if(${OpenCV_VERSION} VERSION_LESS 3.0.0)
|
||||
+ message(STATUS "ENABLE_OPENCV3 option is enabled and OpenCV < 3.0.0 have been found. Disabled ENABLE_OPENCV3")
|
||||
+ set(OpenCV_FOUND FALSE)
|
||||
+ endif()
|
||||
+ endif()
|
||||
+
|
||||
+else()
|
||||
+ set(OPENCV_MIN_VERSION "2.4.9")
|
||||
+ DETECT_OPENCV(${OPENCV_MIN_VERSION} core highgui objdetect contrib legacy imgproc)
|
||||
+
|
||||
+ if(${OpenCV_FOUND})
|
||||
+ if(${OpenCV_VERSION} VERSION_GREATER 2.4.99)
|
||||
+ message(STATUS "ENABLE_OPENCV3 option is disabled and OpenCV >= 3.0.0 have been found. Enabled ENABLE_OPENCV3")
|
||||
+ set(OpenCV_FOUND FALSE)
|
||||
+ endif()
|
||||
+ endif()
|
||||
+
|
||||
+endif()
|
||||
|
||||
include_directories(${OpenCV_INCLUDE_DIRS})
|
||||
|
||||
diff -urNB a/extra/libkface/libkface/CMakeLists.txt b/extra/libkface/libkface/CMakeLists.txt
|
||||
--- a/extra/libkface/libkface/CMakeLists.txt 2015-09-03 23:22:44.000000000 +0200
|
||||
+++ b/extra/libkface/libkface/CMakeLists.txt 2016-03-04 08:17:38.604392033 +0100
|
||||
@@ -1,5 +1,5 @@
|
||||
#
|
||||
-# Copyright (c) 2010-2014, Gilles Caulier, <caulier dot gilles at gmail dot com>
|
||||
+# Copyright (c) 2010-2015, Gilles Caulier, <caulier dot gilles at gmail dot com>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
diff -urNB a/extra/libkface/libkface/detection/opencvfacedetector.cpp b/extra/libkface/libkface/detection/opencvfacedetector.cpp
|
||||
--- a/extra/libkface/libkface/detection/opencvfacedetector.cpp 2015-09-03 23:22:44.000000000 +0200
|
||||
+++ b/extra/libkface/libkface/detection/opencvfacedetector.cpp 2016-03-04 09:00:03.837203004 +0100
|
||||
@@ -136,13 +136,14 @@
|
||||
|
||||
cv::Size getOriginalWindowSize() const
|
||||
{
|
||||
+#if OPENCV_VERSION <= OPENCV_MAKE_VERSION(2,4,99)
|
||||
// This is a HACK which may break any time. Work around the fact that getOriginalWindowSize()
|
||||
// always returns (0,0) and we need these values.
|
||||
if (oldCascade)
|
||||
{
|
||||
return oldCascade->orig_window_size;
|
||||
}
|
||||
-
|
||||
+#endif
|
||||
return cv::Size(0, 0);
|
||||
}
|
||||
|
||||
diff -urNB a/extra/libkface/libkface/libopencv.h.cmake.in b/extra/libkface/libkface/libopencv.h.cmake.in
|
||||
--- a/extra/libkface/libkface/libopencv.h.cmake.in 2015-09-03 23:22:44.000000000 +0200
|
||||
+++ b/extra/libkface/libkface/libopencv.h.cmake.in 2016-03-04 08:17:46.260398775 +0100
|
||||
@@ -7,7 +7,7 @@
|
||||
* @date 2010-06-16
|
||||
* @brief Wrapper for OpenCV header files
|
||||
*
|
||||
- * @author Copyright (C) 2012-2014 by Gilles Caulier
|
||||
+ * @author Copyright (C) 2012-2015 by Gilles Caulier
|
||||
* <a href="mailto:caulier dot gilles at gmail dot com">caulier dot gilles at gmail dot com</a>
|
||||
*
|
||||
* This program is free software; you can redistribute it
|
||||
@@ -31,16 +31,16 @@
|
||||
|
||||
// Pragma directives to reduce warnings from OpenCV header files.
|
||||
#if not defined(__APPLE__) && defined(__GNUC__)
|
||||
-#pragma GCC diagnostic push
|
||||
-#pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
-#pragma GCC diagnostic ignored "-Woverloaded-virtual"
|
||||
+# pragma GCC diagnostic push
|
||||
+# pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
|
||||
+# pragma GCC diagnostic ignored "-Woverloaded-virtual"
|
||||
#endif
|
||||
|
||||
#if defined(__APPLE__) && defined(__clang__)
|
||||
-#pragma clang diagnostic push
|
||||
-#pragma clang diagnostic ignored "-Wnon-virtual-dtor"
|
||||
-#pragma clang diagnostic ignored "-Woverloaded-virtual"
|
||||
-#pragma clang diagnostic ignored "-Wcast-align"
|
||||
+# pragma clang diagnostic push
|
||||
+# pragma clang diagnostic ignored "-Wnon-virtual-dtor"
|
||||
+# pragma clang diagnostic ignored "-Woverloaded-virtual"
|
||||
+# pragma clang diagnostic ignored "-Wcast-align"
|
||||
#endif
|
||||
|
||||
// OpenCV includes
|
||||
@@ -49,15 +49,22 @@
|
||||
|
||||
#define OPENCV_MAKE_VERSION(major,minor,patch) (((major) << 16) | ((minor) << 8) | (patch))
|
||||
#define OPENCV_VERSION OPENCV_MAKE_VERSION(CV_MAJOR_VERSION,CV_MINOR_VERSION,CV_SUBMINOR_VERSION)
|
||||
-#define OPENCV_TEST_VERSION(major,minor,patch) ( OPENCV_VERSION >= OPENCV_MAKE_VERSION(major,minor,patch) )
|
||||
+#define OPENCV_TEST_VERSION(major,minor,patch) ( OPENCV_VERSION < OPENCV_MAKE_VERSION(major,minor,patch) )
|
||||
|
||||
-#include <opencv2/core/core.hpp>
|
||||
-#include <opencv2/core/internal.hpp>
|
||||
-#include <opencv2/contrib/contrib.hpp>
|
||||
+#if(ENABLE_OPENCV3)
|
||||
+# include <opencv2/core/core.hpp>
|
||||
+# include <opencv2/core/internal.hpp>
|
||||
+# include <opencv2/contrib/contrib.hpp>
|
||||
+#else
|
||||
+# include <opencv2/face.hpp>
|
||||
+# include <opencv2/core.hpp>
|
||||
+#endif
|
||||
|
||||
// for old-style code
|
||||
+#if OPENCV_VERSION <= OPENCV_MAKE_VERSION(2,4,99)
|
||||
+# include <opencv2/legacy/compat.hpp>
|
||||
+#endif
|
||||
#include <opencv2/opencv.hpp>
|
||||
-#include <opencv2/legacy/compat.hpp>
|
||||
#include <opencv2/highgui/highgui_c.h>
|
||||
#include <opencv/cvaux.h>
|
||||
|
||||
diff -urNB a/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.cpp b/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.cpp
|
||||
--- a/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.cpp 2015-09-03 23:22:44.000000000 +0200
|
||||
+++ b/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.cpp 2016-03-04 11:03:01.968939437 +0100
|
||||
@@ -36,6 +36,8 @@
|
||||
*
|
||||
* ============================================================ */
|
||||
|
||||
+#define QT_NO_EMIT
|
||||
+
|
||||
#include "facerec_borrowed.h"
|
||||
|
||||
// C++ includes
|
||||
@@ -375,7 +377,11 @@
|
||||
}
|
||||
}
|
||||
|
||||
+#if OPENCV_TEST_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 @@
|
||||
m_grid_y, /* grid size y */
|
||||
true /* normed histograms */
|
||||
);
|
||||
+#if OPENCV_TEST_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 @@
|
||||
{
|
||||
double dist = compareHist(m_histograms[sampleIdx], query, CV_COMP_CHISQR);
|
||||
|
||||
+#if OPENCV_TEST_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 @@
|
||||
// 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 @@
|
||||
double mean = sum / it->second.size();
|
||||
s += QString("%1: %2 - ").arg(it->first).arg(mean);
|
||||
|
||||
+#if OPENCV_TEST_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 @@
|
||||
// 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 @@
|
||||
scoreMap[it->second]++;
|
||||
}
|
||||
|
||||
+#if OPENCV_TEST_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 @@
|
||||
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_TEST_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_TEST_VERSION(3,1,0)
|
||||
int LBPHFaceRecognizer::predict(InputArray _src) const
|
||||
{
|
||||
int label;
|
||||
@@ -506,6 +542,7 @@
|
||||
predict(_src, label, dummy);
|
||||
return label;
|
||||
}
|
||||
+#endif
|
||||
|
||||
// Static method ----------------------------------------------------
|
||||
|
||||
@@ -531,14 +568,15 @@
|
||||
return ptr;
|
||||
}
|
||||
|
||||
-CV_INIT_ALGORITHM(LBPHFaceRecognizer, "FaceRecognizer.LBPH-KFaceIface",
|
||||
- obj.info()->addParam(obj, "radius", obj.m_radius);
|
||||
- obj.info()->addParam(obj, "neighbors", obj.m_neighbors);
|
||||
- obj.info()->addParam(obj, "grid_x", obj.m_grid_x);
|
||||
- obj.info()->addParam(obj, "grid_y", obj.m_grid_y);
|
||||
- obj.info()->addParam(obj, "threshold", obj.m_threshold);
|
||||
- obj.info()->addParam(obj, "histograms", obj.m_histograms); // modification: Make Read/Write
|
||||
- obj.info()->addParam(obj, "labels", obj.m_labels); // modification: Make Read/Write
|
||||
- obj.info()->addParam(obj, "statistic", obj.m_statisticsMode)); // modification: Add parameter
|
||||
-
|
||||
+#if OPENCV_VERSION <= OPENCV_MAKE_VERSION(2,4,99)
|
||||
+ CV_INIT_ALGORITHM(LBPHFaceRecognizer, "FaceRecognizer.LBPH-KFaceIface",
|
||||
+ obj.info()->addParam(obj, "radius", obj.m_radius);
|
||||
+ obj.info()->addParam(obj, "neighbors", obj.m_neighbors);
|
||||
+ obj.info()->addParam(obj, "grid_x", obj.m_grid_x);
|
||||
+ obj.info()->addParam(obj, "grid_y", obj.m_grid_y);
|
||||
+ obj.info()->addParam(obj, "threshold", obj.m_threshold);
|
||||
+ obj.info()->addParam(obj, "histograms", obj.m_histograms); // modification: Make Read/Write
|
||||
+ obj.info()->addParam(obj, "labels", obj.m_labels); // modification: Make Read/Write
|
||||
+ obj.info()->addParam(obj, "statistic", obj.m_statisticsMode)) // modification: Add parameter
|
||||
+#endif
|
||||
} // namespace KFaceIface
|
||||
diff -urNB a/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.h b/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.h
|
||||
--- a/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.h 2015-09-03 23:22:44.000000000 +0200
|
||||
+++ b/extra/libkface/libkface/recognition-opencv-lbph/facerec_borrowed.h 2016-03-04 10:59:51.244576351 +0100
|
||||
@@ -45,7 +45,11 @@
|
||||
namespace KFaceIface
|
||||
{
|
||||
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
class LBPHFaceRecognizer : public cv::FaceRecognizer
|
||||
+#else
|
||||
+class LBPHFaceRecognizer : public cv::face::FaceRecognizer
|
||||
+#endif
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -99,8 +103,13 @@
|
||||
|
||||
~LBPHFaceRecognizer() {}
|
||||
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
using cv::FaceRecognizer::save;
|
||||
using cv::FaceRecognizer::load;
|
||||
+#else
|
||||
+ using cv::face::FaceRecognizer::save;
|
||||
+ using cv::face::FaceRecognizer::load;
|
||||
+#endif
|
||||
|
||||
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);
|
||||
|
||||
@@ -116,6 +125,8 @@
|
||||
*/
|
||||
void update(cv::InputArrayOfArrays src, cv::InputArray labels);
|
||||
|
||||
+
|
||||
+#if OPENCV_TEST_VERSION(3,1,0)
|
||||
/**
|
||||
* Predicts the label of a query image in src.
|
||||
*/
|
||||
@@ -125,6 +136,13 @@
|
||||
* 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,8 @@
|
||||
/**
|
||||
* Getter functions.
|
||||
*/
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
+
|
||||
int neighbors() const { return m_neighbors; }
|
||||
int radius() const { return m_radius; }
|
||||
int grid_x() const { return m_grid_x; }
|
||||
@@ -147,6 +167,34 @@
|
||||
// NOTE: Implementation done through CV_INIT_ALGORITHM macro from OpenCV.
|
||||
cv::AlgorithmInfo* info() const;
|
||||
|
||||
+#else
|
||||
+
|
||||
+ int getNeighbors() const { return m_neighbors; }
|
||||
+ void setNeighbors(int _neighbors) { m_neighbors = _neighbors; }
|
||||
+
|
||||
+ int getRadius() const { return m_radius; }
|
||||
+ void setRadius(int radius) { m_radius = radius; }
|
||||
+
|
||||
+ int getGrid_x() const { return m_grid_x; }
|
||||
+ void setGrid_x(int _grid_x) { m_grid_x = _grid_x; }
|
||||
+
|
||||
+ int getGrid_y() const { return m_grid_y; }
|
||||
+ void setGrid_y(int _grid_y) { m_grid_y = _grid_y; }
|
||||
+
|
||||
+ double getThreshold() const { return m_threshold; }
|
||||
+ void setThreshold(double _threshold) { m_threshold = _threshold; }
|
||||
+
|
||||
+ void setHistograms(std::vector<cv::Mat> _histograms) { m_histograms = _histograms; }
|
||||
+ std::vector<cv::Mat> getHistograms() const { return m_histograms; }
|
||||
+
|
||||
+ void setLabels(cv::Mat _labels) { m_labels = _labels; }
|
||||
+ cv::Mat getLabels() const { return m_labels; }
|
||||
+
|
||||
+ void setStatistic(int _statistic) { m_statisticsMode = _statistic; }
|
||||
+ int getStatistic() const { return m_statisticsMode; }
|
||||
+
|
||||
+#endif
|
||||
+
|
||||
private:
|
||||
|
||||
/** Computes a LBPH model with images in src and
|
||||
diff -urNB a/extra/libkface/libkface/recognition-opencv-lbph/lbphfacemodel.cpp b/extra/libkface/libkface/recognition-opencv-lbph/lbphfacemodel.cpp
|
||||
--- a/extra/libkface/libkface/recognition-opencv-lbph/lbphfacemodel.cpp 2015-09-03 23:22:44.000000000 +0200
|
||||
+++ b/extra/libkface/libkface/recognition-opencv-lbph/lbphfacemodel.cpp 2016-03-04 08:17:46.260398775 +0100
|
||||
@@ -61,7 +61,11 @@
|
||||
: cv::Ptr<LBPHFaceRecognizer>(LBPHFaceRecognizer::create()),
|
||||
databaseId(0)
|
||||
{
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
ptr()->set("threshold", 100.0);
|
||||
+#else
|
||||
+ ptr()->setThreshold(100.0);
|
||||
+#endif
|
||||
}
|
||||
|
||||
LBPHFaceModel::~LBPHFaceModel()
|
||||
@@ -80,7 +84,11 @@
|
||||
|
||||
const LBPHFaceRecognizer* LBPHFaceModel::ptr() const
|
||||
{
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
const LBPHFaceRecognizer* const ptr = cv::Ptr<LBPHFaceRecognizer>::operator const KFaceIface::LBPHFaceRecognizer*();
|
||||
+#else
|
||||
+ const LBPHFaceRecognizer* const ptr = cv::Ptr<LBPHFaceRecognizer>::operator KFaceIface::LBPHFaceRecognizer*();
|
||||
+#endif
|
||||
|
||||
if (!ptr)
|
||||
kWarning() << "LBPHFaceRecognizer pointer is null";
|
||||
@@ -90,47 +98,83 @@
|
||||
|
||||
int LBPHFaceModel::radius() const
|
||||
{
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
return ptr()->get<int>("radius");
|
||||
+#else
|
||||
+ return ptr()->getRadius();
|
||||
+#endif
|
||||
}
|
||||
|
||||
void LBPHFaceModel::setRadius(int radius)
|
||||
{
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
ptr()->set("radius", radius);
|
||||
+#else
|
||||
+ ptr()->setRadius(radius);
|
||||
+#endif
|
||||
}
|
||||
|
||||
int LBPHFaceModel::neighbors() const
|
||||
{
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
return ptr()->get<int>("neighbors");
|
||||
+#else
|
||||
+ return ptr()->getNeighbors();
|
||||
+#endif
|
||||
}
|
||||
|
||||
void LBPHFaceModel::setNeighbors(int neighbors)
|
||||
{
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
ptr()->set("neighbors", neighbors);
|
||||
+#else
|
||||
+ ptr()->setNeighbors(neighbors);
|
||||
+#endif
|
||||
}
|
||||
|
||||
int LBPHFaceModel::gridX() const
|
||||
{
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
return ptr()->get<int>("grid_x");
|
||||
+#else
|
||||
+ return ptr()->getGrid_x();
|
||||
+#endif
|
||||
}
|
||||
|
||||
void LBPHFaceModel::setGridX(int grid_x)
|
||||
{
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
ptr()->set("grid_x", grid_x);
|
||||
+#else
|
||||
+ ptr()->setGrid_x(grid_x);
|
||||
+#endif
|
||||
}
|
||||
|
||||
int LBPHFaceModel::gridY() const
|
||||
{
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
return ptr()->get<int>("grid_y");
|
||||
+#else
|
||||
+ return ptr()->getGrid_y();
|
||||
+#endif
|
||||
}
|
||||
|
||||
void LBPHFaceModel::setGridY(int grid_y)
|
||||
{
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
ptr()->set("grid_y", grid_y);
|
||||
+#else
|
||||
+ ptr()->setGrid_y(grid_y);
|
||||
+#endif
|
||||
}
|
||||
|
||||
OpenCVMatData LBPHFaceModel::histogramData(int index) const
|
||||
{
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
return OpenCVMatData(ptr()->get<std::vector<cv::Mat> >("histograms").at(index));
|
||||
+#else
|
||||
+ return OpenCVMatData(ptr()->getHistograms().at(index));
|
||||
+#endif
|
||||
}
|
||||
|
||||
QList<LBPHistogramMetadata> LBPHFaceModel::histogramMetadata() const
|
||||
@@ -168,12 +212,24 @@
|
||||
m_histogramMetadata << metadata;
|
||||
}
|
||||
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
std::vector<cv::Mat> currentHistograms = ptr()->get<std::vector<cv::Mat> >("histograms");
|
||||
cv::Mat currentLabels = ptr()->get<cv::Mat>("labels");
|
||||
+#else
|
||||
+ std::vector<cv::Mat> currentHistograms = ptr()->getHistograms();
|
||||
+ cv::Mat currentLabels = ptr()->getLabels();
|
||||
+#endif
|
||||
+
|
||||
currentHistograms.insert(currentHistograms.end(), newHistograms.begin(), newHistograms.end());
|
||||
currentLabels.push_back(newLabels);
|
||||
+
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
ptr()->set("histograms", currentHistograms);
|
||||
- ptr()->set("labels", currentLabels);
|
||||
+ ptr()->set("labels", currentLabels);
|
||||
+#else
|
||||
+ ptr()->setHistograms(currentHistograms);
|
||||
+ ptr()->setLabels(currentLabels);
|
||||
+#endif
|
||||
|
||||
/*
|
||||
//Most cumbersome and inefficient way through a file storage which we were forced to use if we used standard OpenCV
|
||||
@@ -215,7 +271,11 @@
|
||||
|
||||
// Update local information
|
||||
// We assume new labels are simply appended
|
||||
+#if OPENCV_TEST_VERSION(3,0,0)
|
||||
cv::Mat currentLabels = ptr()->get<cv::Mat>("labels");
|
||||
+#else
|
||||
+ cv::Mat currentLabels = ptr()->getLabels();
|
||||
+#endif
|
||||
|
||||
for (int i = m_histogramMetadata.size() ; i < currentLabels.rows ; i++)
|
||||
{
|
Loading…
Reference in New Issue
Block a user