Skip to content

Commit

Permalink
warp
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben committed Nov 18, 2010
1 parent 1e7cdb2 commit 4e58d06
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 21 deletions.
12 changes: 12 additions & 0 deletions src/SimpleThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class SimpleThread:public ofxRuiThread
bool bLearnBackground;
ofxCvContourFinder contourFinder;

ofPoint warpPoints[4];

SimpleThread()
{
//cam.initGrabber(640,480);
Expand All @@ -32,6 +34,15 @@ class SimpleThread:public ofxRuiThread
grayDiff.allocate(320,240);
bLearnBackground = true;
threshold = 80;

warpPoints[0].x = 0;
warpPoints[0].y = 0;
warpPoints[1].x = 320;
warpPoints[1].y = 0;
warpPoints[2].x = 320;
warpPoints[2].y = 240;
warpPoints[3].x = 0;
warpPoints[3].y = 240;
}

void updateThread()
Expand All @@ -42,6 +53,7 @@ class SimpleThread:public ofxRuiThread
{
colorImg.setFromPixels(cam.getPixels(), 320,240);
grayImg = colorImg;
grayImg.warpPerspective(warpPoints[0],warpPoints[1],warpPoints[2],warpPoints[3]);
if (bLearnBackground == true)
{
grayBg = grayImg; // the = sign copys the pixels from grayImage into grayBg (operator overloading)
Expand Down
12 changes: 12 additions & 0 deletions src/SimpleThread1.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ class SimpleThread1:public ofxRuiThread
bool bLearnBackground;
ofxCvContourFinder contourFinder;

ofPoint warpPoints[4];

SimpleThread1()
{
//cam.initGrabber(640,480);
Expand All @@ -32,6 +34,15 @@ class SimpleThread1:public ofxRuiThread
grayDiff.allocate(320,240);
bLearnBackground = true;
threshold = 80;

warpPoints[0].x = 0;
warpPoints[0].y = 0;
warpPoints[1].x = 320;
warpPoints[1].y = 0;
warpPoints[2].x = 320;
warpPoints[2].y = 240;
warpPoints[3].x = 0;
warpPoints[3].y = 240;
}

void updateThread()
Expand All @@ -43,6 +54,7 @@ class SimpleThread1:public ofxRuiThread
{
colorImg.setFromPixels(cam.getPixels(), 320,240);
grayImg = colorImg;
grayImg.warpPerspective(warpPoints[0],warpPoints[1],warpPoints[2],warpPoints[3]);
if (bLearnBackground == true)
{
grayBg = grayImg; // the = sign copys the pixels from grayImage into grayBg (operator overloading)
Expand Down
21 changes: 2 additions & 19 deletions src/testApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,30 +40,13 @@ void testApp::setup()
toggleDebugOutput = true;

//GUI
warpPoints1[0].x = 0;
warpPoints1[0].y = 0;
warpPoints1[1].x = 320;
warpPoints1[1].y = 0;
warpPoints1[2].x = 320;
warpPoints1[2].y = 240;
warpPoints1[3].x = 0;
warpPoints1[3].y = 240;

warpPoints2[0].x = 0;
warpPoints2[0].y = 0;
warpPoints2[1].x = 320;
warpPoints2[1].y = 0;
warpPoints2[2].x = 320;
warpPoints2[2].y = 240;
warpPoints2[3].x = 0;
warpPoints2[3].y = 240;

//gui.config->gridSize.set(340,0,0);
gui.addTitle("1");
//gui.config->gridSize.set(340,0,0);
gui.addQuadWarper("Cam 1", thread_1.colorImg, warpPoints1);
gui.addQuadWarper("Cam 1", thread_1.colorImg, thread_1.warpPoints);
gui.addTitle("2").newColumn = true;
gui.addQuadWarper("Cam 2", thread_2.colorImg, warpPoints2);
gui.addQuadWarper("Cam 2", thread_2.colorImg, thread_2.warpPoints);
gui.loadFromXML();
gui.show();
}
Expand Down
2 changes: 0 additions & 2 deletions src/testApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,6 @@ class testApp : public ofBaseApp

bool toggleDebugOutput, debug;
ofImage twoScreenImage;
ofPoint warpPoints1[4];
ofPoint warpPoints2[4];
};

#endif

0 comments on commit 4e58d06

Please sign in to comment.