From bb3ec78313e82859eb6927f770c8d20123868038 Mon Sep 17 00:00:00 2001 From: Weng Xuetian Date: Thu, 21 Jan 2016 02:24:45 +0000 Subject: [PATCH] update digikam libkface against new opencv 3.1 --- digikam/PKGBUILD | 108 ++++++++++--------- digikam/PKGBUILD-kf5-beta | 79 -------------- libkface/PKGBUILD | 11 +- libkface/opencv-3.1-support.patch | 167 ++++++++++++++++++++++++++++++ 4 files changed, 234 insertions(+), 131 deletions(-) delete mode 100644 digikam/PKGBUILD-kf5-beta create mode 100644 libkface/opencv-3.1-support.patch diff --git a/digikam/PKGBUILD b/digikam/PKGBUILD index fd78c590b..0a344ec7d 100644 --- a/digikam/PKGBUILD +++ b/digikam/PKGBUILD @@ -1,68 +1,80 @@ - pkgbase=digikam +pkgbase=digikam pkgname=('digikam' 'kipi-plugins') -pkgver=4.14.0 -pkgrel=2 +_pkgver=5.0.0-beta2 +pkgver=${_pkgver//-/_} +pkgrel=4 url="http://digikam.sourceforge.net" arch=('x86_64') license=('GPL') -screenshot=('http://i.imgur.com/6YnUM.png') -makedepends=('kde-runtime' 'kdepimlibs4' 'lensfun' 'libmarble4' - 'liblqr' 'opencv' 'lapack' 'libgpod' 'libkvkontakte' 'pkgconfig' 'cmake' 'automoc4' - 'doxygen' 'docbook-xsl' 'qjson' 'libkexiv2_4' 'libkdcraw4' - 'libksane4' 'mariadb' 'qt4-gstreamer' 'boost' 'hugin-tools' 'eigen3' - 'libbluray' 'libpgf' 'libkface' 'libkgeomap' 'kfilemetadata4') -source=("http://download.kde.org/stable/${pkgname}/${pkgname}-${pkgver}.tar.bz2") options=("debug") -md5sums=('8fd3cb0a822e8c2d4102e8adc00c082f') +makedepends=('extra-cmake-modules' 'libkipi' 'libksane' 'liblqr' 'boost' + 'libgpod' 'hugin' 'opencv' 'qt5-webkit' 'doxygen' 'lensfun' 'imagemagick' 'eigen3' 'libpgf' + 'libusb' 'kio' 'kdoctools' 'marble' 'kfilemetadata' 'akonadi-contact' 'qt5-multimedia' + 'threadweaver' 'kcalcore' 'knotifyconfig' 'kdelibs4support' 'libkvkontakte' 'libmediawiki') +source=("http://download.kde.org/unstable/${pkgname}/${pkgname}-${_pkgver}.tar.bz2") +sha1sums=('db2f6d7e84e67a338bee9373bdba2dc116f5e1f0') + + +prepare() { + mkdir -p build + + sed -e 's|${KF5_MIN_VERSION}||' -i $pkgname-$_pkgver/core/CMakeLists.txt -i $pkgname-$_pkgver/extra/kipi-plugins/CMakeLists.txt +} build() { - cd ${srcdir} - - mkdir -p build && cd build - cmake ../${pkgname}-${pkgver} \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DCMAKE_INSTALL_LIBDIR=/usr/lib \ - -DCMAKE_SKIP_RPATH=ON \ - -DBUILD_tests=OFF \ - -DDIGIKAMSC_COMPILE_LIBMEDIAWIKI=ON \ - -DENABLE_KDEPIMLIBSSUPPORT=ON \ - -DENABLE_MYSQLSUPPORT=ON + cd build - make + cmake ../${pkgname}-${_pkgver} \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DCMAKE_INSTALL_LIBDIR=lib \ + -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_SKIP_RPATH=ON \ + -DBUILD_TESTING=OFF \ + -DKDE_INSTALL_USE_QT_SYS_PATHS=ON \ + -DENABLE_KFILEMETADATASUPPORT=ON \ + -DENABLE_MEDIAPLAYER=ON \ + -DENABLE_AKONADICONTACTSUPPORT=ON \ + -DENABLE_OPENCV3=On \ + -DDIGIKAMSC_CHECKOUT_PO=ON + make } package_digikam() { - pkgdesc="Digital photo management application for kde" - depends=('kde-runtime' 'kdepimlibs4' 'lensfun' 'libmarble4' 'liblqr' - 'mariadb' 'opencv' 'kipi-plugins' 'lapack' 'libgpod' 'libpgf' 'libkface' 'libkgeomap') + pkgdesc="Digital photo management application for KDE" + depends=('liblqr' 'libkipi' 'lensfun' 'libpgf' 'opencv' 'akonadi-contact' + 'knotifyconfig' 'libksane' 'kfilemetadata' 'qt5-multimedia' 'marble') + optdepends=('kipi-plugins: more tools and plugins') install=digikam.install - replaces=('digikamimageplugins') - categories=('graphics') - screenshot=('http://farm4.staticflickr.com/3197/2606712653_e9b9dc6ca1_o.png') - splitdirs="core doc po" - for i in ${splitdirs} ; do - cd ${srcdir}/build/${i} - make DESTDIR="${pkgdir}" install - done - rm -rf "${pkgdir}/usr/share/icons/oxygen" - rm "${pkgdir}"/usr/share/locale/kde4/*/LC_MESSAGES/libkipi.mo + pushd build/core + make DESTDIR="${pkgdir}" install + popd + + pushd build/doc/digikam + make DESTDIR="${pkgdir}" install + popd } package_kipi-plugins() { - pkgdesc="Kipi plugins and additional libs for digikam and kde apps" - depends=('kdepimlibs4' 'opencv' 'libgpod' 'sane' 'hugin-tools' - 'libgphoto2-nolimit' 'libkvkontakte' 'libkexiv2_4' 'libkdcraw4' - 'libksane4' 'qt4-gstreamer' 'kfilemetadata4') - optdepends=('imagemagick: for picture manipulation' - 'qca: for shwup webservice support' - 'libkgeomap: Geolocalize tool') + pkgdesc="A collection of plugins extending the KDE graphics and image applications as digiKam" + depends=('kio' 'libkipi') + optdepends=('kcalcore: Calendar plugin' + # 'libmediawiki: MediaWiki Export plugin' + # 'libkvkontakte: VKontakte.ru Exporter plugin' + 'libgpod: iPodExport plugin' + 'opencv: Remove Red Eyes plugin' + 'imagemagick: Video SlideShow plugin' + 'qt5-gstreamer: Video SlideShow plugin' + 'threadweaver: panorama plugin' + 'hugin: panorama plugin') install=kipi-plugins.install - categories=('graphics') - - cd ${srcdir}/build/extra/kipi-plugins + pushd build/extra/kipi-plugins make DESTDIR="${pkgdir}" install -} \ No newline at end of file + popd + + pushd build/doc/kipi-plugins + make DESTDIR="${pkgdir}" install + popd +} diff --git a/digikam/PKGBUILD-kf5-beta b/digikam/PKGBUILD-kf5-beta deleted file mode 100644 index c395bacd5..000000000 --- a/digikam/PKGBUILD-kf5-beta +++ /dev/null @@ -1,79 +0,0 @@ -pkgbase=digikam -pkgname=('digikam' 'kipi-plugins') -_pkgver=5.0.0-beta2 -pkgver=${_pkgver//-/_} -pkgrel=1 -url="http://digikam.sourceforge.net" -arch=('x86_64') -license=('GPL') -options=("debug") -makedepends=('extra-cmake-modules' 'libkipi' 'libksane' 'liblqr' 'opencv' 'boost' - 'libgpod' 'hugin' 'opencv' 'qt5-webkit' 'doxygen' 'lensfun' 'imagemagick' 'eigen3' 'libpgf' - 'libusb' 'kio' 'kdoctools' 'marble' 'kfilemetadata' 'akonadi-contact' 'qt5-multimedia' - 'threadweaver' 'kcalcore' 'knotifyconfig' 'kdelibs4support' 'libkvkontakte' 'libmediawiki') -source=("http://download.kde.org/unstable/${pkgname}/${pkgname}-${_pkgver}.tar.bz2") -sha1sums=('db2f6d7e84e67a338bee9373bdba2dc116f5e1f0') - - -prepare() { - mkdir -p build - - sed -e 's|${KF5_MIN_VERSION}||' -i $pkgname-$_pkgver/core/CMakeLists.txt -i $pkgname-$_pkgver/extra/kipi-plugins/CMakeLists.txt -} - -build() { - - cd build - - cmake ../${pkgname}-${_pkgver} \ - -DCMAKE_INSTALL_PREFIX=/usr \ - -DCMAKE_INSTALL_LIBDIR=lib \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ - -DCMAKE_SKIP_RPATH=ON \ - -DBUILD_TESTING=OFF \ - -DKDE_INSTALL_USE_QT_SYS_PATHS=ON \ - -DENABLE_KFILEMETADATASUPPORT=ON \ - -DENABLE_MEDIAPLAYER=ON \ - -DENABLE_AKONADICONTACTSUPPORT=ON \ - -DDIGIKAMSC_CHECKOUT_PO=ON - make -} - -package_digikam() { - pkgdesc="Digital photo management application for KDE" - depends=('liblqr' 'libkipi' 'lensfun' 'libpgf' 'opencv' 'akonadi-contact' - 'knotifyconfig' 'libksane' 'kfilemetadata' 'qt5-multimedia' 'marble') - optdepends=('kipi-plugins: more tools and plugins') - install=digikam.install - - pushd build/core - make DESTDIR="${pkgdir}" install - popd - - pushd build/doc/digikam - make DESTDIR="${pkgdir}" install - popd -} - -package_kipi-plugins() { - pkgdesc="A collection of plugins extending the KDE graphics and image applications as digiKam" - depends=('kio' 'libkipi') - optdepends=('kcalcore: Calendar plugin' - # 'libmediawiki: MediaWiki Export plugin' - # 'libkvkontakte: VKontakte.ru Exporter plugin' - 'libgpod: iPodExport plugin' - 'opencv: Remove Red Eyes plugin' - 'imagemagick: Video SlideShow plugin' - 'qt5-gstreamer: Video SlideShow plugin' - 'threadweaver: panorama plugin' - 'hugin: panorama plugin') - install=kipi-plugins.install - - pushd build/extra/kipi-plugins - make DESTDIR="${pkgdir}" install - popd - - pushd build/doc/kipi-plugins - make DESTDIR="${pkgdir}" install - popd -} diff --git a/libkface/PKGBUILD b/libkface/PKGBUILD index cf5451dd2..38729b82b 100644 --- a/libkface/PKGBUILD +++ b/libkface/PKGBUILD @@ -4,7 +4,7 @@ source ../kdeapps.conf pkgname=libkface pkgver=${_kdever} -pkgrel=1 +pkgrel=2 pkgdesc="A Qt/C++ wrapper around LibFace library to perform face recognition and detection over pictures" url="https://projects.kde.org/projects/kde/kdegraphics/libs/libkface" arch=('x86_64') @@ -13,16 +13,19 @@ depends=(qt5-base opencv) makedepends=(extra-cmake-modules) install=${pkgname}.install options=('docs' 'debug') -source=("$_mirror/${pkgname}-$_kdever.tar.xz") -sha256sums=(`grep ${pkgname}-$_kdever.tar.xz ../checksums.txt | cut -d " " -f1`) +source=("$_mirror/${pkgname}-$_kdever.tar.xz" "opencv-3.1-support.patch") +sha256sums=(`grep ${pkgname}-$_kdever.tar.xz ../checksums.txt | cut -d " " -f1` + 'b778be1f87897205bc4ea22ae94177a4aa4dcf9ae25b74a272818eed1049a779') prepare() { mkdir build + cd ${pkgname}-${pkgver} + patch -Np1 -i ../opencv-3.1-support.patch } build() { cd build - cmake_kf5 ../${pkgname}-${pkgver} + cmake_kf5 ../${pkgname}-${pkgver} -DENABLE_OPENCV3=On make } diff --git a/libkface/opencv-3.1-support.patch b/libkface/opencv-3.1-support.patch new file mode 100644 index 000000000..8ba12618a --- /dev/null +++ b/libkface/opencv-3.1-support.patch @@ -0,0 +1,167 @@ +diff --git a/src/recognition-opencv-lbph/facerec_borrowed.cpp b/src/recognition-opencv-lbph/facerec_borrowed.cpp +index 748691e..3c37ce2 100644 +--- a/src/recognition-opencv-lbph/facerec_borrowed.cpp ++++ b/src/recognition-opencv-lbph/facerec_borrowed.cpp +@@ -36,6 +36,8 @@ + * + * ============================================================ */ + ++#define QT_NO_EMIT ++ + #include "facerec_borrowed.h" + + // C++ includes +@@ -375,7 +377,11 @@ void LBPHFaceRecognizer::train(InputArrayOfArrays _in_src, InputArray _inm_label + } + } + ++#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 collector, const int state) const ++#endif + { + if(m_histograms.empty()) + { +@@ -394,8 +400,12 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist + 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 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist + { + 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) sampleIdx); + } ++#else ++ int label = m_labels.at((int) sampleIdx); ++ if (!collector->emit(label, dist, state)) ++ { ++ return; ++ } ++#endif + } + } + +@@ -422,7 +440,7 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist + // Create map "label -> vector of distances to all histograms for this label" + std::map > 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& distances = distancesMap[m_labels.at((int) sampleIdx)]; +@@ -445,11 +463,18 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist + double mean = sum / it->second.size(); + s += QString::fromLatin1("%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 + } + + qCDebug(LIBKFACE_LOG) << s; +@@ -462,7 +487,7 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist + // map "label -> number of histograms" + std::map 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) sampleIdx); + double dist = compareHist(m_histograms[sampleIdx], query, CV_COMP_CHISQR); +@@ -480,7 +505,9 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist + scoreMap[it->second]++; + } + ++#if OPENCV_TEST_VERSION(3,1,0) + minDist = 0; ++#endif + QString s = QString::fromLatin1("Nearest Neighbor score: "); + + for (std::map::iterator it = scoreMap.begin(); it != scoreMap.end(); ++it) +@@ -488,17 +515,26 @@ void LBPHFaceRecognizer::predict(InputArray _src, int &minClass, double &minDist + double score = double(it->second) / countMap.at(it->first); + s += QString::fromLatin1("%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 + } + + qCDebug(LIBKFACE_LOG) << s; + } + } + ++#if OPENCV_TEST_VERSION(3,1,0) + int LBPHFaceRecognizer::predict(InputArray _src) const + { + int label; +@@ -506,6 +542,7 @@ int LBPHFaceRecognizer::predict(InputArray _src) const + predict(_src, label, dummy); + return label; + } ++#endif + + // Static method ---------------------------------------------------- + +diff --git a/src/recognition-opencv-lbph/facerec_borrowed.h b/src/recognition-opencv-lbph/facerec_borrowed.h +index 27ad77a..f197d22 100644 +--- a/src/recognition-opencv-lbph/facerec_borrowed.h ++++ b/src/recognition-opencv-lbph/facerec_borrowed.h +@@ -125,6 +125,8 @@ public: + */ + void update(cv::InputArrayOfArrays src, cv::InputArray labels); + ++ ++#if OPENCV_TEST_VERSION(3,1,0) + /** + * Predicts the label of a query image in src. + */ +@@ -134,6 +136,13 @@ public: + * 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 collector, const int state = 0) const override; ++#endif + + /** + * See FaceRecognizer::load().