Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

pointPolygonTest in OpenCV

I want to find center of palm. Firstly,I found contours and select max area contour. And I used pointPolygonTest. My code and result image are below, but I didn't find any point using pointPolygonTest. What is the problem?

`

     double dist, maxdist = -1;
     Point center;

    for(int i = 0; i< drawing.cols; i += 10) {
    for(int j = 0; j< drawing.rows; j += 10) {

        dist = pointPolygonTest(contours[maxAreaIndex], Point(i,j),true);
        cout << "   dist " << dist << endl;
        if(dist > maxdist)
        {
            maxdist = dist;
            center = cv::Point(i,j);
        }
    }
}
cout << "maxdist = " << maxdist << endl;
circle(drawing, center, maxdist, cv::Scalar(220,75,20),1,CV_AA);
/// Show in a window
namedWindow( "Contours", CV_WINDOW_AUTOSIZE );
imshow( "Contours", drawing );`

The drawing image is below image description