-
-
Save AlexAbraham1/47437c86cd286ace26d7 to your computer and use it in GitHub Desktop.
App
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ofApp.h" | |
//-------------------------------------------------------------- | |
void ofApp::setup() { | |
ofBackground(255, 255, 255); | |
ofSetLogLevel (OF_LOG_VERBOSE); | |
screenWidth = ofGetScreenWidth(); | |
screenHeight = ofGetScreenHeight(); | |
// this makes the camera directly return grayscale image, faster! | |
grabber.setPixelFormat(OF_PIXELS_MONO); | |
grabber.initGrabber(screenWidth, screenHeight); | |
//gray.allocate(grabber.getWidth(),grabber.getHeight()); | |
bg.allocate(grabber.getWidth(), grabber.getHeight()); | |
//diff.allocate(grabber.getWidth(),grabber.getHeight()); | |
one_second_time = ofGetSystemTime(); | |
camera_fps = 0; | |
frames_one_sec = 0; | |
captureBg = false; | |
captureBgCount = 3; | |
circleRadius = 3; | |
} | |
//-------------------------------------------------------------- | |
void ofApp::update() { | |
grabber.update(); | |
if (grabber.isFrameNew()) { | |
frames_one_sec++; | |
if (ofGetSystemTime() - one_second_time >= 1000) { | |
camera_fps = frames_one_sec; | |
frames_one_sec = 0; | |
one_second_time = ofGetSystemTime(); | |
} | |
//gray.setFromPixels(grabber.getPixels(),grabber.getWidth(),grabber.getHeight()); | |
if (captureBg) { | |
if (captureBgCount == 3) { | |
captureBgCount = 0; | |
bg = gray; | |
captureBg = true; | |
gray.absDiff(bg); | |
} else { | |
captureBgCount++; | |
} | |
} | |
//gray.threshold(70); | |
} | |
} | |
//-------------------------------------------------------------- | |
void ofApp::draw() { | |
ofSetHexColor(0xFFFFFF); | |
//gray.draw(0,0); | |
grabber.getTextureReference().drawSubsection(0, 0, screenWidth, screenHeight, 0, 0); | |
// int x = (screenWidth/2) + circleRadius; | |
// int y = circleRadius; | |
// while (x + circleRadius < screenWidth) { | |
// while (y + circleRadius < screenHeight) { | |
// ofColor c = grabber.getPixelsRef().getColor(x-(screenWidth/2), y); | |
// ofSetColor(c); | |
// ofCircle(x, y, circleRadius); | |
// y += circleRadius; | |
// } | |
// x += circleRadius; | |
// } | |
ofColor c2 = grabber.getPixelsRef().getColor(600,600); | |
ofSetColor(c2); | |
ofCircle(30,30,30); | |
// ofSetColor(0x000000); | |
// ofDrawBitmapString("screenWidth: " + screenWidth, 700, 700); | |
// ofDrawBitmapString("screenHeight: " + screenHeight, 700 , 720); | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyPressed(int key) { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::keyReleased(int key) { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::windowResized(int w, int h) { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::touchDown(int x, int y, int id) { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::touchMoved(int x, int y, int id) { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::touchUp(int x, int y, int id) { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::touchDoubleTap(int x, int y, int id) { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::touchCancelled(int x, int y, int id) { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::swipe(ofxAndroidSwipeDir swipeDir, int id) { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::pause() { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::stop() { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::resume() { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::reloadTextures() { | |
} | |
//-------------------------------------------------------------- | |
bool ofApp::backPressed() { | |
return false; | |
} | |
//-------------------------------------------------------------- | |
void ofApp::okPressed() { | |
} | |
//-------------------------------------------------------------- | |
void ofApp::cancelPressed() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment