|
|
|
@ -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.
|
|
|
|
|