Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed inversion of ymin and ymax in detection models output #690

Merged
merged 1 commit into from
Feb 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/backends/caffe/caffelib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2557,9 +2557,9 @@ namespace dd
cats.push_back(this->_mlmodel.get_hcorresp(detection[1]));
APIData ad_bbox;
ad_bbox.add("xmin",static_cast<double>(detection[3]*(cols-1)));
ad_bbox.add("ymax",static_cast<double>(detection[4]*(rows-1)));
ad_bbox.add("ymin",static_cast<double>(detection[4]*(rows-1)));
ad_bbox.add("xmax",static_cast<double>(detection[5]*(cols-1)));
ad_bbox.add("ymin",static_cast<double>(detection[6]*(rows-1)));
ad_bbox.add("ymax",static_cast<double>(detection[6]*(rows-1)));
bboxes.push_back(ad_bbox);
}
if (leave)
Expand Down
4 changes: 2 additions & 2 deletions src/backends/ncnn/ncnnlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ namespace dd

APIData ad_bbox;
ad_bbox.add("xmin",static_cast<double>(values[2] * inputc.width()));
ad_bbox.add("ymax",static_cast<double>(values[3] * inputc.height()));
ad_bbox.add("ymin",static_cast<double>(values[3] * inputc.height()));
ad_bbox.add("xmax",static_cast<double>(values[4] * inputc.width()));
ad_bbox.add("ymin",static_cast<double>(values[5] * inputc.height()));
ad_bbox.add("ymax",static_cast<double>(values[5] * inputc.height()));
bboxes.push_back(ad_bbox);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/backends/tensorrt/tensorrtlib.cc
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,9 @@ namespace dd
cats.push_back(this->_mlmodel.get_hcorresp(detection[1]));
APIData ad_bbox;
ad_bbox.add("xmin",static_cast<double>(detection[3]*(cols-1)));
ad_bbox.add("ymax",static_cast<double>(detection[4]*(rows-1)));
ad_bbox.add("ymin",static_cast<double>(detection[4]*(rows-1)));
ad_bbox.add("xmax",static_cast<double>(detection[5]*(cols-1)));
ad_bbox.add("ymin",static_cast<double>(detection[6]*(rows-1)));
ad_bbox.add("ymax",static_cast<double>(detection[6]*(rows-1)));
bboxes.push_back(ad_bbox);
}
if (leave)
Expand Down
8 changes: 4 additions & 4 deletions src/chain_actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ namespace dd

double cxmin = std::max(0.0,xmin-deltax);
double cxmax = std::min(static_cast<double>(img.cols),xmax+deltax);
double cymax = std::max(0.0,ymax-deltay);
double cymin = std::min(static_cast<double>(img.rows),ymin+deltay);
double cymin = std::max(0.0,ymin-deltay);
double cymax = std::min(static_cast<double>(img.rows),ymax+deltay);

if (cxmin > img.cols || cymax > img.rows || cxmax < 0 || cymin < 0)
if (cxmin > img.cols || cymin > img.rows || cxmax < 0 || cymax < 0)
{
_chain_logger->warn("bounding box does not intersect image, skipping crop action");
continue;
}

cv::Rect roi(cxmin,cymax,cxmax-cxmin,cymin-cymax);
cv::Rect roi(cxmin,cymax,cxmax-cxmin,cymax-cymin);
cv::Mat cropped_img = img(roi);

// adding bbox id
Expand Down