我想找到掌心。首先,我找到了轮廓并选择了最大面积轮廓。我使用了pointPolygonTest。我的代码和结果图像在下面,但我没有使用pointPolygonTest找到任何一点。有什么问题?
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 );