Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
‣
‣


‣


‣
‣
‣

‣
‣
‣
‣




‣http://goo.gl/VunsO
‣
‣
‣
‣


‣
    ‣
    ‣

    ‣
    ‣

    ‣
    ‣
‣
‣
    ‣
‣


    ‣
        ‣


        ‣



    ‣
        ‣
‣



‣


    ‣
    ‣
‣


‣


‣

‣http://goo.gl/OlVT5
‣
‣
‣


‣


‣


‣
‣
#pragma once

#include "ofMain.h"

class testApp : public ofBaseApp{
!
public:
! void setup();
! void update();
! void d...
‣
#include "testApp.h"

void testApp::setup(){
    ofSetFrameRate(60);
    ofBackgroundHex(0x000000);
}

void testApp::upd...
‣
void testApp::mouseDragged(int x, int y, int button){

}

void testApp::mousePressed(int x, int y, int button){

}

void...
‣
‣
    ‣
    ‣
    ‣
    ‣


‣
‣
#pragma once

#include "ofMain.h"

#include "ofxControlPanel.h"

class testApp : public ofBaseApp{
!
public:
! void setu...
‣
void testApp::setup(){
    ofSetFrameRate(60);
    ofBackgroundHex(0x000000);

!   //GUI setup
     gui.setup("control p...
‣
void testApp::draw(){
    ofPushMatrix();

    ofTranslate(ofGetWidth()/2, ofGetHeight()/2);
    ofRotateX(gui.getValueF...
‣

void testApp::mouseDragged(int x, int y, int button){
    gui.mouseDragged(x, y, button);
}

void testApp::mousePressed...
‣
‣
‣
‣
    ‣


‣
    ‣
    ‣


    ‣
    ‣
‣


‣


‣
‣


‣


‣
‣
‣ http://yesyesno.com/night-lights
‣
‣ http://graffitiresearchlab.com/projects/laser-tag/
‣
‣ http://www.eyewriter.org/
‣
‣ http://www.chrisoshea.org/hand-from-above
‣
‣ http://www.chrisoshea.org/audience
‣
‣ http://www.flong.com/projects/snout/
‣
‣ http://www.boardsmag.com/community/blogs/behindthescenes/
  index.php?p=834
‣
‣


‣


‣
‣
‣


‣
‣
#pragma once
#include "ofMain.h"
#include "ofxOpenCv.h"
//#define _USE_LIVE_VIDEO

class testApp : public ofBaseApp{
pub...
‣
void testApp::setup(){
! ofSetFrameRate(60);
!
! #ifdef _USE_LIVE_VIDEO
! vidGrabber.setVerbose(true);
! vidGrabber.init...
‣
void testApp::update(){
! ofBackground(100,100,100);
!
    bool bNewFrame = false;
!
! #ifdef _USE_LIVE_VIDEO
! vidGrabb...
‣
!   if (bNewFrame){
!   !
!   !    #ifdef _USE_LIVE_VIDEO
!   !    colorImg.setFromPixels(vidGrabber.getPixels(), 320,24...
‣
void testApp::draw(){
!
! ofSetHexColor(0xffffff);
! colorImg.draw(20,20);
! grayImage.draw(360,20);
! grayBg.draw(20,28...
‣
‣


‣


‣
‣
‣
‣



‣
‣


‣

‣
    ‣
    ‣
    ‣
‣
#pragma once
#include "ofMain.h"
#include "ofxOpenCv.h"

typedef enum{
! BG_ABS, BG_GREATER, BG_LESS
} captureMode;

cla...
‣
#include "BackgroundSubtraction.h"

void BackgroundSubtraction::setup(int width, int height){
!
! color.allocate(width, ...
‣
!   if( mode == BG_ABS ){
!   !    thresh.absDiff(gray, background);
!   }else if( mode == BG_GREATER ){
!   !    thresh...
‣
void BackgroundSubtraction::captureBackground(){
! background = gray;
}

void BackgroundSubtraction::setDifferenceMode(i...
‣
‣



‣


‣
‣
‣
‣
‣
‣
‣
‣



‣
‣
‣
‣
‣


‣
‣
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII
You’ve finished this document.
Download and read it offline.
Upcoming SlideShare
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
Next
Upcoming SlideShare
openFrameworks – パーティクルを動かす、静的配列と動的配列 - 多摩美メディアアートII
Next
Download to read offline and view in fullscreen.

Share

openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII

Download to read offline

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

openFrameworks addonを利用する ofxControlPanel ofxOpenCv - 多摩美メディアアートII

  1. 1. ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣
  2. 2. ‣ ‣http://goo.gl/VunsO
  3. 3. ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣
  4. 4.
  5. 5. ‣ ‣
  6. 6. ‣ ‣ ‣ ‣ ‣ ‣
  7. 7. ‣ ‣ ‣ ‣
  8. 8. ‣ ‣ ‣ ‣http://goo.gl/OlVT5 ‣
  9. 9.
  10. 10. ‣ ‣ ‣ ‣
  11. 11. ‣ #pragma once #include "ofMain.h" class testApp : public ofBaseApp{ ! public: ! void setup(); ! void update(); ! void draw(); ! void mouseDragged(int x, int y, int button); ! void mousePressed(int x, int y, int button); ! void mouseReleased(int x, int y, int button); };
  12. 12. ‣ #include "testApp.h" void testApp::setup(){ ofSetFrameRate(60); ofBackgroundHex(0x000000); } void testApp::update(){ } void testApp::draw(){ ! float rot_x = 10.0f; ! float rot_y = 20.0f; ! float rot_z = 30.0f; ! float size = 200.0f; ! ofPushMatrix(); ! ofTranslate(ofGetWidth()/2, ofGetHeight()/2); ! ofRotateX(rot_x); ! ofRotateY(rot_y); ! ofRotateZ(rot_z); ! ofSetHexColor(0x3399ff); ! ofSetRectMode(OF_RECTMODE_CENTER); ! ofRect(0, 0, size, size); ! ofPopMatrix(); }
  13. 13. ‣ void testApp::mouseDragged(int x, int y, int button){ } void testApp::mousePressed(int x, int y, int button){ } void testApp::mouseReleased(int x, int y, int button){ }
  14. 14.
  15. 15. ‣ ‣ ‣ ‣ ‣ ‣
  16. 16. ‣ #pragma once #include "ofMain.h" #include "ofxControlPanel.h" class testApp : public ofBaseApp{ ! public: ! void setup(); ! void update(); ! void draw(); ! void mouseDragged(int x, int y, int button); ! void mousePressed(int x, int y, int button); ! void mouseReleased(int x, int y, int button); ofxControlPanel gui; };
  17. 17. ‣ void testApp::setup(){ ofSetFrameRate(60); ofBackgroundHex(0x000000); ! //GUI setup gui.setup("control panel test", 0, 0, 340, 400); gui.addPanel("panel 1", 1); gui.addSlider("rect size", "size", 100, 0, 800, false); gui.addSlider("rotate x", "rot_x", 0, 0, 360, false); gui.addSlider("rotate y", "rot_y", 0, 0, 360, false); gui.addSlider("rotate z", "rot_z", 0, 0, 360, false); gui.loadSettings("controlPanel.xml"); }
  18. 18. ‣ void testApp::draw(){ ofPushMatrix(); ofTranslate(ofGetWidth()/2, ofGetHeight()/2); ofRotateX(gui.getValueF("rot_x")); ofRotateY(gui.getValueF("rot_y")); ofRotateZ(gui.getValueF("rot_z")); ofSetHexColor(0x3399ff); ofSetRectMode(OF_RECTMODE_CENTER); ofRect(0, 0, gui.getValueF("size"), gui.getValueF("size")); ofPopMatrix(); ofSetRectMode(OF_RECTMODE_CORNER); gui.draw(); }
  19. 19. ‣ void testApp::mouseDragged(int x, int y, int button){ gui.mouseDragged(x, y, button); } void testApp::mousePressed(int x, int y, int button){ gui.mousePressed(x, y, button); } void testApp::mouseReleased(int x, int y, int button){ gui.mouseReleased(); }
  20. 20.
  21. 21. ‣ ‣
  22. 22. ‣ ‣ ‣ ‣ ‣ ‣ ‣
  23. 23. ‣ ‣ ‣
  24. 24. ‣ ‣ ‣
  25. 25. ‣ ‣ http://yesyesno.com/night-lights
  26. 26. ‣ ‣ http://graffitiresearchlab.com/projects/laser-tag/
  27. 27. ‣ ‣ http://www.eyewriter.org/
  28. 28. ‣ ‣ http://www.chrisoshea.org/hand-from-above
  29. 29. ‣ ‣ http://www.chrisoshea.org/audience
  30. 30. ‣ ‣ http://www.flong.com/projects/snout/
  31. 31. ‣ ‣ http://www.boardsmag.com/community/blogs/behindthescenes/ index.php?p=834
  32. 32. ‣ ‣ ‣ ‣
  33. 33.
  34. 34. ‣ ‣
  35. 35. ‣ #pragma once #include "ofMain.h" #include "ofxOpenCv.h" //#define _USE_LIVE_VIDEO class testApp : public ofBaseApp{ public: ! void setup(); ! void update(); ! void draw(); ! void keyPressed(int key); ! ! #ifdef _USE_LIVE_VIDEO ! ofVideoGrabber vidGrabber; ! #else ! ofVideoPlayer vidPlayer; ! #endif ! ! ofxCvColorImage colorImg; ! ofxCvGrayscaleImage grayImage; ! ofxCvGrayscaleImage grayBg; ! ofxCvGrayscaleImage grayDiff; ! ofxCvContourFinder contourFinder; ! ! int threshold; ! bool bLearnBakground; };
  36. 36. ‣ void testApp::setup(){ ! ofSetFrameRate(60); ! ! #ifdef _USE_LIVE_VIDEO ! vidGrabber.setVerbose(true); ! vidGrabber.initGrabber(320,240); ! #else ! vidPlayer.loadMovie("fingers.mov"); ! vidPlayer.play(); ! #endif ! ! colorImg.allocate(320,240); ! grayImage.allocate(320,240); ! grayBg.allocate(320,240); ! grayDiff.allocate(320,240); ! ! bLearnBakground = true; ! threshold = 80; }
  37. 37. ‣ void testApp::update(){ ! ofBackground(100,100,100); ! bool bNewFrame = false; ! ! #ifdef _USE_LIVE_VIDEO ! vidGrabber.grabFrame(); ! bNewFrame = vidGrabber.isFrameNew(); ! #else ! vidPlayer.idleMovie(); ! bNewFrame = vidPlayer.isFrameNew(); ! #endif
  38. 38. ‣ ! if (bNewFrame){ ! ! ! ! #ifdef _USE_LIVE_VIDEO ! ! colorImg.setFromPixels(vidGrabber.getPixels(), 320,240); ! ! #else ! ! colorImg.setFromPixels(vidPlayer.getPixels(), 320,240); ! ! #endif ! ! grayImage = colorImg; ! ! if (bLearnBakground == true){ ! ! ! grayBg = grayImage; ! ! ! bLearnBakground = false; ! ! } ! ! ! ! grayDiff.absDiff(grayBg, grayImage); ! ! grayDiff.threshold(threshold); ! ! ! ! contourFinder.findContours(grayDiff, 20, (340*240)/3, 10, true); ! } }
  39. 39. ‣ void testApp::draw(){ ! ! ofSetHexColor(0xffffff); ! colorImg.draw(20,20); ! grayImage.draw(360,20); ! grayBg.draw(20,280); ! grayDiff.draw(360,280); ! ! ofFill(); ! ofSetHexColor(0x333333); ! ofRect(360,540,320,240); ! ! ofSetHexColor(0xffffff); ! contourFinder.draw(360,540); }
  40. 40.
  41. 41. ‣ ‣ ‣
  42. 42.
  43. 43.
  44. 44. ‣ ‣ ‣ ‣ ‣ ‣ ‣ ‣
  45. 45. ‣ #pragma once #include "ofMain.h" #include "ofxOpenCv.h" typedef enum{ ! BG_ABS, BG_GREATER, BG_LESS } captureMode; class BackgroundSubtraction{ public: ! void setup(int width, int height); ! void update(unsigned char * pixelsIn, int width, int height ); ! void draw(float x, float y); ! void setThreshold(int threshVal); ! void setDifferenceMode(int modeIn); ! void captureBackground(); ! ! ofxCvColorImage color; ! ofxCvGrayscaleImage gray; ! ofxCvGrayscaleImage background; ! ofxCvGrayscaleImage thresh; ! captureMode mode; ! int numFrames; ! float threshAmnt; };
  46. 46. ‣ #include "BackgroundSubtraction.h" void BackgroundSubtraction::setup(int width, int height){ ! ! color.allocate(width, height); ! gray.allocate(width, height); ! thresh.allocate(width, height); ! background.allocate(width, height); ! ! threshAmnt = 29; ! numFrames! 0; = } void BackgroundSubtraction::update(unsigned char * pixelsIn, int width, int height ){ ! color.setFromPixels(pixelsIn, width, height); ! ! gray = color; ! ! if( numFrames < 20 ){ ! ! background = gray; ! }!
  47. 47. ‣ ! if( mode == BG_ABS ){ ! ! thresh.absDiff(gray, background); ! }else if( mode == BG_GREATER ){ ! ! thresh = gray; ! ! thresh -= background; ! }else if( mode == BG_LESS ){ ! ! thresh = background; ! ! thresh -= gray;! ! } ! ! thresh.threshold(threshAmnt); ! numFrames++; } void BackgroundSubtraction::draw(float x, float y){ ! ofSetColor(0xFFFFFF); ! gray.draw(x, y); ! background.draw(x + gray.width, y); ! thresh.draw(x, y + gray.height); } void BackgroundSubtraction::setThreshold(int threshVal){ ! threshAmnt = (int)threshVal; }
  48. 48. ‣ void BackgroundSubtraction::captureBackground(){ ! background = gray; } void BackgroundSubtraction::setDifferenceMode(int modeIn){ ! mode = (captureMode)modeIn; }
  49. 49.
  50. 50. ‣ ‣ ‣
  51. 51. ‣ ‣
  52. 52. ‣ ‣
  53. 53.
  54. 54. ‣ ‣ ‣
  55. 55.
  56. 56. ‣ ‣ ‣ ‣
  57. 57.
  • SenaKoga

    Aug. 1, 2016
  • onibmuu

    Apr. 29, 2015
  • m0Rya

    Sep. 30, 2014
  • KazukiSekiya

    Dec. 19, 2013
  • gup0n

    May. 31, 2013
  • litchirhythm

    Apr. 12, 2012
  • sokumura8

    Apr. 9, 2012
  • kishir1

    Feb. 6, 2012
  • nekouo

    Dec. 17, 2011

Views

Total views

10,003

On Slideshare

0

From embeds

0

Number of embeds

3,771

Actions

Downloads

136

Shares

0

Comments

0

Likes

9

×