summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/opencv/gstfacedetect.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/ext/opencv/gstfacedetect.cpp b/ext/opencv/gstfacedetect.cpp
index e78e4c43c..1f351ee3a 100644
--- a/ext/opencv/gstfacedetect.cpp
+++ b/ext/opencv/gstfacedetect.cpp
@@ -595,7 +595,11 @@ gst_face_detect_run_detector (GstFaceDetect * filter,
}
}
+/**
+ * Delta percentaje after wich position is considered off-center
+ */
#define LINEAR_DAMPING_FACTOR 5
+
/**
* @gst_face_detect_get_leaning_side
*
@@ -603,12 +607,17 @@ gst_face_detect_run_detector (GstFaceDetect * filter,
* @pos: Object x coordinate
* @ref_pos: Reference x coordinate
* @side: result. DIRECTION_RIGHT or DIRECTION_LEFT. Untouched if inconclusive
+ * @displacement: Magnitude of min to max ramp
*/
static inline void
-gst_face_detect_get_leaning_side (guint *side, gint reference, gint position) {
+gst_face_detect_get_leaning_side (guint *side, gint reference, gint position,
+ guint displacement) {
+
g_assert (side);
- if (ABS (position - reference) < LINEAR_DAMPING_FACTOR)
+ displacement = displacement * LINEAR_DAMPING_FACTOR / 100;
+
+ if ((guint)ABS (position - reference) <= displacement)
return;
if (position > reference)
@@ -812,7 +821,8 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
center.y = cvRound ((rny + sr.y + h));
/* left/right toggle */
- gst_face_detect_get_leaning_side (&aim, f_center.x, center.x);
+ gst_face_detect_get_leaning_side (&aim, f_center.x, center.x,
+ r.width);
axes.width = w;
axes.height = h * 1.25; /* tweak for nose form */
@@ -827,8 +837,10 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
center.x = cvRound ((rmx + sr.x + w));
center.y = cvRound ((rmy + sr.y + h));
- if (!aim)
- gst_face_detect_get_leaning_side (&aim, f_center.x, center.x);
+ if (!aim) {
+ gst_face_detect_get_leaning_side (&aim, f_center.x, center.x,
+ r.width);
+ }
axes.width = w * 1.5; /* tweak for mouth form */
axes.height = h;