Sometimes we need to get an area of interest ROI from an image (region of interesting) and crop the ROI region into small images as input for post-processing. With the Cvsetimageroi () function, you can easily get it done.
First, Cvsetimageroi function
function
Sets the ROI of an image based on a given rectangle (area of interest, region of interesting)
formatvoid Cvsetimageroi (iplimage*Image, Cvrectrect);ParametersImageImage header, pending imagerect ROIRectangular
Example
Cvsetimageroi (Image,cvrect (100,100,356,156)), (100,100) represents the upper-left coordinate of the ROI region, and 356,156 represents the length-width of the ROI region, respectively.
Description
After executing Cvsetimageroi (), the image is displayed only as part of the ROI ID, which changes the pointer image, but it still retains the information of the original image, in the execution of this sentence cvresetimageroi (image); Image indicates the original picture information.
Second, the Code
#include <iostream> #include
Iii. Results of operation
OPENCV Study Notes (8): capturing/cropping images with Cvsetimageroi