I would like to have a function that returns something like an array of pointers, i.e. a pointer pointing to the first element of an array of CvSeq. However, I don’t know if it is possible to create an array of CvSeq.
The purpose of this is to get the CvSeq Values of different images contours.
Here is the code that I have:
CvSeq* get_template_contours(string templ[], int SIZE){
IplImage *templ_img;
CvSeq *contour = NULL;
CvSeq *contourPoly = new CvSeq[SIZE];
CvMemStorage* storage = cvCreateMemStorage(0);
for(int i = 0; i < SIZE; i++){
templ_img = cvLoadImage(templ[i].c_str(), 0);
cvFindContours(templ_img, storage, &contour, sizeof(CvContour),
CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, cvPoint(0, 0));
contourPoly[i]=cvApproxPoly(contour, sizeof(CvContour), storage,CV_POLY_APPROX_DP,1,1);
}
cvReleaseImage(&templ_img);
cvClearMemStorage(storage);
cvClearSeq(contour);
return contourPoly;
}
But I get this error
error: no match for ‘operator=’ in ‘*(contourPoly + ((long unsigned int)(((long unsigned int)i) * 96ul))) = cvApproxPoly(((const void*)contour), 128, storage, 0, 1.0e+0, 1)’
/usr/local/include/opencv2/core/types_c.h:1316:1: note: candidate is: CvSeq& CvSeq::operator=(const CvSeq&)
Thanks in advance
cvApproxPoly returns a pointer to a CvSeq structure, and you are trying to store it in an array of CvSeq, not an array of pointers to CvSeq. I’d recommend you to use a vector of CvSeq pointers:
Then you will be able to assign the CvSeq pointers successfully:
Note that that function’s signature should now be: