#include "testApp.h" int imgWidth = 320; int imgHeight = 240; //-------------------------------------------------------------- void testApp::setup(){ vidPlayer.loadMovie("movies/touchscreen0.mpg"); m_box.setup( 20, 270, imgWidth, imgHeight ); // set up interface for warping // first two values are off set for where to draw to the screen // second two values are w and h of image m_tracker.setup( imgWidth, imgHeight, 1280, 768); ciImg.allocate(imgWidth, imgHeight); // allocate memory giImg.allocate(imgWidth, imgHeight); giImg.set(0); bShowTouchScreen = true; // hard code box align values m_box.fHandles[0].x = 84.0f; m_box.fHandles[0].y = 119.0f; m_box.fHandles[1].x = 229.0f; m_box.fHandles[1].y = 125.0f; m_box.fHandles[2].x = 236.0f; m_box.fHandles[2].y = 67.0f; m_box.fHandles[3].x = 71.0f; m_box.fHandles[3].y = 60.0f; m_tracker.setScreenArea(m_box.fHandles); } //-------------------------------------------------------------- void testApp::update(){ vidPlayer.idleMovie(); ciImg.setFromPixels(vidPlayer.getPixels(),imgWidth, imgHeight); giImg.setFromColorImage(ciImg); // mirror the image becuase the video is recored upside down (oops) giImg.mirror(true,false); giImg += 30; m_tracker.update( giImg ); } //-------------------------------------------------------------- void testApp::draw(){ ofSetColor(0xffffff); giImg.draw(20,270); m_box.draw(20,270); ofSetColor(0xffffff); m_tracker.giBgImage.draw(350,270); m_tracker.giScreenArea.draw(20,20); m_tracker.giAllTouchArea.draw(350,20); m_tracker.giWarpTouchArea.draw(680,20); ofSetColor(0xa1a1a1); glPushMatrix(); glTranslatef(350,20,0); glBegin( GL_LINE_STRIP ); glVertex2f(m_box.fHandles[0].x, m_box.fHandles[0].y); glVertex2f(m_box.fHandles[1].x, m_box.fHandles[1].y); glVertex2f(m_box.fHandles[2].x, m_box.fHandles[2].y); glVertex2f(m_box.fHandles[3].x, m_box.fHandles[3].y); glVertex2f(m_box.fHandles[0].x, m_box.fHandles[0].y); glEnd(); glPopMatrix(); ofSetColor(0x000000); // labels ofDrawBitmapString("T: Hide/Show on screen track positions.\n\nB: Background Capture\n", 680, 360); if(bShowTouchScreen) m_tracker.drawTouchingPoints(); } //-------------------------------------------------------------- void testApp::keyPressed (int key){ switch (key){ case 'b': m_tracker.bgCapture(giImg); break; case 't': bShowTouchScreen = (bShowTouchScreen) ? false : true; break; } } //-------------------------------------------------------------- void testApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void testApp::mouseDragged(int x, int y, int button){ m_box.adjustHandle(x, y); m_tracker.setScreenArea(m_box.fHandles); } //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mouseReleased(){ }