summaryrefslogtreecommitdiff
path: root/ext/opencv/gstfacedetect.cpp
diff options
context:
space:
mode:
authorReynaldo H. Verdejo Pinochet <reynaldo@osg.samsung.com>2017-11-29 22:10:51 -0800
committerReynaldo H. Verdejo Pinochet <reynaldo@freedesktop.org>2019-04-17 15:48:41 -0700
commit4222f903ccbd34f46eff4ee6ae4b42abbc379813 (patch)
tree006037c6ca60b457aa4641d75b07fe1163329b69 /ext/opencv/gstfacedetect.cpp
parent7f55dc4bc6c93e69dd6fda7cc3247b68f91affef (diff)
opencv: facedetect: signal gaze direction with color
THIS CHANGE IS NOT MEANT TO BE UPSTREAMED. This is just a mod.
Diffstat (limited to 'ext/opencv/gstfacedetect.cpp')
-rw-r--r--ext/opencv/gstfacedetect.cpp47
1 files changed, 40 insertions, 7 deletions
diff --git a/ext/opencv/gstfacedetect.cpp b/ext/opencv/gstfacedetect.cpp
index 1b0d2d474..c2b101669 100644
--- a/ext/opencv/gstfacedetect.cpp
+++ b/ext/opencv/gstfacedetect.cpp
@@ -759,20 +759,21 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
}
if (filter->display) {
- Point center;
- Size axes;
+ Point f_center, center;
+ Size f_axes, axes;
gdouble w, h;
+ guint aim = 0; /* unset. 1=r, 2=left */
+
gint cb = 255 - ((i & 3) << 7);
gint cg = 255 - ((i & 12) << 5);
gint cr = 255 - ((i & 48) << 3);
w = r.width / 2;
h = r.height / 2;
- center.x = cvRound ((r.x + w));
- center.y = cvRound ((r.y + h));
- axes.width = w;
- axes.height = h * 1.25; /* tweak for face form */
- ellipse (img, center, axes, 0, 0, 360, Scalar (cr, cg, cb), 3, 8, 0);
+ f_center.x = cvRound ((r.x + w));
+ f_center.y = cvRound ((r.y + h));
+ f_axes.width = w;
+ f_axes.height = h * 1.25; /* tweak for face form */
if (have_nose) {
Rect sr = nose[0];
@@ -781,10 +782,18 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
h = sr.height / 2;
center.x = cvRound ((rnx + sr.x + w));
center.y = cvRound ((rny + sr.y + h));
+
+ /* left/right toggle */
+ if (center.x > f_center.x)
+ aim = 1;
+ else if (center.x < f_center.x)
+ aim = 2;
+
axes.width = w;
axes.height = h * 1.25; /* tweak for nose form */
ellipse (img, center, axes, 0, 0, 360, Scalar (cr, cg, cb), 1, 8, 0);
}
+
if (have_mouth) {
Rect sr = mouth[0];
@@ -792,10 +801,34 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf,
h = sr.height / 2;
center.x = cvRound ((rmx + sr.x + w));
center.y = cvRound ((rmy + sr.y + h));
+
+ if (!aim) {
+ if (center.x > f_center.x)
+ aim = 1;
+ else if (center.x < f_center.x)
+ aim = 2;
+ }
+
axes.width = w * 1.5; /* tweak for mouth form */
axes.height = h;
ellipse (img, center, axes, 0, 0, 360, Scalar (cr, cg, cb), 1, 8, 0);
}
+
+ /* Face ellipse */
+ switch (aim) {
+ case 1:
+ ellipse (mtxOrg, f_center, f_axes, 0, 0, 360, Scalar (cr, 0, 0),
+ 3, 8, 0);
+ break;
+ case 2:
+ ellipse (mtxOrg, f_center, f_axes, 0, 0, 360, Scalar (0, 0, cb),
+ 3, 8, 0);
+ break;
+ default:
+ ellipse (mtxOrg, f_center, f_axes, 0, 0, 360, Scalar (cr, cg, cb),
+ 3, 8, 0);
+ }
+
if (have_eyes) {
Rect sr = eyes[0];