我想找到手掌的中心。首先,我找到轮廓并选择最大面积轮廓。我使用了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 );