Correct way of cropping an IplImage

asked 2013-03-01 01:50:09 -0500

manmedia gravatar image

updated 2018-01-13 09:45:20 -0500

I have a set of mask images that I need to use everytime I recognise a previously-known scene on my camera. All the mask images are in IplImage format. There will be instances where, for example, the camera has panned to a slightly different but nearby location. this means that if I do a template matching somewhere in the middle of the current scene, I will be able to recognise the scene with some amount of shift of the template in this scene. All I need to do is use those shifts to adjust the mask image ROIs so that they can be overlayed appropriately based on the template-matching. I know that there are functions such as:

cvSetImageROI(Iplimage* img, CvRect roi)
cvResetImageROI(IplImage* img);

Which I can use to set crop/uncrop my image. However, it didn't work for me quit the way I expected. I would really appreciate if someone could suggest an alternative or what I am doing wrong, or even what I haven't thought of!

edit retag flag offensive close merge delete