c++ - Return array of pointers (CvSeq pointers) -
i have function returns array of pointers, i.e. pointer pointing first element of array of cvseq. however, don't know if possible create array of cvseq.
the purpose of cvseq values of different images contours.
here code 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 = 0; < 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 error
error: no match ‘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 pointer cvseq structure, , trying store in array of cvseq, not array of pointers cvseq. i'd recommend use vector of cvseq pointers:
#include <vector> /* .... */ std::vector<cvseq*> contourpoly(size);
then able assign cvseq pointers successfully:
contourpoly[i]=cvapproxpoly(contour, sizeof(cvcontour), storage,cv_poly_approx_dp,1,1);
note that function's signature should be:
std::vector<cvseq*> get_template_contours(string templ[], int size)
Comments
Post a Comment