[shotwell/wip/cleanup-facedetect: 2/15] Clean-up header file
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell/wip/cleanup-facedetect: 2/15] Clean-up header file
- Date: Sun, 14 Aug 2022 15:32:29 +0000 (UTC)
commit 974bc4427a0ef1037108dc7f83db13ff8eb4ddf0
Author: Jens Georg <mail jensge org>
Date: Sat Aug 13 17:07:51 2022 +0200
Clean-up header file
.../shotwell-facedetect/facedetect-opencv.cpp | 19 ++++++++++++--
.../shotwell-facedetect/shotwell-facedetect.hpp | 30 ++++++++++------------
2 files changed, 30 insertions(+), 19 deletions(-)
---
diff --git a/subprojects/shotwell-facedetect/facedetect-opencv.cpp
b/subprojects/shotwell-facedetect/facedetect-opencv.cpp
index f844ac56..3191c548 100644
--- a/subprojects/shotwell-facedetect/facedetect-opencv.cpp
+++ b/subprojects/shotwell-facedetect/facedetect-opencv.cpp
@@ -1,9 +1,24 @@
#include "shotwell-facedetect.hpp"
#include <opencv2/imgcodecs.hpp>
+#include <opencv2/imgproc/imgproc.hpp>
+#include <opencv2/objdetect/objdetect.hpp>
-#define OPENFACE_RECOG_TORCH_NET "openface.nn4.small2.v1.t7"
-#define RESNET_DETECT_CAFFE_NET "res10_300x300_ssd_iter_140000_fp16.caffemodel"
+#ifdef HAS_OPENCV_DNN
+ #include <opencv2/dnn.hpp>
+#endif
+
+// Global variable for DNN to generate vector out of face
+#ifdef HAS_OPENCV_DNN
+static cv::dnn::Net faceRecogNet;
+static cv::dnn::Net faceDetectNet;
+#endif
+
+constexpr char OPENFACE_RECOG_TORCH_NET[]{ "openface.nn4.small2.v1.t7" };
+constexpr char RESNET_DETECT_CAFFE_NET[]{ "res10_300x300_ssd_iter_140000_fp16.caffemodel" };
+
+std::vector<cv::Rect> detectFacesMat(cv::Mat img);
+std::vector<double> faceToVecMat(cv::Mat img);
// Detect faces in a photo
std::vector<FaceRect> detectFaces(cv::String inputName, cv::String cascadeName, double scale, bool infer =
false) {
diff --git a/subprojects/shotwell-facedetect/shotwell-facedetect.hpp
b/subprojects/shotwell-facedetect/shotwell-facedetect.hpp
index 688a1012..ae6f18dc 100644
--- a/subprojects/shotwell-facedetect/shotwell-facedetect.hpp
+++ b/subprojects/shotwell-facedetect/shotwell-facedetect.hpp
@@ -7,30 +7,26 @@
* Header file for facedetect/recognition routines
*/
+#pragma once
+
#include <opencv2/core/core.hpp>
-#include <opencv2/objdetect/objdetect.hpp>
-#include <opencv2/imgproc/imgproc.hpp>
-#ifdef HAS_OPENCV_DNN
-#include <opencv2/dnn.hpp>
-#endif
+#include <algorithm>
#include <iostream>
#include <stdio.h>
-#include <algorithm>
-typedef struct {
- float x, y, width, height;
+struct FaceRect {
+ FaceRect()
+ : vec(128, 0)
+ {
+ }
+ float x{ 0.0F };
+ float y{ 0.0F };
+ float width{ 0.0F };
+ float height{ 0.0F };
std::vector<double> vec;
-} FaceRect;
-
-// Global variable for DNN to generate vector out of face
-#ifdef HAS_OPENCV_DNN
-static cv::dnn::Net faceRecogNet;
-static cv::dnn::Net faceDetectNet;
-#endif
+};
bool loadNet(cv::String netFile);
std::vector<FaceRect> detectFaces(cv::String inputName, cv::String cascadeName, double scale, bool infer);
-std::vector<cv::Rect> detectFacesMat(cv::Mat img);
-std::vector<double> faceToVecMat(cv::Mat img);
std::vector<double> faceToVec(cv::String inputName);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]