ROI with Quad or irregular shapes

Hi, i need to do a crop of an image using ROI , i would like to know if its possible to use a quad instead a rectangle o a irregular shape.

How can i use a quad?

thanks

ADAM

Hey Adam,

if you are working with ofxCvImages you can use the techniques from this thread:
http://forum.openframeworks.cc/t/simple-zoom-function-before-opencv’s-blob-detection/6151/4

if you are drawing an image or a texture, perhaps setting your own texture coordinates would work:

something like this, off the top of my head:

  
  
ofPoint pointsOnTheImage[4];  
ofPoint pointsOnTheScreen[4];  
//... fill out these ^ with points in 4 corners  
//like so:  
//  1---2  
//  |   |  
//  4---3  
//  
pointsOnTheImage[0] = ofPoint(0, 0);  
pointsOnTheScreen[0] = ofPoint(20, 20);  
...  
//then draw  
myImage.getTextureRef().bind();  
glBegin(GL_QUADS);  
for(int i = 0; i < 4; i++){  
    glTexCoord2f(pointsOnTheImage[i].x, pointsOnTheImage[i].y);  
    glVertex2f(pointsOnTheScreen[i].x,pointsOnTheScreen[i].y);  
}  
glEnd();  
myImage.getTextureRef().unbind();  
  
  

or if you need a perspective warp you can look at this thread for doing more “projection mapping” type of quad distortion:
http://forum.openframeworks.cc/t/little-projection-mapping-tool/5133/0

hope this helps