Updated by Andrey Pavlenko over 12 years ago
version: OpenCV 2.0, OpenCV 2.4.2
Platform: Windows XP
Compilor: VS 2008
<pre>
/* the piece of code */
if (m_pForeStorage)
cvReleaseMemStorage(&m_pForeStorage);
m_pForeStorage = cvCreateMemStorage(0);
CvSeq* contours = NULL;
IplImage * image_find = cvCloneImage(image);
int nOut = cvFindContours(image_find,m_pForeStorage,&contours, sizeof(CvContour),CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE);
int contour_points_number = 0;
CvSeq * obj_contour = NULL;
for( CvSeq* c=contours; c!=NULL; c=c->h_next )
{
printf("%d ", c->total);
if (contour_points_number < c->total)
{
contour_points_number = c->total;
obj_contour = c;
}
}
if (obj_contour == NULL)
return 1;
</pre>
Now /* ------- */
now the @obj_contour@ obj_contour is the contour that who gets most point number.
For the attatchment @white.png@, white.png, the output contour is expected: (0,0), (0, 1920), 1920)
(1920,1080), (1080, 0).
But the function return the error contour: (1,1),........
Platform: Windows XP
Compilor: VS 2008
<pre>
/* the piece of code */
if (m_pForeStorage)
cvReleaseMemStorage(&m_pForeStorage);
m_pForeStorage = cvCreateMemStorage(0);
CvSeq* contours = NULL;
IplImage * image_find = cvCloneImage(image);
int nOut = cvFindContours(image_find,m_pForeStorage,&contours, sizeof(CvContour),CV_RETR_LIST,CV_CHAIN_APPROX_SIMPLE);
int contour_points_number = 0;
CvSeq * obj_contour = NULL;
for( CvSeq* c=contours; c!=NULL; c=c->h_next )
{
printf("%d ", c->total);
if (contour_points_number < c->total)
{
contour_points_number = c->total;
obj_contour = c;
}
}
if (obj_contour == NULL)
return 1;
</pre>
Now /* ------- */
now the @obj_contour@ obj_contour is the contour that who gets most point number.
For the attatchment @white.png@, white.png, the output contour is expected: (0,0), (0, 1920), 1920)
(1920,1080), (1080, 0).
But the function return the error contour: (1,1),........