Merge branch 'master' of http://gitlab.rezometz.org/lhark/papillon
This commit is contained in:
commit
09a5c786f8
1 changed files with 12 additions and 16 deletions
|
@ -61,6 +61,10 @@ class Traite_image {
|
|||
cv::Mat next;
|
||||
resize(input, next, cv::Size(input.size().width/resize_f, input.size().height/resize_f));
|
||||
cv::Mat output;
|
||||
next.copyTo(output);
|
||||
|
||||
cv::cvtColor(next, next, cv::COLOR_BGR2GRAY);
|
||||
|
||||
if (first) {
|
||||
for (int i = 0; i < NB_FRAME_DROP; ++i) {
|
||||
prevs.push_back(next.clone());
|
||||
|
@ -90,11 +94,7 @@ class Traite_image {
|
|||
prevs.insert(prevs.begin(), next.clone());
|
||||
}
|
||||
|
||||
void stabiliseImg(cv::Mat prev, cv::Mat cur, cv::Mat &output){
|
||||
cv::Mat cur_grey, prev_grey;
|
||||
cv::cvtColor(cur, cur_grey, cv::COLOR_BGR2GRAY);
|
||||
cv::cvtColor(prev, prev_grey, cv::COLOR_BGR2GRAY);
|
||||
|
||||
void stabiliseImg(cv::Mat prev_grey, cv::Mat cur_grey, cv::Mat &output){
|
||||
// vector from prev to cur
|
||||
vector <cv::Point2f> prev_corner, cur_corner;
|
||||
vector <cv::Point2f> prev_corner2, cur_corner2;
|
||||
|
@ -119,14 +119,10 @@ class Traite_image {
|
|||
}
|
||||
T.copyTo(last_T);
|
||||
|
||||
cv::warpAffine(cur, output, T, cur.size(),cv::INTER_CUBIC|cv::WARP_INVERSE_MAP);
|
||||
cv::warpAffine(cur_grey, output, T, cur_grey.size(),cv::INTER_CUBIC|cv::WARP_INVERSE_MAP);
|
||||
}
|
||||
|
||||
void searchForMovement(cv::Mat prev, cv::Mat cur, cv::Mat &output, cv::Mat &out2){
|
||||
cv::Mat cur_grey, prev_grey;
|
||||
cur.copyTo(output);
|
||||
cv::cvtColor(prev, prev_grey, cv::COLOR_BGR2GRAY);
|
||||
cv::cvtColor(cur, cur_grey, cv::COLOR_BGR2GRAY);
|
||||
void searchForMovement(cv::Mat prev_grey, cv::Mat cur_grey, cv::Mat &output, cv::Mat &out2){
|
||||
cv::GaussianBlur(prev_grey, prev_grey, cv::Size(BLUR_SIZE,BLUR_SIZE), 3.0);
|
||||
cv::GaussianBlur(cur_grey, cur_grey, cv::Size(BLUR_SIZE,BLUR_SIZE), 3.0);
|
||||
|
||||
|
@ -165,17 +161,17 @@ class Traite_image {
|
|||
}
|
||||
|
||||
vector<cv::Rect> c_rects; // Connected rectangles
|
||||
cleanBBoxes(nc_rects, cur.size(), c_rects);
|
||||
cleanBBoxes(nc_rects, cur_grey.size(), c_rects);
|
||||
if (c_rects.size() > 0) {
|
||||
for (const auto& rect : c_rects)
|
||||
cv::rectangle(output, rect, cv::Scalar(0, 255, 0), 2);
|
||||
|
||||
cv::Rect objBRect = c_rects.front();
|
||||
papillon::BoundingBox bbox = papillon::BoundingBox();
|
||||
bbox.x = objBRect.x / (float)cur.size().width;
|
||||
bbox.y = objBRect.y / (float)cur.size().height;
|
||||
bbox.width = objBRect.width / (float)cur.size().width;
|
||||
bbox.height = objBRect.height / (float)cur.size().height;
|
||||
bbox.x = objBRect.x / (float)cur_grey.size().width;
|
||||
bbox.y = objBRect.y / (float)cur_grey.size().height;
|
||||
bbox.width = objBRect.width / (float)cur_grey.size().width;
|
||||
bbox.height = objBRect.height / (float)cur_grey.size().height;
|
||||
pub_cmd.publish(bbox);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue