Browse Source

pi mapper working!

tsns-map
cailean 1 week ago
parent
commit
ac632ad4a4
  1. 21
      src/QuadSource/QuadSource.cpp
  2. 17
      src/QuadSource/QuadSource.h
  3. 29
      src/ofApp.cpp
  4. 6
      src/ofApp.h

21
src/QuadSource/QuadSource.cpp

@ -0,0 +1,21 @@
#include "QuadSource.h"
void QuadSource::setup(){
// name
name = "test";
// allocate size
allocate(1512, 1080);
}
void QuadSource::update(){
}
void QuadSource::draw(){
// Fill FBO with our quads
ofClear(0);
//ofBackground(255, 120, 10);
fbo_in->draw(0, 0);
}

17
src/QuadSource/QuadSource.h

@ -0,0 +1,17 @@
#ifndef _QUADSOURCE
#define _QUADSOURCE
#include "ofMain.h"
#include "FboSource.h"
class QuadSource : public ofx::piMapper::FboSource{
public:
void setup();
void update();
void draw();
std::vector<ofRectangle> quads;
std::vector<float> quad_speeds;
};
#endif

29
src/ofApp.cpp

@ -7,6 +7,10 @@ void ofApp::setup(){
ofSetVerticalSync(true);
window_width = 1512;
window_height = ofGetWindowHeight();
ofx::piMapper::VideoSource::enableAudio = false;
ofx::piMapper::VideoSource::useHDMIForAudio = false;
projection_mapper.registerFboSource(quad_src);
projection_mapper.setup();
/* load font */
tf.load("data/fonts/jetbrainsmono-regular.ttf", 20);
@ -38,6 +42,7 @@ void ofApp::setup(){
/* Shader output */
rampedFbo.allocate(window_width, window_height);
quad_src.setFbo(&rampedFbo);
emoteImage.allocate(260, 260);
tempImage.allocate(emoteImage.getWidth(), emoteImage.getHeight(), OF_IMAGE_COLOR);
@ -116,6 +121,8 @@ void ofApp::update(){
std::cout << "Model did not run" << std::endl;
}
projection_mapper.update();
}
@ -144,7 +151,10 @@ void ofApp::draw(){
tf.drawString(std::to_string(ofGetFrameRate()), 10, 30);
ofPopMatrix();
printEmotions();
// printEmotions();
// send final fbo (ramp.fbo) to pi_mapper
//projection_mapper.draw();
// emoteImage.draw(640, 0);
// for(auto& face : detected_faces){
@ -198,15 +208,12 @@ void ofApp::inferEmotionalState(){
*/
void ofApp::renderDepthMap(){
rampedFbo.begin();
depthToColourShader.begin();
depthToColourShader.setUniformTexture("tex0", screen_fbo.getTexture(), 0);
depthToColourShader.setUniform1f("texW", rampedFbo.getWidth());
depthToColourShader.setUniform1f("texH", rampedFbo.getHeight());
screen_fbo.draw(0, 0);
depthToColourShader.end();
img.draw(0, 0);
rampedFbo.end();
rampedFbo.draw(0,0);
@ -234,34 +241,32 @@ void ofApp::displayFrame(){
//--------------------------------------------------------------
void ofApp::keyPressed(int key){
// if (key=OF_KEY_LEFT){
// player.SetRandomFrame();
// }
projection_mapper.keyPressed(key);
}
//--------------------------------------------------------------
void ofApp::keyReleased(int key){
projection_mapper.keyReleased(key);
}
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
projection_mapper.mouseDragged(x, y, button);
}
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button){
projection_mapper.mousePressed(x, y, button);
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
projection_mapper.mouseReleased(x, y, button);
}
//--------------------------------------------------------------

6
src/ofApp.h

@ -13,7 +13,8 @@
#include "ModelThread.h"
#include "Server.h"
#include "Request.h"
// #include "ofxPiMapper.h"
#include "ofxPiMapper.h"
#include "QuadSource/QuadSource.h"
class ofApp : public ofBaseApp{
@ -86,5 +87,6 @@ class ofApp : public ofBaseApp{
int app_h = 1080;
int app_w = 1512;
//ofxPiMapper mapper;
ofxPiMapper projection_mapper;
QuadSource quad_src;
};

Loading…
Cancel
Save