Note that there are some explanatory texts on larger screens.

plurals
  1. POcreate a customized sequence of CvPoint in OpenCv
    primarykey
    data
    text
    <p>I want to use cvDrawContours to draw my own contours created from CvSeq (normally, contours are retured from other functions of OpenCV). This is my solution but it does not work :(</p> <pre><code>IplImage* g_gray = NULL; CvMemStorage *memStorage = cvCreateMemStorage(0); CvSeq* seq = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvPoint)*4, memStorage); CvPoint points[4]; points[0].x = 10; points[0].y = 10; points[1].x = 1; points[1].y = 1; points[2].x = 20; points[2].y = 50; points[3].x = 10; points[3].y = 10; cvSeqPush(seq, &amp;points); g_gray = cvCreateImage( cvSize(300,300), 8, 1 ); cvNamedWindow( "MyContour", CV_WINDOW_AUTOSIZE ); cvDrawContours( g_gray, seq, cvScalarAll(100), cvScalarAll(255), 0, 3); cvShowImage( "MyContour", g_gray ); cvWaitKey(0); cvReleaseImage( &amp;g_gray ); cvDestroyWindow("MyContour"); return 0; </code></pre> <p>I picked the method to create a customized contour sequence from CvPoint from this post <a href="https://stackoverflow.com/questions/6984994/opencv-sequences-how-to-create-a-sequence-of-point-pairs">OpenCV sequences -- how to create a sequence of point pairs?</a></p> <p>FOr the second try, I did it with Cpp OpenCV: </p> <pre><code>vector&lt;vector&lt;Point2i&gt;&gt; contours; Point2i P; P.x = 0; P.y = 0; contours.push_back(P); P.x = 50; P.y = 10; contours.push_back(P); P.x = 20; P.y = 100; contours.push_back(P); Mat img = imread(file, 1); drawContours(img, contours, -1, CV_RGB(0,0,255), 5, 8); </code></pre> <p>Perhaps I used the data incorrectly. The compiler alerts errors &amp; does not allow push_back points to vectors like that. Why??</p> <p>The error is like this: Error 2 error C2664: 'std::vector&lt;_Ty>::push_back' : cannot convert parameter 1 from 'cv::Point2i' to 'const std::vector&lt;_Ty> &amp;'</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload