ROI functions in c and c++

asked 2016-05-23 08:41:15 -0500

essamzaky gravatar image

I have the following c code implementation and i want to port to c++ i want to use equivalent to cvSetImageROI ,cvResetImageROI

        cvMatchTemplate(pMainImg, pTempImg, res, CV_TM_CCOEFF_NORMED );

but i did not find the equivalent function in c++ implementation

is that the only way to create new matrix and path the ROI to the original Matrix such as

cv::Mat roiImg;
roiImg = img2(roi);

is there any other way to do my job directly inside the original matrix ?

edit retag flag offensive close merge delete



What's exactly your problem with the new ROI definition? As easy as doing

MatchTemplate(pMainImg(cvROIRect), pTempImg, res, CV_TM_CCOEFF_NORMED);
LorenaGdL gravatar imageLorenaGdL ( 2016-05-23 08:56:37 -0500 )edit

i want access the original matrix directly , MatchTemplate is sample of using ROI , i may smooth , rotate , or doing any action affact only ROI , finally i want to keep the changes done in the ROI in the original matrix

essamzaky gravatar imageessamzaky ( 2016-05-23 09:23:29 -0500 )edit

Setting a ROI does not create a new header/matrix, only a pointer to the original matrix. Therefore, every change in the ROI will be reflected in the original matrix as well. This tutorial makes this and other observations that might be interest for you

LorenaGdL gravatar imageLorenaGdL ( 2016-05-23 09:54:58 -0500 )edit

Thanks @LorenaGdL i will test and feed you back , also i found function in the Mat class to set and change the ROI the function called "adjustROI"

essamzaky gravatar imageessamzaky ( 2016-05-23 10:07:27 -0500 )edit

Thanks @LorenaGdL , The method working correctly , the changes in ROI is updated in the original image

essamzaky gravatar imageessamzaky ( 2016-11-10 08:23:16 -0500 )edit