I am trying to develop a program that captures snapshots from the webcam using OfVideoGrabber, and store those pictures side by side on the screen.
I have the videograbber and webcam setup, but how do I get the webcam to capture whenever i press a certain key? and how do I load the image from pixels?
I think you can simply load a frame from the camera into a texture upon pressing a key.
In your header
ofTexture camtex;
Then in your source, use the keyPressed method of your app (use GL_RGB for color)
void testApp::keyPressed(int key){
if(key == 'g')
{
camtex.loadData(cam1.getPixels(), camWidth, camHeight, GL_LUMINANCE);
}
}
And display the image on the screen in the draw() method of you app class
camtex.draw(10, 10, camWidth, camHeight);
Now build and run the app and press g to see a snapshot. I guess for multiple snapshots you’d need multiple textures, maybe in an array, and use loops to diplay them, maybe downscaled…
i can’t get this to build. does anyone have the .h .cpp files to get this working please?