Skip to content
Snippets Groups Projects
Commit dfb80291 authored by Louis James's avatar Louis James
Browse files

deleted projector source; no longer using pimapper

parent c41b01aa
Branches
No related merge requests found
ofxCv
ofxGui
ofxOpenCv
ofxPiMapper
......@@ -3,20 +3,15 @@
//--------------------------------------------------------------
void Projector::setup(){
// pSource.set_ss(sharedState);
// mapper.registerFboSource(pSource);
mapper.setup();
}
//-------------------------------------------------------------
void Projector::update(){
mapper.update();
}
//--------------------------------------------------------------
void Projector::draw(){
ofBackground(0);
mapper.draw();
// for(int i =0; i < sharedState->num_colours; i++){
// sharedState->contourFinders[i].draw();
// }
......@@ -38,7 +33,6 @@ void Projector::draw(){
//--------------------------------------------------------------
void Projector::keyPressed(int key){
// mapper.keyPressed(key);
if (key == 'f') {
bFullscreen = !bFullscreen;
if (!bFullscreen) {
......@@ -55,19 +49,15 @@ void Projector::keyPressed(int key){
}
void Projector::keyReleased(int key){
mapper.keyReleased(key);
}
void Projector::mouseDragged(int x, int y, int button){
mapper.mouseDragged(x, y, button);
}
void Projector::mouseReleased(int x, int y, int button){
mapper.mouseReleased(x, y, button);
}
void Projector::mousePressed(int x, int y, int button){
mapper.mousePressed(x, y, button);
}
......
#pragma once
#include "VideoSource.h"
#include "ofMain.h"
#include "ofxPiMapper.h"
#include "projectorSource.h"
#include "State.h"
class Projector: public ofBaseApp {
......@@ -22,7 +19,6 @@ class Projector: public ofBaseApp {
float xp1, yp1;
int gwidth, gheight;
ofxPiMapper mapper;
shared_ptr<State> sharedState;
/* ProjectorSource pSource; */
......
......@@ -19,8 +19,10 @@ void ofApp::setup() {
cam.setDeviceID(camId);
if(camId==2){
cam.setup(1920, 1080);
xr = 20, yr = 20, wr = 1800, hr = 900;
} else if(camId==0){
cam.setup(640, 480);
xr = 20, yr = 20, wr = 300, hr = 200;
}
//contourFinder.setInvert(true); // find black instead of white
// initialise gui
......@@ -53,11 +55,10 @@ void ofApp::setup() {
vn.push_back(false);
}
// img1.load("pic1.png");
// img1Pix = img1.getPixels();
// for(int i = 0; i < img1Pix.size(); i++){
// }
//
xyb=false;
whb=false;
}
......@@ -66,7 +67,7 @@ void ofApp::update() {
// update camera
cam.update();
camPix = cam.getPixels();
camPix.cropTo(camPix, 100, 100, 300, 400);
camPix.cropTo(camPix, xr, yr, wr, hr);
// check new frame
if(cam.isFrameNew()) {
// Loop for number of colours and track target colours
......@@ -107,15 +108,27 @@ void ofApp::draw() {
// Draw anchor points and highlight when hovered
ofPushMatrix();
for(int i = 0; i < 4; i++){
ofSetColor(100, 244, 244, 100);
ofFill();
ofDrawCircle(sharedState->proPoints[i].x, sharedState->proPoints[i].y, 10);
if (vn[i]==true){
ofNoFill();
ofDrawCircle(sharedState->proPoints[i].x, sharedState->proPoints[i].y, 30);
}
// for(int i = 0; i < 4; i++){
// ofSetColor(100, 244, 244, 100);
// ofFill();
// ofDrawCircle(sharedState->proPoints[i].x,
// sharedState->proPoints[i].y, 10); if (vn[i]==true){
// ofNoFill();
// ofDrawCircle(sharedState->proPoints[i].x,
// sharedState->proPoints[i].y, 30);
// }
// }
ofSetColor(100, 244, 244, 100);
ofNoFill();
if(xyb==true){
ofDrawCircle(xr, yr, 30);
}
if(whb==true){
ofDrawCircle(xr+wr, yr+hr, 30);
}
ofFill();
ofSetColor(ofColor(255, 200, 233, 40));
ofDrawRectangle(xr, yr, wr, hr);
ofPopMatrix();
// img1.setFromPixels(img1Pix);
......@@ -145,31 +158,43 @@ void ofApp::keyReleased(int key){
//--------------------------------------------------------------
void ofApp::mouseMoved(int x, int y ){
// Anchor hover booleans
for(int i = 0; i < 4; i++){
if (ofDist(mouseX, mouseY, sharedState->proPoints[i].x, sharedState->proPoints[i].y) < 20){
vn[i] = true;
} else {
vn[i] = false;
}
// for(int i = 0; i < 4; i++){
// if (ofDist(mouseX, mouseY, sharedState->proPoints[i].x, sharedState->proPoints[i].y) < 20){
// vn[i] = true;
// } else {
// vn[i] = false;
// }
// }
if(ofDist(mouseX, mouseY, xr, yr) < 20){
xyb=true;
}
if (ofDist(mouseX, mouseY, xr+wr, yr+hr) < 20) {
whb=true;
}
}
//--------------------------------------------------------------
void ofApp::mouseDragged(int x, int y, int button){
// Control anchors
for(int i = 0; i < 4; i++){
if (ofDist(mouseX, mouseY, sharedState->proPoints[i].x, sharedState->proPoints[i].y) < 20){
sharedState->proPoints[i].x = mouseX;
sharedState->proPoints[i].y = mouseY;
sharedState->setvx(i, mouseX);
sharedState->setvy(i, mouseY);
}
// for(int i = 0; i < 4; i++){
// if (ofDist(mouseX, mouseY, sharedState->proPoints[i].x, sharedState->proPoints[i].y) < 20){
// sharedState->proPoints[i].x = mouseX;
// sharedState->proPoints[i].y = mouseY;
// sharedState->setvx(i, mouseX);
// sharedState->setvy(i, mouseY);
// }
// }
if (xyb) {
xr=mouseX;
yr=mouseY;
}
if (whb) {
wr=mouseX-xr;
hr=mouseY-yr;
}
}
//--------------------------------------------------------------
void ofApp::mouseReleased(int x, int y, int button){
......
......@@ -48,6 +48,9 @@ public:
ofImage camImage;
ofPixels camPix;
/* ofRectangle rect; */
int xr, yr, wr, hr;
bool xyb, whb;
};
#include "projectorSource.h"
#include "ofApp.h"
//------------------------------------------------------------------------
void ProjectorSource::setup(){
name = "Projector Source";
allocate(1920, 1080);
}
//------------------------------------------------------------------------
// Don't do any drawing here
void ProjectorSource::update(){
}
//------------------------------------------------------------------------
// No need to take care of fbo.begin() and fbo.end() here.
// All within draw() is being rendered into fbo;
void ProjectorSource::draw(){
// ofClear(0,0,0);
// ofBackground(0);
// for(int i = 0; i < ss->num_colours; i++){
// //ss->contourFinders[i].draw();
// vector<cv::Rect> boundingRects = ss->contourFinders[i].getBoundingRects();
// for(unsigned int j = 0; j < boundingRects.size(); j++){
// cv::Point2f p_;
// p_ = ss->contourFinders[i].getCenter(j);
// ofSetColor(255,200,255);
// ofNoFill();
// ofDrawCircle(p_.x, p_.y, 30);
// //ofDrawCircle(ofMap(p_.x,0, 640, 0, 1920),ofMap(p_.y, 0, 480, 0, 1080), 30);
// }
// }
//cout << ss->contourFinders.size() << endl;
}
//------------------------------------------------------------------------
void ProjectorSource::set_ss(shared_ptr<State> ss_) {
ss = ss_;
}
//------------------------------------------------------------------------
#pragma once
#include "ofMain.h"
#include "FboSource.h"
#include "State.h"
class ProjectorSource : public ofx::piMapper::FboSource {
public:
// ProjectorSource(shared_ptr<State> s);
void setup();
void update();
void draw();
void set_ss(shared_ptr<State>);
// Pointer to shared state class
shared_ptr<State> ss;
};
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment