Quantcast
Channel: beginners - openFrameworks
Viewing all articles
Browse latest Browse all 4929

Get subSection or ROI from a bigger section

$
0
0

@antocreo wrote:

Hi
I am trying to get a portion, a subsection from a texture (in specific from video source/webcam).
I see there is drawSubsection()method which draws the portion I want, but how do I translate the same portion as texture to bind()on to a ofMesh?

Ultimately what I want to achieve is having portions of videos delimited by a mesh area. That would work exactly like using a mesh as a mask. (which is my next test)

Anyway, so far, this is what I have tried:

in .h

ofxCvColorImage testImage;

in cpp

setup(){
//leRect is a getboundingBox() of the area I need - it is a dynamic value
    testImage.allocate(leRect.width, leRect.height); 
}

update(){
 testImage = cam.getPixels();
 testImage.setROI(feature.getBoundingBox());
}

draw(){

        testImage.getTextureReference().bind();
        mesh.draw();
        testImage.getTextureReference().unbind();
}

I get these errors like the allocation doesn't work...

[ error ] ofxCvImage: setROI(): image not allocated
[ error ] ofxCvColorImage: setFromPixels(): width and height are zero

is there anything/anyone that can help please?

Cheers

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929