Simple Zoom function before openCV's blob detection?

Hello again!
I now have a setup which consists of a DLP proyector with a webcam placed directly on top, and it works ok, but the only problem I have is the webcam captures a bigger area than the one that is projected.

I tried inventing really complicated methods and plan on buyin a zoom lens or something, but I actually arrived to the conclusion that all I need is a “digital zoom” before openCV’s blob detection.

Does a function like this exist, or is there a better way to implement this?
I have no distortion in the viewing angle.
thanks yet again! =)

hey there,

I think the simplest way to do it is to use the setROI method on ofxCvImage to set the rectangle of interest and crop out the rest.

If you need more than rectangular crop, you can look into quad-warping as a more advanced way to crop out the area of interest for tracking.

The OF OpenCV image has a “warp into me” function that allows you crop out parts of the image based on a 4 points quad warp. it’s used like this:

  
  
ofPoint sourcePoints[4];  
ofPoint destPoints[4];  
//set the source to the bounds of the image, set the dest to the points where you want to crop out  
warpedImage.warpIntoMe(originalImage, sourcePoints, destPoints);  
  

There is an example of this working with a GUI in the openTSPS app: (http://opentsps.com). The incoming image can be changed by moving the 4 point handles around to remove parts of the image edges.

hope this helps,

Nice!..
Will try this out later =D
Thank you for the very quick response obviousjim!

obviousjim:
Does ROI rescale the smaller area reactangle of the image back to 320x240 like warpIntoMe() does?
I think I got warpIntoMe() but I get a weird, half zoomed image on top, half MEGAzoomed on bottom, but at least it is progress :smiley:
I would still greatly appreciate your input. =D

Here are the ofPoints I used. Zoom was set to 0 on setup();

  
        ofPoint sourcePoints[4];  
            sourcePoints[0] = ofPoint(    zoom,     zoom);  
            sourcePoints[1] = ofPoint(320-zoom,     zoom);  
            sourcePoints[2] = ofPoint(320-zoom, 240-zoom);  
            sourcePoints[3] = ofPoint(    zoom, 240-zoom);  
        ofPoint destPoints[4];  
            destPoints[0]   = ofPoint(       0,        0);  
            destPoints[1]   = ofPoint(     320,        0);  
            destPoints[2]   = ofPoint(     320,      240);  
            destPoints[3]   = ofPoint(       0,      240);  
        colorImg.warpIntoMe(colorImg, sourcePoints, destPoints);  

Also, setROI worked great too!
I do have one question about it, does one actually have to resetROI() every time one needs to set it again? I had to do it because it was setting only once in the beginning and it didnt work for live video this way. <–nevermind, works now, I don’t know why.
:stuck_out_tongue:
Now I have a huge setROI smile… so a million thanks for your input.

hey there,

Not sure why the warp into me isn’t working – i always have to mess around with it a bit before it works. If you still need it perhaps try switching some of the parameters around.

And check out the implementation in OpenTSPS if you’re curious =)

glad you’re on your way though!

Yes well, I am checking the source openTSPS source you mentioned. Are you refering to the ofxOpenCVExtensions? more specifically to the ofxCvCoordWarping .h and ccp?

Hey this is great!!! I needed blob tracking like 2 weeks ago xD!
Now I have so many reasons to get into the OpenSPS!

:o so many thanks to give!

Hello guys, I’m just a beginner in openCV. I am trying to zoom a small area of an image. I really don’t know how to do it. I will be appreciate any help from you guys. Here an example of an image. It shows exactly what I want to do.

Thanks in advance for your help.