title: Create Mat from vector<point2f>
body: <p>I am extremely new to computer vision and the opencv library.</p>
  
  <p>I've done some googling around to try to find how to make a new image from a vector of Point2fs and haven't found any examples that work. I've seen <a href="http://www.pieter-jan.com/node/5" rel="nofollow noreferrer"><code>vector&lt;Point&gt;</code> to <code>Mat</code></a> but when I use those examples I always get errors.</p>
  
  <p>I'm working from <a href="https://stackoverflow.com/questions/10533233/opencv-c-obj-c-advanced-square-detection">this</a> example and any help would be appreciated.</p>
  
  <p>Code: I pass in occludedSquare.</p>
  
  <pre><code>   resize(occludedSquare, occludedSquare, Size(0, 0), 0.5, 0.5);
  
     Mat occludedSquare8u;
     cvtColor(occludedSquare, occludedSquare8u, CV_BGR2GRAY);
  
     //convert to a binary image. pixel values greater than 200 turn to white. otherwize black
     Mat thresh;
     threshold(occludedSquare8u, thresh, 170.0, 255.0, THRESH_BINARY);
  
  
  
     GaussianBlur(thresh, thresh, Size(7, 7), 2.0, 2.0);
  
     //Do edge detection
     Mat edges;
     Canny(thresh, edges, 45.0, 160.0, 3);
  
     //Do straight line detection
     vector&lt;Vec2f&gt; lines;
     HoughLines( edges, lines, 1.5, CV_PI/180, 50, 0, 0 );
  
     //imshow("thresholded", edges);
  
  
     cout &lt;&lt; "Detected " &lt;&lt; lines.size() &lt;&lt; " lines." &lt;&lt; endl;
  
     // compute the intersection from the lines detected...
     vector&lt;Point2f&gt; intersections;
     for( size_t i = 0; i &lt; lines.size(); i++ )
     {
         for(size_t j = 0; j &lt; lines.size(); j++)
         {
             Vec2f line1 = lines[i];
             Vec2f line2 = lines[j];
             if(acceptLinePair(line1, line2, CV_PI / 32))
             {
                 Point2f intersection = computeIntersect(line1, line2);
                 intersections.push_back(intersection);
             }
         }
  
     }
  
     if(intersections.size() &gt; 0)
     {
         vector&lt;Point2f&gt;::iterator i;
         for(i = intersections.begin(); i != intersections.end(); ++i)
         {
             cout &lt;&lt; "Intersection is " &lt;&lt; i-&gt;x &lt;&lt; ", " &lt;&lt; i-&gt;y &lt;&lt; endl;
             circle(occludedSquare8u, *i, 1, Scalar(0, 255, 0), 3);
         }
     }
  
  //Make new matrix bounded by the intersections
  ...
  imshow("localized", localized);
  </code></pre>