Skip to content

Instantly share code, notes, and snippets.

@jvcleave
Created December 7, 2012 05:38
Show Gist options
  • Save jvcleave/4231042 to your computer and use it in GitHub Desktop.
Save jvcleave/4231042 to your computer and use it in GitHub Desktop.
simple ofxOpenCv RPI test
#include "testApp.h"
bool hasCaptured = false;
//--------------------------------------------------------------
void testApp::setup(){
ofSetLogLevel(OF_LOG_VERBOSE);
logo1.loadImage("ofLogo1.jpg");
w = logo1.getWidth();
h = logo1.getHeight();
ofLogVerbose() << "logo1.getWidth(), logo1.getHeight(): " << w << " " << h;
colorImg.allocate(w, h);
colorImg.setFromPixels(logo1.getPixels(), w, h);
grayImage.allocate(w, h);
grayImage = colorImg;
}
//--------------------------------------------------------------
void testApp::update(){
}
//--------------------------------------------------------------
void testApp::draw(){
ofBackground(100,100,100);
colorImg.draw(0,0, w, h);
grayImage.draw(w, 0, w, h);
if (!hasCaptured) {
hasCaptured = true;
ofImage screenCap;
screenCap.grabScreen(0, 0, w*2, h);
screenCap.saveImage(ofToDataPath("cv.jpg", true));
}
}
//--------------------------------------------------------------
void testApp::keyPressed(int key){
}
//--------------------------------------------------------------
void testApp::keyReleased(int key){
}
//--------------------------------------------------------------
void testApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
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){
}
//--------------------------------------------------------------
void testApp::windowResized(int w, int h){
}
//--------------------------------------------------------------
void testApp::gotMessage(ofMessage msg){
}
//--------------------------------------------------------------
void testApp::dragEvent(ofDragInfo dragInfo){
}
#pragma once
#include "ofMain.h"
#include "ofxOpenCv.h"
//#define _USE_LIVE_VIDEO // uncomment this to use a live camera
// otherwise, we'll use a movie file
class testApp : public ofBaseApp{
public:
void setup();
void update();
void draw();
void keyPressed(int key);
void keyReleased(int key);
void mouseMoved(int x, int y );
void mouseDragged(int x, int y, int button);
void mousePressed(int x, int y, int button);
void mouseReleased(int x, int y, int button);
void windowResized(int w, int h);
void dragEvent(ofDragInfo dragInfo);
void gotMessage(ofMessage msg);
ofxCvColorImage colorImg;
ofxCvGrayscaleImage grayImage;
ofxCvGrayscaleImage grayBg;
ofxCvGrayscaleImage grayDiff;
ofImage logo1;
int w, h;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment