#include "testApp.h" int imgWidth = 320; int imgHeight = 240; //-------------------------------------------------------------- void testApp::setup(){ /* vidGrabber.setVerbose(true); vidGrabber.initGrabber(320,240); // windows direct show users be careful // some devices (dvcams, for example) don't // allow you to capture at this resolution. // you will need to check, and if necessary, change // some of these values from 320x240 to whatever your camera supports // most webcams, firewire cams and analog capture devices will support this resolution. */ imgLoader.loadImage("images/camera_view.bmp"); // load image if there is no camera m_box.setup( 75, 100, 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 colorImg.allocate(imgWidth, imgHeight); // allocate memory grayImage.allocate(imgWidth, imgHeight); giWarped.allocate(imgWidth, imgHeight); grayImage.setFromPixels( imgLoader.getPixels(),imgWidth, imgHeight ); } //-------------------------------------------------------------- void testApp::update(){ ofBackground(180,180,180); ofPoint2f dstPts[4] = { {0,imgHeight}, {imgWidth,imgHeight}, {imgWidth,0}, {0,0} }; giWarped.warpIntoMe(grayImage, m_box.fHandles, dstPts ); /*vidGrabber.grabFrame(); if (vidGrabber.isFrameNew()){ colorImg.setFromPixels(vidGrabber.getPixels(), 320,240); grayImage.setFromColorImage(colorImg); giWarped = grayImage; ofPoint2f dstPts[4] = { {0,320}, {240,320}, {240,0}, {0,0} }; giWarped.warpIntoMe(grayImage, m_box.fHandles, dstPts ); }*/ } //-------------------------------------------------------------- void testApp::draw(){ ofSetColor(0xffffff); grayImage.draw(75,100); giWarped.draw( 405, 100 ); ofSetColor(0x000000); ofNoFill(); ofRect(75,100,320,240); ofRect(405,100,320,240); ofFill(); m_box.draw( 75, 100 ); ofSetColor(0x000000); char reportStr[1024]; sprintf(reportStr, "Original Image"); ofDrawBitmapString(reportStr, 75, 360); sprintf(reportStr, "Warped Image"); ofDrawBitmapString(reportStr, 405, 360); sprintf(reportStr, "Drag handles to warp image."); ofDrawBitmapString(reportStr, 75, 410); } //-------------------------------------------------------------- void testApp::keyPressed (int key){ switch (key){ } } //-------------------------------------------------------------- void testApp::mouseMoved(int x, int y ){ } //-------------------------------------------------------------- void testApp::mouseDragged(int x, int y, int button){ m_box.adjustHandle(x, y); } //-------------------------------------------------------------- void testApp::mousePressed(int x, int y, int button){ } //-------------------------------------------------------------- void testApp::mouseReleased(){ }