Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
OpenFrameworks Essentials

You're reading from   OpenFrameworks Essentials Create stunning, interactive openFrameworks-based applications with this fast-paced guide

Arrow left icon
Product type Paperback
Published in Apr 2015
Publisher
ISBN-13 9781784396145
Length 206 pages
Edition 1st Edition
Arrow right icon
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with openFrameworks FREE CHAPTER 2. Creating Your First openFrameworks Project 3. Adding a GUI and Handling Keyboard Events 4. Working with Raster Graphics – Images, Videos, and Shaders 5. Creating 3D Graphics 6. Animating Parameters 7. Distributed and Physical Computing with Networking and Arduino 8. Deploying the Project on iOS, Android, and Raspberry Pi 9. Further Resources A. Video Synthesizer Reference B. openFrameworks Quick Reference Index

Running your first example

We would like to introduce one of the funniest openFrameworks examples, which we like a lot. The example captures the images from a webcam and draws it on the screen as a fancy 3D surface, as shown in the following picture:

Running your first example

3D surface generated by an openFrameworks example

This is the meshFromCamera example located in the examples/3d folder.

Tip

This example requires a webcam. If your computer does not have a built-in webcam, and you have no external webcam to connect to, please work with another example, for instance, examples/3d/3DPrimitivesExample.

We cannot run the example immediately after installing openFrameworks. The reason is that openFrameworks examples are distributed as source files only, without executable files that you can run.

To obtain the executable file, we need to build the project, that is, compile its C++ source code to machine code and link it into an executable file. Let's do it and then run the example by performing the following steps:

  1. Open the example folder examples/3d/meshFromCamera.
  2. Find there the file named meshFromCamera.xcodeproj (Xcode project), meshFromCamera.sln (Visual Studio project), or meshFromCamera.workspace (Code::Blocks project).
  3. Double-click on this file, and the meshFromCamera project will open in your IDE.
  4. Build the project by pressing Command + B in Xcode, F7 in Visual Studio, or by clicking on the Build button in Code::Blocks.

    Tip

    For Xcode users

    In the project, there exist several schemes that indicate the part of the project to build and a number of settings for it. Often at first run, the scheme is set to openFrameworks, as shown on the following screenshot:

    Running your first example

    Scheme selector in Xcode

    If so, the compiler builds openFrameworks, but not the project. To resolve the issue, please click on the scheme name. A context menu will appear. Select the meshFromCamera Release scheme there. After this, perform building as described in step 4.

  5. Run the project by clicking on the corresponding button in your IDE (normally, it's depicted as a small triangle, meaning the play symbol). After running, you will see your webcam's image drawn as a distorted 3D surface.
  6. Press Esc to stop the execution.

This example involves several topics, such as capturing frames from the camera, creating 3D surfaces, and texturing them. You will discover these topics in Chapter 4, Working with Raster Graphics – Images, Videos, and Shaders, and Chapter 5, Creating 3D Graphics, and will be able to build similar and even more sophisticated projects easily.

You have been reading a chapter from
OpenFrameworks Essentials
Published in: Apr 2015
Publisher:
ISBN-13: 9781784396145
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image