X-Git-Url: http://git.treefish.org/~alex/stickletrack.git/blobdiff_plain/c5b2e5fcf2f1f22edf6897dacaba496b165f10fd..e81c69eea555724e25ea911c274a1fa996363d4c:/stickletrack.cpp diff --git a/stickletrack.cpp b/stickletrack.cpp index 0db07ce..c5c8504 100755 --- a/stickletrack.cpp +++ b/stickletrack.cpp @@ -62,6 +62,13 @@ void genBaseDir() { cout << "Using " << Props.basedir << " for data output." << endl; } +bool isWindowClosed (const char* name) { + if ( cvGetWindowHandle(name) == NULL ) + return true; + else + return false; +} + void beforeExit() { cout << "Exitting ..." << endl; @@ -116,19 +123,19 @@ void drawTimes(Mat& mContours) { alles << framenum << " : " << fixed << (framenum)/(double)Props.fps << "s : +" << (double)moresleep/Props.fps << "ms"; string text = alles.str(); - int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX; + int fontFace = FONT_HERSHEY_DUPLEX; - double fontScale = Props.diagonal/1000.0; - int thickness = 3; + double fontScale = Props.width / 600.0; + int thickness = Props.width / 250.0; int baseline=0; Size textSize = getTextSize(text, fontFace, fontScale, thickness, &baseline); - Point textOrg(10, 10 + textSize.height); + Point textOrg(Props.width*0.01, Props.width*0.01 + textSize.height); rectangle(mContours, Point(0, 0), - Point(Props.width, 20+textSize.height), + Point(Props.width, Props.width*0.02 + textSize.height), Scalar(0,0,255), -1); putText(mContours, text, textOrg, fontFace, fontScale, @@ -356,7 +363,7 @@ int process(VideoCapture& capture) { char filename[200]; bool pleaseExit = false; - namedWindow("original", CV_WINDOW_KEEPRATIO); + namedWindow("stickletrack_original", CV_WINDOW_KEEPRATIO); Mat frame, origframe, combinedmask; @@ -390,9 +397,7 @@ int process(VideoCapture& capture) { openTanjaLog(); masking_init(); - tracking_init(); - - cvSetMouseCallback("contours_picture", mouseTracking, 0); + tracking_init(&mouseTracking); capture.set(CV_CAP_PROP_POS_FRAMES, 0); @@ -442,7 +447,8 @@ int process(VideoCapture& capture) { gotoframe = framenum + 1; - imshow("original", origframe/255.0); + if ( ! isWindowClosed("stickletrack_original") ) + imshow("stickletrack_original", origframe/255.0); } drawTimes(tracking_getFrame()); @@ -451,7 +457,8 @@ int process(VideoCapture& capture) { circle( tracking_getFrame(), Point2f(tags[nearestTags[0]].x, tags[nearestTags[0]].y), Props.diagonal / 100.0, Scalar(0,0,255), -1, 8 ); } - tracking_showFrame(); + if ( tracking_showFrame() ) + pleaseExit = true; char key; @@ -508,8 +515,6 @@ int main(int ac, char** av) { cerr << "Failed to open a video device or video file!\n" << endl; return 1; } - - cout << "Exit with q if you want to save your data!!!" << endl; return process(capture); }