cvSetImageROI ?

Hi , is there cvSetImageROI avaliable for openframeworks? i cant find it on ofxOpenCv , i also need to use commands as:

cvCreateImage , cvGetSize, cvCopy, cvResetImageROI.

Which options do i have? do i need to use the native opencv library or maybe there are other way of doing the same? thanks

Adam

there’s setROI and resetROI methods in all the ofxCVImages (grayscale, color and float)

for cvGetSize you can just do:

  
img.getWidth()*img.getHeight()*num_channels  

where num_channels is 1 for grayscale and 3 for color.

for copying you just need to do:

img1 = img2

and if you need something else that is not in ofxOpenCv you can access the internal opencv image by doing:

  
img.getCVImage()  

is there an example somewhere showing setROI with simple blob detection in use with oF 007? i read through a bunch of forum posts but still can’t quite get it. e.g. dealing with errors from different image sizes.

  
  
grayImage.setROI(0,0, ROI_w, ROI_h);  
...  
grayDiff.absDiff(grayBg, grayImage);  
  

gives [pre]OF_LOG_ERROR: in absDiff, images are different sizes[/pre]
because grayBg is now a different size. is there a way to have ROI set globally for all the CV images, or do you need to somehow set it for grayImage, grayBg, and grayDiff, not to mention deal with the offset that ROI introduces into blob coordinates?

also maybe someone could clarify the best way to use ROI at the earliest possible stage for maximum performance optimization (e.g. when getting pixels from vidGrabber)?

thx!