Quantcast
Channel: openFrameworks - Latest posts
Viewing all articles
Browse latest Browse all 40524

ofPlanePrimitive not mapping textures from ofImage object

$
0
0

I have an ofImage object whose texture I map onto an ofPlanePrimitive. For the ofImage object, at compile time, I don't give it an actual image to display, simply allocate the space. Below is the setup code:

objectImage.allocate(ofGetWidth(), ofGetHeight(), OF_IMAGE_COLOR);
plane.set(objectImage.getWidth(), objectImage.getHeight(), COLUMN_RESOLUTION, ROW_RESOLUTION);
plane.mapTexCoordsFromTexture(objectImage.getTexture());

where objectImage is the ofImage and plane is the ofPlanePrimitive.

However, when drawn to the screen, The plane is not drawing the image texture.
The code to set the image and draw is as below.

void RecognizedObject::updateImageWithObjectRect(cv::Rect &objectRect, cv::Mat &camMat) {
    this->objectRect = objectRect;
    this->camMat = camMat;
    Mat croppedCamMat(camMat, objectRect);
    
    resize(croppedCamMat, objectImage);
    objectImage.update();
    plane.set(objectRect.width, objectRect.height);
}

void RecognizedObject::draw() {
    float x = objectRect.x;
    float y = objectRect.y;
    float width = objectRect.width;
    float height = objectRect.height;
    
    ((ofApp*)ofGetAppPtr())->cvObjectsFbo.begin();
    ofPushMatrix();
    ofTranslate(x, y);
    objectImage.draw(0, 0, width, height);
    plane.drawWireframe();
    ofPopMatrix();
    ((ofApp*)ofGetAppPtr())->cvObjectsFbo.end();
    
}

The source of the image is actually a frame from a video stream that is cropped to a particular location using openCV. The update method is always called before the draw method.

When drawn, however, the plane simply appears as a white wireframe. Why isn't the image appearing on the plane?


Viewing all articles
Browse latest Browse all 40524

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>