boundingRect()函数的使用方法 (通俗易懂)
boundingRect()函数的使用方法
Calculates the up-right bounding rectangle of a point set.
C++:RectboundingRect(InputArraypoints)
Parameters: points– Input 2D point set, stored instd::vectororMat.
注意:(boundingRect读入的参数必须是vector或者Mat点集)
使用例程:
for( size_t k = 0; k < contours.size(); k++ )
{
Rect ret1=boundingRect(Mat(contours[k]));//计算右上点集的边界矩形
avgX = (ret1.x + ret1.x + ret1.width)/2; //运动物体的矩形的中点X位置
avgY = (ret1.y + ret1.y + ret1.height)/2;//运动物体的矩形的中点Y位置
cout<<"x:"<<avgX<<"y:"<<avgY<<endl;
}
由上可以看出,boundingRect()的用法
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。