ROI(region of interest),也就是感兴趣区域。当我们想要只是关注图片的一部分的时候,就可以使用ROI
有两种用法:
一cv::Rect
cv::Rect 表示一个矩形区域,是一个类
常用的构造函数如下:
Rect_ (_Tp _x, _Tp _y, _Tp _width, _Tp _height) //前两个参数表示的是所选区域的左上角的坐标值x和y, 后两个参数表示所选区域的宽和高。
它还有几个方法:
//左上角的点坐标
Point_<_Tp> tl() const;
//右下角的点的坐标
Point_<_Tp> br() const;
//尺寸
Size_<_Tp> size() const;
//矩形的面积
_Tp area() const;
当我们向输出的时候,可以这样使用:
Rect myrectangle=Rect(30,30,100,100);
//面积
cout<<"the area is : "<<myrectangle.area()<<endl;
//左上角坐标
cout<<"the top left point is : "<<myrectangle.tl()<<endl;
//右下角坐标
cout<<"the bottom right point is : "<<myrectangle.br()<<endl;
//输出宽
cout<<"the width is : "<