简体   繁体   中英

How to determine a region of interest and then crop an image using OpenCV c++

I have a sample image as below. I would like to make the square my Region of Interest and then crop out that part (square) and create a new image with it. I will be working with different images so the square won't always be at the same location in all images. So I will need to somehow detect the edges of the square.

I can not post pictures because I have 10 reputations

help me please??

Thank you very much

cvSetImageROI(currentImage,yourSquare);
CvSize size = cvSize(width, height);
IplImage * newImage = cvCreateImage(size,8,3);
cvResize(currentImage,newImage,CV_INTER_AREA);

First you must set your ROI with cvSetImageROI(IplImage*,CvRect). After that you create your new image with the desired width and height. Finally you can copy your old image to the new one. The new image will contain your desired ROI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM