直接上代码
cv::Mat img= cv::imread("1.jpg");
cv::Rect rect(50,20, 200, 50);
cv::Mat ROI = img(rect);
- 其中:Rect的函数定义为: Rect(_Tp _x, _Tp _y, _Tp _width, _Tp _height);
_Tp _x:表示矩形左上角顶点的x坐标; _Tp _y:表示矩形左上角顶点的y坐标;
_Tp _width:表示矩形框的宽度 ; _Tp _height:表示矩形框的高度