Permalink
Browse files

Merge remote-tracking branch 'origin/master'

  • Loading branch information...
Damian @mba Damian @mba
Damian @mba authored and Damian @mba committed Apr 19, 2012
2 parents 6f73bda + ae7490d commit 3ea1b00e5e7d9b034232c645383eebeaa0a4364c
Showing with 78 additions and 21 deletions.
  1. +12 −0 bin/data/artverts-example.xml
  2. +53 −19 src/ArtvertiserApp.cpp
  3. +13 −2 src/binocular/BinocularMenu.cpp
@@ -0,0 +1,12 @@
+<artvert uid="20111121_155941315" alias="" advertName="Streak 7 Box">
+ <artwork>
+ <file>artverts/yourarthere.jpg</file>
+ <title>Your Art Here</title>
+ <artist>us</artist>
+ </artwork>
+</artvert>
+<artvert uid="20111122_140842980" alias="" advertName="" />
+<artvert uid="20111122_141949493" alias="" advertName="" />
+<artvert uid="20111122_223803075" alias="" advertName="" />
+<artvert uid="20111124_130107508" alias="" advertName="" />
+<artvert uid="20111124_140356630" alias="" advertName="" />
View
@@ -28,8 +28,12 @@
//void ofSoundShutdown(){};
-int camW = 640;
-int camH = 480;
+int camW = 800;
+int camH = 600;
+int detectW = 640;
+int detectH = 480;
+//int detectW = -1;
+//int detectH = -1;
//static const string SERVER_URL = "http://192.168.1.134:8888";
static const string SERVER_URL = "http://localhost:8888";
@@ -39,6 +43,7 @@ static const string SERVER_URL = "http://localhost:8888";
void ArtvertiserApp::setup(){
//ofSleepMillis(5000);
ofSetVerticalSync(true);
+// ofSetFrameRate( 30.0f );
//ofSetLogLevel(OF_LOG_VERBOSE);
ofBackground(66,51,51);
ofEnableAlphaBlending();
@@ -71,11 +76,35 @@ void ArtvertiserApp::setup(){
grabber.setUseTexture(false);
//grabber.setPixelFormat(OF_PIXELS_MONO);
grabber.initGrabber(camW, camH);
+ #ifdef TARGET_LINUX
+ ofLogNotice("ArtvertiserApp", "sleeping 10s to allow camera to recover");
+ // sleep to allow the camera to recover from init
+ sleep(10);
+ #endif
+
+
+
+ // drop the first few frames
+ int dropFrameCount = 0;
+ while ( dropFrameCount < 10 )
+ {
+ grabber.update();
+ if ( !grabber.isFrameNew() )
+ usleep( 1000*10 );
+ else
+ {
+ // const ofPixels& p = grabber.getPixelsRef();
+ ofLogVerbose("ArtvertiserApp") << "dropping frame "/* << p.getWidth() << "x" << p.getHeight()*/;
+ dropFrameCount++;
+ }
+ }
+
if ( CommandlineParser::get()->isRunningOnBinoculars() )
{
Binocular::get()->setup( grabber, /*bDebug*/ true );
+ ofHideCursor();
}
counter = 0;
@@ -232,6 +261,8 @@ void ArtvertiserApp::draw(){
w = float(camW)/float(camH)*float(h);
x = (ofGetWidth() - w)/2;
scale = float(w)/float(camW);
+ if ( detectW != -1 )
+ scale *= float(camW)/float(detectW);
grabber.draw(x,0,w,h);
}else{
circularPB.draw();
@@ -244,20 +275,23 @@ void ArtvertiserApp::draw(){
subs_img.draw(0,0);
ofPopMatrix();
}
- ofDrawBitmapString("fps: " + ofToString(ofGetFrameRate(), 2), x+20, 20);
- ofDrawBitmapString("detect fps: " + ofToString(artvertiser.getFps()), x+20, 40);
-
- if(artvertiser.getState()==Detector::Initializing){
- ofDrawBitmapString("Initializing", x+20, 60);
- }else if(artvertiser.isDetected()){
- ofDrawBitmapString("Detected", x+20, 60);
- }else if(artvertiser.isTracked()){
- ofDrawBitmapString("Tracked", x+20, 60);
- }else{
- ofDrawBitmapString("NotDetected", x+20, 60);
- }
+ if ( !CommandlineParser::get()->isRunningOnBinoculars() )
+ {
+ ofDrawBitmapString("fps: " + ofToString(ofGetFrameRate(), 2), x+20, 20);
+ ofDrawBitmapString("detect fps: " + ofToString(artvertiser.getFps()), x+20, 40);
+
+ if(artvertiser.getState()==Detector::Initializing){
+ ofDrawBitmapString("Initializing", x+20, 60);
+ }else if(artvertiser.isDetected()){
+ ofDrawBitmapString("Detected", x+20, 60);
+ }else if(artvertiser.isTracked()){
+ ofDrawBitmapString("Tracked", x+20, 60);
+ }else{
+ ofDrawBitmapString("NotDetected", x+20, 60);
+ }
- if(!allocated) ofDrawBitmapString("warning: not allocated", x+20, 80);
+ if(!allocated) ofDrawBitmapString("warning: not allocated", x+20, 80);
+ }
break;
}
}
@@ -353,11 +387,11 @@ void ArtvertiserApp::artvertSelected(ofFile & artvertimg){
Artvert & artvert = artvertInfo.getCurrentArtvert();
if(artvert.hasAlias()){
- artvertiser.setup(artvert.getAlias().getModel().getAbsolutePath(),grabber,imgQuad);
+ artvertiser.setup(artvert.getAlias().getModel().getAbsolutePath(),grabber,imgQuad, false, detectW, detectH );
ofLogVerbose("ArtvertiserApp", "artvert.hasAlias()");
}else{
ofLogVerbose("ArtvertiserApp", "doesn't: artvert.hasAlias()");
- artvertiser.setup(artvert.getModel().getAbsolutePath(),grabber,imgQuad);
+ artvertiser.setup(artvert.getModel().getAbsolutePath(),grabber,imgQuad, false, detectW, detectH );
}
}
@@ -384,11 +418,11 @@ void ArtvertiserApp::artvertSelectedBinoculars(Binocular::ArtvertSelectedEventIn
Artvert & artvert = info.selectedAdvert;
if ( artvert.hasAlias() )
{
- artvertiser.setup(artvert.getAlias().getModel().getAbsolutePath(),grabber,imgQuad);
+ artvertiser.setup(artvert.getAlias().getModel().getAbsolutePath(),grabber,imgQuad, false, detectW, detectH );
ofLogVerbose("ArtvertiserApp", "artvert.hasAlias()");
}else{
ofLogVerbose("ArtvertiserApp", "doesn't: artvert.hasAlias()");
- artvertiser.setup(artvert.getModel().getAbsolutePath(),grabber,imgQuad);
+ artvertiser.setup(artvert.getModel().getAbsolutePath(),grabber,imgQuad, false, detectW, detectH );
}
}
@@ -12,7 +12,7 @@
#include "Artvert.h"
#include "Binocular.h"
-static const float FONT_SIZE = 32.0f;
+static const float FONT_SIZE = 28.0f;
void BinocularMenu::setup( BinocularButtons& buttons )
@@ -47,7 +47,18 @@ void BinocularMenu::draw( ofEventArgs& args )
float lineHeight = fontSize+hGap;
// offset to keep the selection on-screen
- float yOffset = FONT_SIZE + max(selectionIndex-5,0)*lineHeight;
+ int linesPerScreen = float(ofGetHeight())/lineHeight;
+ int midLine = linesPerScreen/2;
+ float yOffset = FONT_SIZE;
+ if ( selectionIndex > midLine )
+ {
+ if ( selectionIndex < advertArtworkPairs.size()-midLine )
+ yOffset -= lineHeight*(selectionIndex-midLine);
+ else
+ yOffset -= lineHeight*(advertArtworkPairs.size()-2*midLine);
+ }
+
+ //float yOffset = FONT_SIZE - max(min(advertArtworkPairs.size()-4,selectionIndex-8),0)*lineHeight;
ofSetColor( ofColor::black );

0 comments on commit 3ea1b00

Please sign in to comment.