|
|
|
@ -16,9 +16,10 @@ class Traite_image { |
|
|
|
const static int BLUR_Size = 9; |
|
|
|
const static int CLOSE_SIZE = 20; |
|
|
|
const static int ERODE_SIZE = 2; |
|
|
|
const static int NB_FRAME_DROP = 2; |
|
|
|
|
|
|
|
|
|
|
|
cv::Mat prev; |
|
|
|
vector<cv::Mat> prevs; |
|
|
|
cv::Mat last_T; |
|
|
|
bool first = true; |
|
|
|
int resize_f = 1; |
|
|
|
@ -63,13 +64,15 @@ class Traite_image { |
|
|
|
cv::Mat output;// = input.clone(); // (input.rows, input.cols, CV_32FC2);
|
|
|
|
//ROS_INFO("got input");
|
|
|
|
if (first) { |
|
|
|
prev = next.clone(); |
|
|
|
for (int i = 0; i < NB_FRAME_DROP; ++i) { |
|
|
|
prevs.push_back(next.clone()); |
|
|
|
} |
|
|
|
first = false; |
|
|
|
ROS_INFO("first done"); |
|
|
|
} |
|
|
|
|
|
|
|
cv::Mat next_stab; |
|
|
|
stabiliseImg(prev, next, next_stab); |
|
|
|
stabiliseImg(prevs.back(), next, next_stab); |
|
|
|
int crop_ratio = 6; |
|
|
|
float crop_x = next_stab.size().width/crop_ratio; |
|
|
|
float crop_y = next_stab.size().height/crop_ratio; |
|
|
|
@ -77,7 +80,7 @@ class Traite_image { |
|
|
|
float crop_h = next_stab.size().height*(1-2.0/crop_ratio); |
|
|
|
cv::Rect myROI(crop_x, crop_y, crop_w, crop_h); |
|
|
|
cv::Mat next_stab_cropped = next_stab(myROI); |
|
|
|
cv::Mat prev_cropped = prev(myROI); |
|
|
|
cv::Mat prev_cropped = prevs.back()(myROI); |
|
|
|
cv::Mat closed_thres; |
|
|
|
searchForMovement(prev_cropped, next_stab_cropped, output, closed_thres); |
|
|
|
|
|
|
|
@ -90,7 +93,8 @@ class Traite_image { |
|
|
|
|
|
|
|
//ROS_INFO("pub");
|
|
|
|
|
|
|
|
prev = next.clone(); |
|
|
|
prevs.pop_back(); |
|
|
|
prevs.insert(prevs.begin(), next.clone()); |
|
|
|
} |
|
|
|
|
|
|
|
//int to string helper function
|
|
|
|
@ -163,7 +167,6 @@ class Traite_image { |
|
|
|
cv::erode(thres, thres, element ); |
|
|
|
|
|
|
|
|
|
|
|
thres.copyTo(out2); |
|
|
|
|
|
|
|
cv::threshold(thres, thres, SENSITIVITY_VALUE, 255, cv::THRESH_BINARY); |
|
|
|
|
|
|
|
@ -172,6 +175,7 @@ class Traite_image { |
|
|
|
cv::morphologyEx( thres, closed_thres, cv::MORPH_CLOSE, structuringElement ); |
|
|
|
// dilated_thres.copyTo(output);
|
|
|
|
|
|
|
|
closed_thres.copyTo(out2); |
|
|
|
|
|
|
|
//closed_thres.copyTo(output);
|
|
|
|
|
|
|
|
|