Minor code cleanings in lkdemo.cpp
authorKirill Kornyakov <kirill.kornyakov@itseez.com>
Thu, 11 Apr 2013 13:57:33 +0000 (17:57 +0400)
committerKirill Kornyakov <kirill.kornyakov@itseez.com>
Thu, 11 Apr 2013 13:57:33 +0000 (17:57 +0400)
samples/cpp/lkdemo.cpp

index 47fc50e..bbb734c 100644 (file)
@@ -12,9 +12,8 @@ static void help()
 {
     // print a welcome message, and the OpenCV version
     cout << "\nThis is a demo of Lukas-Kanade optical flow lkdemo(),\n"
-            "Using OpenCV version %s\n" << CV_VERSION << "\n"
-            << endl;
-
+            "Using OpenCV version " << CV_VERSION << endl;
+    cout << "\nIt uses camera by default, but you can provide a path to video as an argument.\n";
     cout << "\nHot keys: \n"
             "\tESC - quit the program\n"
             "\tr - auto-initialize tracking\n"
@@ -30,15 +29,17 @@ static void onMouse( int event, int x, int y, int /*flags*/, void* /*param*/ )
 {
     if( event == CV_EVENT_LBUTTONDOWN )
     {
-        point = Point2f((float)x,(float)y);
+        point = Point2f((float)x, (float)y);
         addRemovePt = true;
     }
 }
 
 int main( int argc, char** argv )
 {
+    help();
+
     VideoCapture cap;
-    TermCriteria termcrit(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS,20,0.03);
+    TermCriteria termcrit(CV_TERMCRIT_ITER|CV_TERMCRIT_EPS, 20, 0.03);
     Size subPixWinSize(10,10), winSize(31,31);
 
     const int MAX_COUNT = 500;
@@ -56,8 +57,6 @@ int main( int argc, char** argv )
         return 0;
     }
 
-    help();
-
     namedWindow( "LK Demo", 1 );
     setMouseCallback( "LK Demo", onMouse, 0 );
 
@@ -140,12 +139,10 @@ int main( int argc, char** argv )
         case 'n':
             nightMode = !nightMode;
             break;
-        default:
-            ;
         }
 
         std::swap(points[1], points[0]);
-        swap(prevGray, gray);
+        cv::swap(prevGray, gray);
     }
 
     return 0;