opencv 剪切图片

#include "pch.h"
#include <iostream>
#include <highgui.hpp>
#include <highgui/highgui_c.h>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
//#include <opencv2/core/core.hpp>
//#include <opencv2/highgui/highgui.hpp>
//#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;


//const char* path = "C:\\Users\\fengl\\Desktop\\素材.avi";
const char* path = "C:\\Users\\fengl\\Desktop\\p1.jpg";

int main()
{

cv::Mat tomato = cv::imread(path, 1);

Rect rec(tomato.cols / 4, tomato.rows / 4, tomato.cols / 2, tomato.cols / 2);

Mat img = tomato(rec);


cv::imshow("test", tomato);

cv::waitKey(1000);

cv::imshow("test", img);

cv::waitKey(1000);
return 0;
}

扫描二维码关注公众号,回复: 4278333 查看本文章

猜你喜欢

转载自www.cnblogs.com/zfq572815535/p/10034461.html