OpenCV: How to create a mask in the shape of a polygon? : <p>I have a list of points which are the vertices of a polygon, like this:</p>

<pre><code>std::vector&lt;cv::Point2d&gt; polygonPoints;
</code></pre>

<p>I need to create a mask for the <code>goodFeaturesToTrack</code> function in openCV. For a rectangle, the easiest way to fill the desired area with <code>1</code>'s is like this:</p>

<pre><code>cv::Mat mask = cv::Mat::zeros(img.rows, img.cols, CV_8U);
mask(boundingbox) = 1;
</code></pre>

<p>How do I do this with a polygon that has 10+ edges? Is there an equivalent solution for n-sided polygons?</p>
