Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

@sweptica you should not adapt the code as it is since the other case had different requirements and features. You need to play with the original code which I point in the other thread plus to play with some customizations in the parameters. For example changing the following in the code:

... ... int N = 1; ... ... if( maxCosine < 0.3 && ratio <= 0.15) ... ... adaptiveThreshold(~gray, bin, 255, CV_ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 15, -5); imshow("bin", bin);

// find squares and draw them Mat inv; cvtColor(/~/bin, inv, CV_GRAY2BGR); imshow("inv", inv); vector<vector<point> > squares; findSquares(inv, squares);

I managed to get the following result:

@sweptica you should not adapt the code as it is since the other case had different requirements and features. You need to play with the original code which I point in the other thread plus to play with some customizations in the parameters. For example changing the following in the code:

...
...
int N = 1;
...
...
if( maxCosine < 0.3 && ratio <= 0.15)
...
...
adaptiveThreshold(~gray, bin, 255, CV_ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 15, -5);
imshow("bin", bin);

bin);

// find squares and draw them Mat inv; cvtColor(/~/bin, cvtColor(/*~*/bin, inv, CV_GRAY2BGR); imshow("inv", inv); vector<vector<point> vector<vector<Point> > squares; findSquares(inv, squares);

squares);

I managed to get the following result:

image description

I guess with some further process and customization you will get the desired result. Plus as @sturkmen said it would be nice to see some pictures with people on it, since the requirements I have the feeling that would be totally different.

@sweptica you should not adapt the code as it is since the other case had different requirements and features. You need to play with the original code which I point in the other thread plus to play with some customizations in the parameters. For example changing the following in the code:

...
...
int N = 1;
...
findContours(gray, contours, RETR_TREE, CHAIN_APPROX_SIMPLE);
...
if( maxCosine < 0.3 && ratio <= 0.15)
...
...
adaptiveThreshold(~gray, bin, 255, CV_ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 15, -5);
imshow("bin", bin);

// find squares and draw them
Mat inv;
cvtColor(/*~*/bin, inv, CV_GRAY2BGR);
imshow("inv", inv);
vector<vector<Point> > squares;
findSquares(inv, squares);

I managed to get the following result:

image description

I guess with some further process and customization you will get the desired result. Plus as @sturkmen said it would be nice to see some pictures with people on it, since the requirements I have the feeling that would be totally different.

@sweptica you should not adapt the code as it is since the other case had different requirements and features. You need to play with the original code which I point in the other thread plus to play with apply some customizations in the parameters. parameters regarding your use case. For example changing the following in the code:

...
...
int N = 1;
...
findContours(gray, contours, RETR_TREE, CHAIN_APPROX_SIMPLE);
...
if( maxCosine < 0.3 && ratio <= 0.15)
...
...
adaptiveThreshold(~gray, bin, 255, CV_ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 15, -5);
imshow("bin", bin);

// find squares and draw them
Mat inv;
cvtColor(/*~*/bin, inv, CV_GRAY2BGR);
imshow("inv", inv);
vector<vector<Point> > squares;
findSquares(inv, squares);

I managed to get the following result:

image description

I guess with some further process and customization you will get the desired result. Plus as @sturkmen said it would be nice to see some pictures with people on it, since the requirements I have the feeling that would be totally different.

@sweptica you should not adapt the code as it is since the other case had different requirements and features. You need to play with the original code which I point in the other thread plus to apply some customizations in the parameters regarding your use case. For example changing the following in the code:

...
...
int N = 1;
...
findContours(gray, contours, RETR_TREE, CHAIN_APPROX_SIMPLE);
...
if( maxCosine < 0.3 && ratio <= 0.15)
...
...
adaptiveThreshold(~gray, bin, 255, CV_ADAPTIVE_THRESH_MEAN_C, THRESH_BINARY, 15, -5);
imshow("bin", bin);

// find squares and draw them
Mat inv;
cvtColor(/*~*/bin, inv, CV_GRAY2BGR);
imshow("inv", inv);
vector<vector<Point> > squares;
findSquares(inv, squares);

I managed to get the following result:

image descriptionimage description

I guess with some further process and customization you will get the desired result. Plus as @sturkmen said it would be nice to see some pictures with people on it, since the requirements I have the feeling that would be totally different.