C++ 轮廓线和矩形OPENcv c+之间的交点+;
我用cv.rectangle绘制了一个矩形,并绘制了一个轮廓形状(来自FindContours) 矩形在两点处与整个轮廓相交。如何在矩形和轮廓轮廓之间找到这些交点 我可以将这两个图像相加并查找最大值,但我确实知道矩形顶点是如何存储的,因为我需要一个填充有一组点的线型向量C++ 轮廓线和矩形OPENcv c+之间的交点+;,c++,opencv,intersection,C++,Opencv,Intersection,我用cv.rectangle绘制了一个矩形,并绘制了一个轮廓形状(来自FindContours) 矩形在两点处与整个轮廓相交。如何在矩形和轮廓轮廓之间找到这些交点 我可以将这两个图像相加并查找最大值,但我确实知道矩形顶点是如何存储的,因为我需要一个填充有一组点的线型向量 谢谢如果您确定矩形仅在两个点穿过形状,您可以迭代通过轮廓点,并检查这些点是否在矩形边框中 std::vector<cv::Point> shape; // computed with FindContours cv:
谢谢如果您确定矩形仅在两个点穿过形状,您可以迭代通过轮廓点,并检查这些点是否在矩形边框中
std::vector<cv::Point> shape; // computed with FindContours
cv::Rect myRect; //whatever
const int NUMPOINTS = 2;
int found = 0;
for(std::vector<cv::Point>::iterator it = shape.begin(); it != shapes.end() && found < NUMPOINTS; ++it) {
if (it->y == myRect.y && it->x >= myRect.x && it->x < myRect.x + width)
// that point cross the top line of the rectangle
found++; // you might want to store the point
else if (// ... add the other checks here)
}
std::向量形状;//用FindContours计算
cv::Rect myRect//无论什么
常量int NUMPOINTS=2;
int=0;
for(std::vector::iterator it=shape.begin();it!=shapes.end()&&foundy==myRect.y&&it->x>=myRect.x&&it->x
是的……谢谢,这将只在两个地点进行访问……谢谢你的回答……我将在下周度假回来后试一试