一、编程环境:
OpenCV | 4.1.0 |
IDE | Visual Studio 2017 Enterprise (15.9.13) |
操作系统 | Windows 10 x64 中文专业版 (1903) |
二、示例代码:
#include<opencv2/opencv.hpp>
#include<iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
Mat src = imread("../images/test.jpg");
namedWindow("原图1", WINDOW_AUTOSIZE);
imshow("原图1", src);
int h = src.rows;
int w = src.cols;
// 获取ROI
int y = h / 2;
int x = w / 2;
Rect rect(x - 100, y - 100, 200, 200);
Mat roi = src(rect)