I have the following code fragment:
int count = (int)sizes.size();
CvSeq* seq = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvPoint2D32f), memStorage);
float line[4];
for (int i=0;i<count;i++) {
CvPoint2D32f p;
p.x = sizes[i];
p.y = depths[i];
cvSeqPush(seq, &p);
}
cvFitLine( seq, CV_DIST_L1, 1, 0.001, 0.001, line );
but this code throws an exception: Unsupported format or combination of formats (Input sequence must consist of 2d points or 3d points) in cvFitLine
Where’s the problem in my code? (I’m new in OpenCV)
Quoting from the documentation of
cvCreateSeqconcerning the first parameter:And looking at
cvFitLine:So you have to specify the type of points added to the seqeuence.
Should do the trick.