summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>2017-11-15 10:30:46 -0800
committerReynaldo H. Verdejo Pinochet <reynaldo@freedesktop.org>2019-04-17 15:27:52 -0700
commitf10458fd1c14590cb27eb665d5f215bf2c5f57e4 (patch)
tree4bfd904845fa151c1a586b0bd19ed52b1a9109a8
parent74d281fbc2c8017b8f2c58ec21f6882fd4731936 (diff)
opencv: facedetect: allow getting haar path from the environment
-rw-r--r--ext/opencv/gstfacedetect.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/ext/opencv/gstfacedetect.cpp b/ext/opencv/gstfacedetect.cpp
index c1b89ea33..c7cb4d538 100644
--- a/ext/opencv/gstfacedetect.cpp
+++ b/ext/opencv/gstfacedetect.cpp
@@ -90,10 +90,10 @@ GST_DEBUG_CATEGORY_STATIC (gst_face_detect_debug);
#define HAAR_CASCADES_DIR OPENCV_PREFIX G_DIR_SEPARATOR_S "share" \
G_DIR_SEPARATOR_S OPENCV_PATH_NAME G_DIR_SEPARATOR_S "haarcascades" \
G_DIR_SEPARATOR_S
-#define DEFAULT_FACE_PROFILE HAAR_CASCADES_DIR "haarcascade_frontalface_default.xml"
-#define DEFAULT_NOSE_PROFILE HAAR_CASCADES_DIR "haarcascade_mcs_nose.xml"
-#define DEFAULT_MOUTH_PROFILE HAAR_CASCADES_DIR "haarcascade_mcs_mouth.xml"
-#define DEFAULT_EYES_PROFILE HAAR_CASCADES_DIR "haarcascade_mcs_eyepair_small.xml"
+#define DEFAULT_FACE_PROFILE "haarcascade_frontalface_default.xml"
+#define DEFAULT_NOSE_PROFILE "haarcascade_mcs_nose.xml"
+#define DEFAULT_MOUTH_PROFILE "haarcascade_mcs_mouth.xml"
+#define DEFAULT_EYES_PROFILE "haarcascade_mcs_eyepair_small.xml"
#define DEFAULT_SCALE_FACTOR 1.25
#if (CV_MAJOR_VERSION >= 4)
#define DEFAULT_FLAGS CASCADE_DO_CANNY_PRUNING
@@ -293,22 +293,22 @@ gst_face_detect_class_init (GstFaceDetectClass * klass)
g_object_class_install_property (gobject_class, PROP_FACE_PROFILE,
g_param_spec_string ("profile", "Face profile",
"Location of Haar cascade file to use for face detection",
- DEFAULT_FACE_PROFILE,
+ HAAR_CASCADES_DIR DEFAULT_FACE_PROFILE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
g_object_class_install_property (gobject_class, PROP_NOSE_PROFILE,
g_param_spec_string ("nose-profile", "Nose profile",
"Location of Haar cascade file to use for nose detection",
- DEFAULT_NOSE_PROFILE,
+ HAAR_CASCADES_DIR DEFAULT_NOSE_PROFILE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
g_object_class_install_property (gobject_class, PROP_MOUTH_PROFILE,
g_param_spec_string ("mouth-profile", "Mouth profile",
"Location of Haar cascade file to use for mouth detection",
- DEFAULT_MOUTH_PROFILE,
+ HAAR_CASCADES_DIR DEFAULT_MOUTH_PROFILE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
g_object_class_install_property (gobject_class, PROP_EYES_PROFILE,
g_param_spec_string ("eyes-profile", "Eyes profile",
"Location of Haar cascade file to use for eye-pair detection",
- DEFAULT_EYES_PROFILE,
+ HAAR_CASCADES_DIR DEFAULT_EYES_PROFILE,
(GParamFlags) (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)));
g_object_class_install_property (gobject_class, PROP_FLAGS,
@@ -365,10 +365,15 @@ gst_face_detect_class_init (GstFaceDetectClass * klass)
static void
gst_face_detect_init (GstFaceDetect * filter)
{
- filter->face_profile = g_strdup (DEFAULT_FACE_PROFILE);
- filter->nose_profile = g_strdup (DEFAULT_NOSE_PROFILE);
- filter->mouth_profile = g_strdup (DEFAULT_MOUTH_PROFILE);
- filter->eyes_profile = g_strdup (DEFAULT_EYES_PROFILE);
+
+ const gchar *haar_path;
+ haar_path = g_getenv ("GST_HAAR_CASCADES_PATH")?
+ g_getenv ("GST_HAAR_CASCADES_PATH") : HAAR_CASCADES_DIR;
+
+ filter->face_profile = g_strconcat (haar_path, DEFAULT_FACE_PROFILE, NULL);
+ filter->nose_profile = g_strconcat (haar_path, DEFAULT_NOSE_PROFILE, NULL);
+ filter->mouth_profile = g_strconcat (haar_path, DEFAULT_MOUTH_PROFILE, NULL);
+ filter->eyes_profile = g_strconcat (haar_path, DEFAULT_EYES_PROFILE, NULL);
filter->display = TRUE;
filter->face_detected = FALSE;
filter->scale_factor = DEFAULT_SCALE_FACTOR;