only show one box
This commit is contained in:
parent
bdaba2e13c
commit
28435564d6
1 changed files with 10 additions and 7 deletions
|
@ -12,8 +12,9 @@ using namespace std;
|
||||||
|
|
||||||
class Traite_image {
|
class Traite_image {
|
||||||
public:
|
public:
|
||||||
const static int SENSITIVITY_VALUE = 40;
|
const static int SENSITIVITY_VALUE = 30;
|
||||||
const static int BLUR_Size = 15;
|
const static int BLUR_Size = 15;
|
||||||
|
const static int CLOSE_SIZE = 50;
|
||||||
|
|
||||||
|
|
||||||
cv::Mat prev;
|
cv::Mat prev;
|
||||||
|
@ -161,7 +162,7 @@ class Traite_image {
|
||||||
//~ dilated_thres.copyTo(output);
|
//~ dilated_thres.copyTo(output);
|
||||||
|
|
||||||
cv::Mat closed_thres;
|
cv::Mat closed_thres;
|
||||||
cv::Mat structuringElement = getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(40, 40));
|
cv::Mat structuringElement = getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(CLOSE_SIZE, CLOSE_SIZE));
|
||||||
cv::morphologyEx( thres, closed_thres, cv::MORPH_CLOSE, structuringElement );
|
cv::morphologyEx( thres, closed_thres, cv::MORPH_CLOSE, structuringElement );
|
||||||
|
|
||||||
//closed_thres.copyTo(output);
|
//closed_thres.copyTo(output);
|
||||||
|
@ -190,11 +191,13 @@ class Traite_image {
|
||||||
//largestContourVec.push_back(contours.at(contours.size()-1));
|
//largestContourVec.push_back(contours.at(contours.size()-1));
|
||||||
//make a bounding rectangle around the largest contour then find its centroid
|
//make a bounding rectangle around the largest contour then find its centroid
|
||||||
//this will be the object's final esticv::Mated position.
|
//this will be the object's final esticv::Mated position.
|
||||||
for(int i=0; i<contours.size();i++)
|
//~ for(int i=0; i<contours.size();i++)
|
||||||
{
|
//~ {
|
||||||
objectBoundingRectangle = cv::boundingRect(contours[i]);
|
//~ objectBoundingRectangle = cv::boundingRect(contours[i]);
|
||||||
cv::rectangle(output, objectBoundingRectangle, cv::Scalar(0, 255, 0), 2);
|
//~ cv::rectangle(output, objectBoundingRectangle, cv::Scalar(0, 255, 0), 2);
|
||||||
}
|
//~ }
|
||||||
|
objectBoundingRectangle = cv::boundingRect(contours.at(contours.size()-1));
|
||||||
|
cv::rectangle(output, objectBoundingRectangle, cv::Scalar(0, 255, 0), 2);
|
||||||
}
|
}
|
||||||
//make some temp x and y variables so we dont have to type out so much
|
//make some temp x and y variables so we dont have to type out so much
|
||||||
//~ int x = objectBoundingRectangle.x;
|
//~ int x = objectBoundingRectangle.x;
|
||||||
|
|
Loading…
Reference in a new issue