-1

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

Jeru Luke
  • 20,118
  • 13
  • 80
  • 87
Bigboytony
  • 123
  • 1
  • 9
  • 1) **don't** use obsolete C api 2) check [this](http://stackoverflow.com/a/35651948/5008845) – Miki Jan 22 '17 at 11:16
  • I'm using OpenCV in iOS and this is the latest version I have downloaded from the official website? – Bigboytony Jan 22 '17 at 23:38

1 Answers1

0

Turns out I need to call h_next for the next pointer for the contours!!

Bigboytony
  • 123
  • 1
  • 9