1. 程式人生 > >opencv 剪下圖片

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;
}