Trying to use OpenCV in xcode to detect some ellipse of an image:
CvMemStorage *storage2 = cvCreateMemStorage(0);
CvSeq *contours = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvPoint), storage2);
IplImage *th = cvCreateImage(imgSize, 8, 1);
cvThreshold(mask, th, 0.1, 255, CV_THRESH_BINARY_INV );
cvFindContours(th, storage2, &contours, sizeof(CvContour), CV_RETR_LIST, CV_CHAIN_APPROX_NONE, cvPoint(0, 0));
cvDrawContours(th, contours, CV_RGB(0,255,0), CV_RGB(0,0,255),
2, 3, 8, cvPoint(0, 0));
cv::Vector<cv::RotatedRect> minRect(contours->total);
cv::Vector<cv::RotatedRect> minEllipse(contours->total);
for( int i = 0; i < contours->total ; i++ )
{
minRect[i] = cvMinAreaRect2(&contours[i]);
}
I'm using the example provided in the OpenCV documentation.
When I try to run this code, I get the error:
error: (-5) Input array is not a valid matrix in function cvPointSeqFromMat
For the line:
minRect[i] = cvMinAreaRect2(&contours[i]);
I'm fairly new to opencv to will appreciate any help!!
Thanks