Instructions for Downloading & Installing Cinder + OpenCV in OS X: Note: these instructions assumed you have Xcode & Xcode tools installed.
1. Download OS X release of cinder from here: a. https://libcinder.org/download
Click ¡°Cinder for MacOS¡± – do NOT download the previous releases.
You can think of Cinder as like openFrameworks or Processing (for Java). It is a C++ library with a collection of useful classes and functions for UI & visual processing. It also contains templates for basic applications, which is nice. IMO.
Ok, now we are going to install more software C++ library: OpenCV. CV stands for Computer Vision. We will start this class learning basic computer vision techniques for motion capture. We will be using our built-in laptop cameras (or phone), but if you want to use these techniques in your final project, you can use these same techniques with Kinect or with (better camera) Obbrec Astra. Kinect & Astra have depth information as well, but the techniques learned in this unit are relevant in that case as well.
2. Easy Install for latest version of OpenCV using Homebrew: a. Install Homebrew if you haven¡¯t
i. https://brew.sh/
b. Install Homebrew if you haven¡¯t used it
c. Install opencv via homebrew.
i. Open terminal
ii. brew install opencv
If you encounter the above error, simply install the command line tools as directed. (ie, copy & paste ¡°xcode-select –install¡± into the terminal and run. Then run the install code again (See 2.c.ii).
d. Install pkg-config if you don¡¯t have it
i. Go to Terminal
ii. brew install pkg-config
3. Use pkg-config to find your C++ linking flags. These will be entered into Xcode. These
allow your program to access the OpenCV library and is an easy solve for ¡°dependency hell¡±. And it is hell.
a. Go to Terminal
b. Change directory to where homebrew has installed opencv & go to the pkg-
config directory. Generally, this is:
/usr/local/Cellar/opencv/($VERSION)/lib/pkgconfig
c. Eg. cd /usr/local/Cellar/opencv/4.1.0_3/lib/pkgconfig
d. Ok now run pkg-config on the opencv.pc file inside that directory
e. pkg-config –cflags –libs opencv4.pc
f. You should get output like this in Terminal:
-I/usr/local/Cellar/opencv/3.4.2/include/opencv – I/usr/local/Cellar/opencv/3.4.2/include -L/usr/local/Cellar/opencv/3.4.2/lib – lopencv_stitching -lopencv_superres -lopencv_videostab -lopencv_aruco – lopencv_bgsegm -lopencv_bioinspired -lopencv_ccalib -lopencv_dnn_objdetect – lopencv_dpm -lopencv_face -lopencv_photo -lopencv_fuzzy -lopencv_hfs – lopencv_img_hash -lopencv_line_descriptor -lopencv_optflow -lopencv_reg – lopencv_rgbd -lopencv_saliency -lopencv_stereo -lopencv_structured_light – lopencv_phase_unwrapping -lopencv_surface_matching -lopencv_tracking – lopencv_datasets -lopencv_dnn -lopencv_plot -lopencv_xfeatures2d – lopencv_shape -lopencv_video -lopencv_ml -lopencv_ximgproc -lopencv_calib3d -lopencv_features2d -lopencv_highgui -lopencv_videoio -lopencv_flann – lopencv_xobjdetect -lopencv_imgcodecs -lopencv_objdetect -lopencv_xphoto – lopencv_imgproc -lopencv_core
g. OK, Great! Don¡¯t close this window. Save this output. You will need it SOON!
4. Create
a. In Finder, navigate to the cinder directory (cinder_0.9.1_mac)
a new Cinder project using Tinder
b. Run tools/TinderBox-Mac/TinderBox.app
c. Looks like this:
d. In ¡°Project Name¡± change the name to whatever name that you want to name your project. You may also change location.
e. Make sure the path below the cinder version reflects where you installed cinder. If not click ¡°Settings…¡±
Add a cinder version by clicking the green ¡°+¡± and choosing the folder where you installed cinder.
f. Make sure Xcode is selected. Make sure the Template is ¡°Basic OpenGL¡±.
g. OK, great! Hit ¡°Next!¡±
h. Ok, next screen:
i. IGNORE OPENCV if it appears in your options. We¡¯re doing that later so that we will be using the up to date version that works. Instead, scroll down to OSC and in ¡°Install¡± change from ¡°None¡± to ¡°Relative¡± thusly:
j. Click finish!! You are done!!!
5. Open the project that you created in Xcode and build. Run it! It should be a blank
screen. Yay! Everything is working so far. (I hope.)
6. Link the OpenCV libraries to XCode
a. Set Header Search Paths
i. Go to Build Settings by clicking on the Project. Make sure that the target ¡°CinderProject¡± (or whatever you named your program) is selected and NOT the project. It should look like this:
To the left of ¡°General¡± the icon next to ¡°CinderProject¡± looks like a red/yellow ¡°A¡±. This should be the default, but if it is set wrong, then the settings will be invalid.
This is what it should NOT look like:
To change, just click on the ¡°CinderProject¡± to the left of ¡°Info¡± and choose the target.
ii. Search for ¡°Header Search Paths¡±.
iii. Enter in where that is on your computer. Remember where opencv from
step 3c. Instead of the pkgconfig folder, you want to reference the include folder. You also need to specify opencv4 ie:/usr/local/Cellar/opencv/4.1.0_3/include/opencv4
Use the ¡°+¡± to add the folder path. Do NOT overwrite any other paths. You will want to use double-quotes if your path includes a space. When you are finished, it should look like this:
b. Set Library Search Paths
i. Go to Build Settings and search for ¡°Library Search Paths¡±
ii. Enter in where that is on your computer. Instead of ¡°include¡± you will have ¡°lib¡± as the folder IE:
/usr/local/Cellar/opencv/4.1.0_3/lib
When you are done, it should something like:
c. Enter in your Linker Flags
i. Go to the output of your pkg-config action in step 3. Copy it.
ii. Search for ¡°Other Linker Flags¡± in Build Settings.
iii. With a plus, add an entry under what is already there.
iv. Paste the pkg-config output there. You can paste in the box above the
debug & release or you can paste in both separate. After this operation, the debug, for instance, will look something like this:
7. Build and Run again. It should all work. Yay!
8. Download from Canvas and add the file: ¡°CinderOpenCV.h¡± to your file. Build and Run.
9. Add the following includes above the other includes in your .cpp main file:
#include
10. Add this include below the other includes in your .cpp main file: #include “CinderOpenCV.h”
11. Build and Run! If you made to this point, you are ready to start coding!!! Congrats, your painful or not-so-painful installation process is over.
12. You may want to explore out the programs in ¡°samples¡± if you like. Particularly, ¡°CaptureBasic¡±. You may want to move on to setting up your phone as a webcam with this app using EpocCam (if you have access to wifi other than SMU which will shut that %^&*&^% down). See if you can¡¯t figure out how to reference that in code.
13. Turning in a project. Zip your entire project folder and turn in. The project folder is the folder with your project name like so:
In this case, CinderProject is the project folder with /assets, /xcode, /src, etc. You will turn this entire folder in when you need to turn code in.
14. Creating a new project which saves all these settings.
a. DO NOT MOVE YOUR ¡°cinder_0.9.1_mac¡± folder unless you want to tinker with
settings or go through this install sheet again. OMFG. (Although, if you have a
good understanding of C++ builds & Xcode it should be perfectly fine).
b. DO NOT MOVE YOUR project folder unless you want to tinker with settings or go
through this install sheet again. OMFG.
c. Ok, now that I¡¯ve clarified that, duplicate your project folder. Rename the folder
as you please. Ok, now open the Xcode project.
d. Go to your main cpp file. In mine, this was just ¡°CinderProject.cpp¡±. Now highlight
the main class:
Ctrl-Click or Double-Click to get the menu and select ¡°Refactor->Rename¡±
You get:
So rename it. It will probably be good to keep the ¡°App¡± suffix at the end to remind everyone what the class is doing.
e. Ok, now click on your project name and change the name in the project browser:
It will ask you to rename Project contents, etc. and you should click yes. If you like, you can also change the bundle identifier thusly: