From ff44b1eb1320e6e95cf1d830ee00a5bbbd1ad5ce Mon Sep 17 00:00:00 2001 From: lhark Date: Tue, 7 Jun 2016 14:55:41 +0200 Subject: [PATCH] Frezza improvement --- src/papillon.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/papillon.cpp b/src/papillon.cpp index 06ad524..f563ae8 100644 --- a/src/papillon.cpp +++ b/src/papillon.cpp @@ -20,7 +20,7 @@ class Traite_image { Mat prev; Mat last_T; bool first = true; - int resize_f = 1; + int resize_f = 2; int theObject[2] = {0,0}; Rect objectBoundingRectangle = Rect(0,0,0,0); @@ -78,7 +78,7 @@ class Traite_image { searchForMovement(prev_cropped, next_stab_cropped, output); - pub_img.publish(cv_bridge::CvImage(msg->header, "rgb8", output).toImageMsg()); + pub_img.publish(cv_bridge::CvImage(msg->header, "mono8", output).toImageMsg()); // bridge_input is handled by a smart-pointer. No explicit delete needed. //droneTracking(Rect(Point(0,0), output.size())); @@ -128,7 +128,7 @@ class Traite_image { Mat cur2; - warpAffine(cur, cur2, T, cur.size(),INTER_NEAREST|WARP_INVERSE_MAP); + warpAffine(cur, cur2, T, cur.size(),INTER_CUBIC|WARP_INVERSE_MAP); cur2.copyTo(output); } @@ -138,14 +138,19 @@ class Traite_image { cur.copyTo(output); cvtColor(prev, prev_grey, COLOR_BGR2GRAY); cvtColor(cur, cur_grey, COLOR_BGR2GRAY); + GaussianBlur(prev_grey, prev_grey, Size(15,15), 3.0); + GaussianBlur(cur_grey, cur_grey, Size(15,15), 3.0); + //blur(prev_grey, prev_grey, Size(BLUR_SIZE, BLUR_SIZE)); + //blur(cur_grey, cur_grey, Size(BLUR_SIZE, BLUR_SIZE)); // Subtract the 2 last frames and threshold them Mat thres; absdiff(prev_grey,cur_grey,thres); - threshold(thres, thres, SENSITIVITY_VALUE, 255, THRESH_BINARY); - // Blur to eliminate noise - blur(thres, thres, Size(BLUR_SIZE, BLUR_SIZE)); - threshold(thres, thres, SENSITIVITY_VALUE, 255, THRESH_BINARY); + // threshold(thres, thres, SENSITIVITY_VALUE, 255, THRESH_BINARY); + // // Blur to eliminate noise + // blur(thres, thres, Size(BLUR_SIZE, BLUR_SIZE)); + // threshold(thres, thres, SENSITIVITY_VALUE, 255, THRESH_BINARY); + thres.copyTo(output); //notice how we use the '&' operator for objectDetected and output. This is because we wish //to take the values passed into the function and manipulate them, rather than just working with a copy.