[shotwell] Fix compatibility with OpenCV 4
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] Fix compatibility with OpenCV 4
- Date: Sun, 15 Mar 2020 10:26:28 +0000 (UTC)
commit f54094594016359bbafd0be44a53ea28c8968593
Author: Jens Georg <mail jensge org>
Date: Sun Mar 15 11:19:18 2020 +0100
Fix compatibility with OpenCV 4
Second try, much simpler version
subprojects/shotwell-facedetect/facedetect-opencv.cpp | 7 +++----
subprojects/shotwell-facedetect/meson.build | 5 ++++-
2 files changed, 7 insertions(+), 5 deletions(-)
---
diff --git a/subprojects/shotwell-facedetect/facedetect-opencv.cpp
b/subprojects/shotwell-facedetect/facedetect-opencv.cpp
index 70669e30..f844ac56 100644
--- a/subprojects/shotwell-facedetect/facedetect-opencv.cpp
+++ b/subprojects/shotwell-facedetect/facedetect-opencv.cpp
@@ -33,15 +33,14 @@ std::vector<FaceRect> detectFaces(cv::String inputName, cv::String cascadeName,
if (disableDnn) {
// Classical face detection
cv::Mat gray;
- cvtColor(img, gray, CV_BGR2GRAY);
+ cvtColor(img, gray, cv::COLOR_BGR2GRAY);
cv::Mat smallImg(cvRound(img.rows / scale), cvRound(img.cols / scale), CV_8UC1);
smallImgSize = smallImg.size();
cv::resize(gray, smallImg, smallImgSize, 0, 0, cv::INTER_LINEAR);
cv::equalizeHist(smallImg, smallImg);
-
- cascade.detectMultiScale(smallImg, faces, 1.1, 2, CV_HAAR_SCALE_IMAGE, cv::Size(30, 30));
+ cascade.detectMultiScale(smallImg, faces, 1.1, 2, cv::CASCADE_SCALE_IMAGE, cv::Size(30, 30));
} else {
#ifdef HAS_OPENCV_DNN
// DNN based face detection
@@ -159,7 +158,7 @@ std::vector<double> faceToVecMat(cv::Mat img) {
std::vector<double> faceToVec(cv::String inputName) {
std::vector<double> ret;
- cv::Mat img = imread(inputName, 1);
+ cv::Mat img = cv::imread(inputName, 1);
if (img.empty()) {
std::cout << "error;Could not load the file to process. Filename: \"" << inputName << "\"" <<
std::endl;
ret.assign(128, 0);
diff --git a/subprojects/shotwell-facedetect/meson.build b/subprojects/shotwell-facedetect/meson.build
index 493bc04b..ec060812 100644
--- a/subprojects/shotwell-facedetect/meson.build
+++ b/subprojects/shotwell-facedetect/meson.build
@@ -1,6 +1,9 @@
project('shotwell-facedetect', ['c', 'cpp'], default_options : ['cpp_std=c++14'])
gnome = import('gnome')
-facedetect_dep = dependency('opencv', version : ['>= 2.3.0'], required : true)
+facedetect_dep = dependency('opencv4', version : ['>= 4.0.0'], required : false)
+if not facedetect_dep.found()
+ facedetect_dep = dependency('opencv', version : ['>= 3.4.0'], required : true)
+endif
cpp = meson.get_compiler('cpp')
has_dnn = cpp.has_header('opencv2/dnn.hpp', dependencies: facedetect_dep)
if has_dnn
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]