mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
Merge pull request #801 from kirill-kornyakov:lkdemo-fix
This commit is contained in:
commit
b696d49d5a
@ -12,9 +12,8 @@ static void help()
|
|||||||
{
|
{
|
||||||
// print a welcome message, and the OpenCV version
|
// print a welcome message, and the OpenCV version
|
||||||
cout << "\nThis is a demo of Lukas-Kanade optical flow lkdemo(),\n"
|
cout << "\nThis is a demo of Lukas-Kanade optical flow lkdemo(),\n"
|
||||||
"Using OpenCV version %s\n" << CV_VERSION << "\n"
|
"Using OpenCV version " << CV_VERSION << endl;
|
||||||
<< endl;
|
cout << "\nIt uses camera by default, but you can provide a path to video as an argument.\n";
|
||||||
|
|
||||||
cout << "\nHot keys: \n"
|
cout << "\nHot keys: \n"
|
||||||
"\tESC - quit the program\n"
|
"\tESC - quit the program\n"
|
||||||
"\tr - auto-initialize tracking\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 )
|
if( event == CV_EVENT_LBUTTONDOWN )
|
||||||
{
|
{
|
||||||
point = Point2f((float)x,(float)y);
|
point = Point2f((float)x, (float)y);
|
||||||
addRemovePt = true;
|
addRemovePt = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main( int argc, char** argv )
|
int main( int argc, char** argv )
|
||||||
{
|
{
|
||||||
|
help();
|
||||||
|
|
||||||
VideoCapture cap;
|
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);
|
Size subPixWinSize(10,10), winSize(31,31);
|
||||||
|
|
||||||
const int MAX_COUNT = 500;
|
const int MAX_COUNT = 500;
|
||||||
@ -56,8 +57,6 @@ int main( int argc, char** argv )
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
help();
|
|
||||||
|
|
||||||
namedWindow( "LK Demo", 1 );
|
namedWindow( "LK Demo", 1 );
|
||||||
setMouseCallback( "LK Demo", onMouse, 0 );
|
setMouseCallback( "LK Demo", onMouse, 0 );
|
||||||
|
|
||||||
@ -134,17 +133,16 @@ int main( int argc, char** argv )
|
|||||||
needToInit = true;
|
needToInit = true;
|
||||||
break;
|
break;
|
||||||
case 'c':
|
case 'c':
|
||||||
|
points[0].clear();
|
||||||
points[1].clear();
|
points[1].clear();
|
||||||
break;
|
break;
|
||||||
case 'n':
|
case 'n':
|
||||||
nightMode = !nightMode;
|
nightMode = !nightMode;
|
||||||
break;
|
break;
|
||||||
default:
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::swap(points[1], points[0]);
|
std::swap(points[1], points[0]);
|
||||||
swap(prevGray, gray);
|
cv::swap(prevGray, gray);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user