Grayscale image ofVideoGrabber ofPixels

Hello Everyone,

I’m a beginner C++ programmer and I can’t understand how to get a grey image representation of the VideoGrabber or an ofPixels without using openCV. I tried different ways but some of them are deprecated or it doesn’t build. What am I doing wrong? Thanks

you can just do:

// ofApp.h
ofVideoGrabber video;
ofPixels gray;


// ofApp.cpp
void ofApp::update(){
    gray = video.getPixels();
    gray.setImageType(OF_IMAGE_GRAYSCALE);
}

in some platforms you can even call:

video.setPixelFormat(OF_PIXELS_GRAY);

before loading the video and the video player will return grayscale pixels right away without any further conversion but it’s not guaranted to work on every OS

Ok, I understand now. I was making some programming mistakes. Thanks!