From 28f9ff131276e3e0df5d0b6d6e5c03ce01f5319e Mon Sep 17 00:00:00 2001 From: vanechipi Date: Mon, 10 Aug 2015 19:13:11 +0200 Subject: [PATCH] facedetect: simplify repeated code. Store the value of r.height / 2 instead of repeating the operation line three times. --- ext/opencv/gstfacedetect.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ext/opencv/gstfacedetect.cpp b/ext/opencv/gstfacedetect.cpp index cac7b177d5..a5e4b99ec3 100644 --- a/ext/opencv/gstfacedetect.cpp +++ b/ext/opencv/gstfacedetect.cpp @@ -640,6 +640,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, guint rnx = 0, rny = 0, rnw, rnh; guint rmx = 0, rmy = 0, rmw, rmh; guint rex = 0, rey = 0, rew, reh; + guint rhh = r.height / 2; gboolean have_nose, have_mouth, have_eyes; /* detect face features */ @@ -648,7 +649,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, rnx = r.x + r.width / 4; rny = r.y + r.height / 4; rnw = r.width / 2; - rnh = r.height / 2; + rnh = rhh; gst_face_detect_run_detector (filter, filter->cvNoseDetect, mw, mh, Rect (rnx, rny, rnw, rnh), nose); have_nose = !nose.empty (); @@ -660,7 +661,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, rmx = r.x; rmy = r.y + r.height / 2; rmw = r.width; - rmh = r.height / 2; + rmh = rhh; gst_face_detect_run_detector (filter, filter->cvMouthDetect, mw, mh, Rect (rmx, rmy, rmw, rmh), mouth); have_mouth = !mouth.empty (); @@ -672,7 +673,7 @@ gst_face_detect_transform_ip (GstOpencvVideoFilter * base, GstBuffer * buf, rex = r.x; rey = r.y; rew = r.width; - reh = r.height / 2; + reh = rhh; gst_face_detect_run_detector (filter, filter->cvEyesDetect, mw, mh, Rect (rex, rey, rew, reh), eyes); have_eyes = !eyes.empty ();