O'Reilly logo

openFrameworks Essentials by Denis Perevalov, Igor Tatarnikov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Grabbing a live video from a camera

openFrameworks can grab live video from a built-in or external camera connected to your computer. It is accomplished using the ofVideoGrabber class.

Let's implement starting the camera to grab and draw the grabbed video frames on the screen.

Note

Starting a camera can take several seconds. Thus, if we start it in setup(), the project will take a bit longer to start. It could be quite annoying to keep the camera "on" even when we don't use it. For this reason, we will start the camera only when we need it, by pressing C.

The following are the implementation steps:

  1. Add the grabber object definition to the ofApp class:
    ofVideoGrabber camera;
  2. Add the commands to start the camera by adding the following lines to keyPressed() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required