[OpenCV] Image Crop
OpenCV 에서 ROI 만큼 이미지를 Crop 시키는 방법은 아래와 같다. 간단한 방법인데, 잊지않으려고 정리한다. Python 구현 # x, y, w, h refers to the ROI for which the image is to be cropped. img = cv2.imread('test.jpg') cropped_img = img[y: y + h, x: x + w] C++ 구현 Mat img = cv::imread("test.jpg"); Rect bounds(0,0,img.cols,img.rows); Rect r(x,y,width,height); // partly outside Mat roi = img( r & bounds ); // cropped to fit image 위와 같이 구현하면 아..
2020.04.29