Slide #1.

Image Processing on the Pi using openFrameworks
More slides like this


Slide #2.

Setup • Before beginning: – Install openFrameworks per these instructions • Run dependency scripts and compile openFrameworks – Install g++-4.7 • sudo apt-get install g++-4.7 – Install and test Raspberry Pi camera • Use the raspistill command to test • Beware: The Pi camera connection is somewhat fragile. Repeated connecting and disconnecting is not advised.
More slides like this


Slide #3.

openFrameworks • An opensource C++ toolkit that includes many libraries including openCV for computer vision • Massively cross-compatible – Windows, OSX, Linux, iOS, Android, Raspberry Pi – Four IDEs: XCode, Code::Blocks, and Visual Studio and Eclipse • All code is on GitHub • Reminiscent of Processing
More slides like this


Slide #4.

Structure
More slides like this


Slide #5.

Resources • In Ramsey library: – Programming Interactivity by Joshua Noble • Web excerpt • On-line – OF website – A very good workshop
More slides like this


Slide #6.

Working with the Pi Camera • Take from the Creepy Face Tracking Portrait by Tony DiCola • Uses ofxRPICameraVideoGrabber by Jason Van Cleave • Use the program structure created by DiCola to write other openFrameworks programs that work with the Pi camera
More slides like this


Slide #7.

Demo Program: ColorTracker • Download colorTracker.tgz • Uncompress it in openFrameworks/apps/myApps tar -xvzf colorTracker.tgz • Compile cd colorTracker make • Run and notice how it tracks a red colored object bin/colorTracker pi
More slides like this


Slide #8.

Use ColorTracker as a Template • Copy the colorTracker directory into the openFrameworks/apps/myApps directory with a new name: cp –r colorTracker • Keep the portions of main.cpp and the app .h and .cpp files in the src directory as described in the next three slides • Rename the app files, replace ColorTracker with the new app name, and add new code to create the desired functionality
More slides like this


Slide #9.

Keep the following from ColorTracker.h #include #include "ofMain.h" #include "VideoSource.h" #include "ofxOpenCv.h" class ColorTracker: public ofBaseApp { //  remember to change the class name throughout public: ColorTracker() {} ~ColorTracker() {} void setup(); void update(); void draw(); . . // method prototypes in all openFrameworks apps . void gotMessage(ofMessage msg); ofVec2f updateAngle(const ofVec2f& point); // Distance camera is back on the Z axis from the origin. float cameraDistance = 650.0; // Reference to a video source. std::shared_ptr video; float videoFOV; ofVec2f videoOffset = ofVec2f(0,0); private: ofEasyCam camera; float pixelFocalLength; };
More slides like this


Slide #10.

Keep the following from ColorTracker.cpp void ColorTracker::setup() { //  remember to change the class name throughout ofSetVerticalSync(true); pixelFocalLength = sqrt(pow(video->getWidth()/2.0, 2) + pow(video->getHeight()/2.0,2))/sin(ofDegToRad(videoFOV/2.0)); // Set up camera camera.setDistance(cameraDistance); camera.setTarget(ofVec3f(0, 0, 0)); camera.disableMouseInput(); … } void ColorTracker::update() { video->update(); } void ColorTracker::draw(){ camera.begin(); camera.end(); if (video->isFrameNew()) { rgb.setFromPixels(video->getPixels()); … } … }
More slides like this


Slide #11.

main.cpp • Use main.cpp as provided here replacing ColorTracker with the new app (i.e., class) name. – Allows program to use Pi camera on the Raspberry Pi or run alternative video device on another platform • Performance on alternative platform is untested
More slides like this


Slide #12.

Try this with an openFrameworks example Modify openFrameworks/examples/addons/opencvExample to work with the Pi camera using colorTracker as a template: 1. Copy the colorTracker folder to openFrameworks/apps/myApps/ giving it the new name opencvExample. 2. Rename opencvExample/src/ColorTracker.h to be opencvExample/src/OpencvExample.h 3. Rename opencvExample/src/ColorTracker.cpp to be opencvExample/src/OpencvExample.cpp 4. Change all occurences of ColorTracker to be OpencvExample throughout OpencvExample.h, OpencvExample.cpp, & main.cpp 5. Add the relevant content of openFrameworks/examples/addons/opencvExample/src/testApp.h to OpencvExample.h 6. Add the relevant content of openFrameworks/examples/addons/opencvExample/src/testApp.cpp to OpencvExample.cpp 7. Compile and run
More slides like this