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

Invert video to negative

$
0
0

@Antonio_Castles wrote:

Hello. I’ve been working recently with a Blackmagic capture card thanks to the advise and guidance of some members of this forum and now I’m stuck with a problem. I want to take the video that I’m capturing and invert it when I activate a button from the Gui. I already did something similar before with a webcam by creating first an ofPixels object and allocating to it the video grabber, and then passing it to an ofTexture. I wanted to do something similar but the application crashes because of a segmentation fault.

///
void ofApp::update(){

if(cam.update()) {
    timer.tick();

    //copiar frames a videoPix
    ofPixels& pixels = cam.getColorPixels();



    if(invert){
        for(size_t i = 0; i < pixels.size(); i ++){
            videoPix[i] = 255 - pixels[i];
            //videoTex.loadData(videoPix);
            continue;

        }
    }
    else{

        for (size_t i = 0; i < pixels.size(); i ++){
            videoPix[i] = pixels[i];
            //videoTex.loadData(videoPix);
            continue;
    }


        //videoTex.loadData(videoPix);
}
}

}

//--------------------------------------------------------------
void ofApp::draw(){
ofBackgroundGradient(ofColor::white, ofColor::gray);
//cam.drawColor(20,(((height/3) *2) - (576/2)),camWidth, camHeight);

videoTex.loadData(videoPix);
videoTex.draw(20,(((height/3) *2) - (576/2)),camWidth, camHeight);

///

Any idea?

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 4929

Trending Articles