Appendix A. Working with Addons

Addons are plugins of a specific kind for openFrameworks. Addons add new capabilities to openFramework projects, such as working with a network, depth cameras, computer vision, and others. In this chapter, we will learn the basic principles of addons' structure, and working with addons:

  • Installing a non-core addon
  • Linking addons to a project
  • Using Project Generator
  • List of selected addons

Addons basics

Though openFrameworks' core has powerful capabilities for processing and generating various kinds of multimedia data, it does not contain everything. For example, the core does not contain support for depth cameras, processing the images using the computer vision library OpenCV, or sending and receiving data via a network.

For using such capabilities in your project, you would link and use any of the C++ or C external libraries that are available on the Internet. But, each library is different so using them in your project is sometimes easy and sometimes not. Fortunately, openFrameworks has a friendly mechanism for plugging libraries to your project. Such a mechanism is called an addon.

Most often, an addon is a class that acts as a wrapper for a library. Also, the addon contains the library itself in a form that is ready to be linked to your project binaries. This relation is shown in the following image:

Addons basics

The term wrapper here means that it lets your project and a library communicate in some way. openFrameworks' addon mission is to simplify such a communication and do it in a standardized way (in "the openFrameworks's style"). Hence, you do not need to learn about a library interface and its usage but just learn how to use an addon, and that would be enough for most situations. So using addons accelerates project development a lot. Furthermore, when you need deeper capabilities of the library, not included in the addon, you can always access them by reaching the library objects and functions directly or through the addon's class members.

Remember, an addon is just an openFrameworks extension; it only links to a project, which is using it, but does not affect the other projects and openFrameworks itself.

Sometimes an addon is not a wrapper, but just a class that adds some new functionality without linking any new library to the project. See the following image:

Addons basics

Addons in openFrameworks

Every openFrameworks's addon class name begins with ofx. This is an acronym for openFrameworks extension. For example, ofxXmlSettings is a class for writing and reading settings in XML files.

Addons are located in the addons folder of openFrameworks. The examples of addons' usage are located in the examples/addons folder of openFrameworks.

There are two classes of addons. The first class of addons is called core addons and is distributed with openFrameworks. You have the addons of this class in the addons folder right after installing openFrameworks. They are stable and useful addons that are needed in many interactive projects.

The second class of addons is called non-core addons and are available for download at http://ofxaddons.com. There are both mature addons as well as the ones currently in development. Please test them carefully before using them in your installations or performances. Fortunately, all the addons have open code, and you can always check and modify them. Nevertheless, sometimes addons have binary .lib or .a files; it is very difficult to find and correct errors in such addons rapidly, so again, test addons before using them.

Installing a non-core addon

To install a non-core addon into openFrameworks, perform the following steps:

  1. Go to http://ofxaddons.com, find the desired addon and click on its name.
  2. The addon's page will be opened. The page contains addon's description and downloading button. Currently download button is named Download ZIP and is located in the right part of the page. Press it to download the addon's archive.
  3. Unpack it into the openFrameworks' addons folder.
  4. If the name of the unpacked folder containing an addon does not match the addon's name, for example, ofxOpenNI-master.zip, rename the folder to the addon's name, ofxOpenNI.
  5. If the addon's folder contains examples of its usage, it is a good idea to move the examples to the examples/addons folder.

The world of addons is rapidly evolving. New addons appear and are renamed regularly. The most useful non-core addons eventually become core addons. And some core addons migrate into openFrameworks core. (Then the ofx prefix in the class name turns into of). So, it would not make much sense to discuss all the existing addons because next year, the list could be totally outdated. Nevertheless, we will discuss the current core and some non-core addons in the List of selected addons section.

Tip

Adding new capabilities to your projects using addons is very easy and comfortable. But there are many libraries and algorithms that have not been implemented in addons yet. So if your project needs some functionality, and if there are no addons for this, don't be upset and solve the problem without addons. For example, if you need to control a new device from your project, then find its SDK, the library or example of its usage, and use it in your C++ project directly without addons.

Once you succeed in doing this, you can package your code as an addon and publish it for the openFrameworks' community by following the recommendations at http://www.ofxaddons.com/howto/.

Now we will talk about linking addons to your project.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset