I’m using a IR camera, and the second image is what I have right now.
I want to play a video in the background and cut the white part. (play video inside the white part)Anyone can help?
This is the code:
#include "ofApp.h"
void ofApp::setup()
{
grabber.setup(640, 480);
IRCamPixels.allocate(grabber.getWidth(), grabber.getHeight(), OF_PIXELS_GRAY);
myPlayer.load("take another peep.mp4");
myPlayer.play();
}
void ofApp::update()
{
myPlayer.update();
threshold = ofMap(ofGetMouseX(), 0, ofGetWidth(), 0, 255);
grabber.update();
if (grabber.isFrameNew())
{
for (int x = 0; x < grabber.getWidth(); x++)
{
for (int y = 0; y < grabber.getHeight(); y++)
{
if (grabber.getPixels().getColor(x, y).getBrightness() > threshold)
{
IRCamPixels.setColor(x, y, ofColor(255,10));
}
else
{
IRCamPixels.setColor(x, y, ofColor(0));
}
}
}
// myPlayer.update();
IRCamTexture.loadData(IRCamPixels);
}
}
void ofApp::draw()
{
myPlayer.draw(0, 0);
IRCamTexture.draw(0, 0);
ofDrawBitmapStringHighlight("Threshold: " + ofToString(threshold), 14, 14);
}
What you want to do is called “masking” or “blending”. Please search through the forum, you will find lots of ways to do it.
For example have a look at these threads: