Ask Your Question

tenkeason's profile - activity

2020-02-03 20:55:08 -0600 received badge  Popular Question (source)
2019-09-08 12:03:18 -0600 received badge  Famous Question (source)
2018-05-03 21:01:53 -0600 received badge  Notable Question (source)
2017-10-26 02:30:46 -0600 received badge  Popular Question (source)
2016-01-20 10:42:57 -0600 commented question Only draw Rectangle when largest than the minimum size

May i know is that posible if i want change the minimum size at line 279 in main.cpp, if posible what should i use here? can i use if(width>100 && height>150) replace with this code

if(area>MIN_OBJECT_AREA)

2016-01-20 07:27:29 -0600 commented question Only draw Rectangle when largest than the minimum size

ok its works, thanks for help!

2016-01-20 07:19:55 -0600 commented question Possible if only draw a Rectangle at the front object?

OK thanks.

2016-01-20 06:45:35 -0600 received badge  Student (source)
2016-01-20 05:41:42 -0600 commented question Only draw Rectangle when largest than the minimum size

if (minRect.width() > 100 && minRect.height() > 150) {rectangle( frame, minRect, Scalar( 0, 0, 255 ),2 );}

it got error there :expression preceding parentheses of apparent call must have (point-to-) function type

2016-01-20 05:24:23 -0600 commented question Only draw Rectangle when largest than the minimum size

May i know if my minimum size is 100*150, how to change in the desiredValue?

2016-01-20 05:16:56 -0600 asked a question Possible if only draw a Rectangle at the front object?

May i know is that possible if we draw a rectangle at the front object show as below picture?

This is the Real Situation

image description

This is what the robot will get from webcam when tracking the color

image description

This what was i get now (draw a rectangles at biggest object)

image description

This is what i want to do

image description

int largestIndex = 0;
int largestContour = 0;
int secondLargestIndex = 0;
int secondLargestContour = 0;

vector<vector<Point> > contours;
vector<Vec4i> hierarchy;

//find contours
findContours(thresh, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE);

/// Find the convex hull object for each contour
vector<vector<Point> >hull(contours.size());
vector<vector<int> >inthull(contours.size());
vector<vector<Vec4i> >defects(contours.size());

for (int i = 0; i < contours.size(); i++)
{
    convexHull(Mat(contours[i]), hull[i], false);
    convexHull(Mat(contours[i]),inthull[i], false);
    if (inthull[i].size()>3)
    convexityDefects(contours[i], inthull[i], defects[i]);
}

//find 2 largest contour
for( int i = 0; i< contours.size(); i++ )
{
    if(contours[i].size() > largestContour)
    {
        secondLargestContour = largestContour;
        secondLargestIndex = largestIndex;
        largestContour = contours[i].size();
        largestIndex = i;
    }
    else if(contours[i].size() > secondLargestContour)
    {
        secondLargestContour = contours[i].size();
        secondLargestIndex = i;
    }
}
    //show contours of 2 biggest and hull as well
if(contours.size()>0)
    {
    //check for contouraea function if error occur
    //draw the 2 largest contour using previously stored index.
    //drawContours(frame, contours, largestIndex, CV_RGB(0,255,0), 2, 8, hierarchy);
    //drawContours(frame, contours, secondLargestIndex, CV_RGB(0,255,0), 2, 8, hierarchy);

    //draw rectangle at specified obstacle
    Rect minRect = boundingRect( Mat(contours[ largestIndex ]) );
    rectangle( frame, minRect, Scalar( 0, 0, 255 ),2 );
    minRect = boundingRect( Mat(contours[ secondLargestIndex ]) );
    rectangle( frame, minRect, Scalar( 0, 0, 255 ),2 );}

This code link : http://paste.ofcode.org/33beiUcpvTuPd...

2016-01-19 23:34:36 -0600 commented question Only draw Rectangle when largest than the minimum size

ok now at "original image" window (right picture), it will only draw rectangles on 2 largest object(black color) was been detect. now i need add some function that is it will draw rectangle on object if only the object was largest than the minimum size (eg, 100*300)

2016-01-19 22:20:45 -0600 asked a question Only draw Rectangle when largest than the minimum size

May i know how to draw the rectangle at the object when the object is largest than the minimum size(left window picture), i already got to draw the rectangle when it was largest than the minimum size(right window picture) but i confused about this "Original Image" window(left window picture)

This is My Picture

main.cpp : http://paste.ofcode.org/33beiUcpvTuPd...

Color.cpp : http://paste.ofcode.org/xbRhjeB3fnR2i...

Color.h : http://paste.ofcode.org/zeu4brWENxvtZ...

2016-01-15 22:38:12 -0600 commented answer How to draw a rectangle contours only if largest than specific size

oh i see, thanks for reminding.

2016-01-15 21:59:40 -0600 commented answer How to draw a rectangle contours only if largest than specific size

May i know what means the width and height aren't the same numbers used here?

2016-01-15 20:43:56 -0600 commented answer How to draw a rectangle contours only if largest than specific size

this is my code, is that true?

http://paste.ofcode.org/w3cZgTE7kkyM9...

2016-01-15 09:18:54 -0600 commented answer How to draw a rectangle contours only if largest than specific size

Sorry, i'm just start learn opencv few month and i still confuse about the code below. Would you help me explain about the below code please?

Rect minRect = boundingRect( Mat(contours[ largestIndex ]) );

2016-01-14 20:04:50 -0600 marked best answer How to draw a rectangle contours only if largest than specific size

This is i get just now, it will detect and draw rectangle at the 2 largest object, the problem now is it will draw a rectangle when the object is small than the size i want but is the first/second largest in the camera.

Requirement : It will draw rectangles at the 1st & 2nd largest object only if when the object largest than 200 * 300 (frame size : 640*480). If the 1st & 2nd object is small than the minimum size so it will not be draw.

may i know what should i write in condition if?

if ( what should i type here )

{

112 ... 132 line

}

The codes are in below link

image description

main,cpp : http://paste.ofcode.org/36TG5U8WTViFN...

Color.h : http://paste.ofcode.org/WDy2xPwYnaZxL...

Color.cpp : http://paste.ofcode.org/c4yeiyC2tv2t8...

2016-01-14 19:30:12 -0600 commented answer How to draw a rectangle contours only if largest than specific size

may i know what should i write in condition if?

if ( what should i type here )

{

112 ... 132

}