Feature #3957
This commit is contained in:

committed by
Maksim Shabunin

parent
5cdf0e3e89
commit
297808e6b9
@@ -148,23 +148,33 @@ static void writeOpticalFlowToFile(const Mat_<Point2f>& flow, const string& file
|
||||
|
||||
int main(int argc, const char* argv[])
|
||||
{
|
||||
if (argc < 3)
|
||||
cv::CommandLineParser parser(argc, argv, "{help h || show help message}"
|
||||
"{ @frame0 | | frame 0}{ @frame1 | | frame 1}{ @output | | output flow}");
|
||||
if (parser.has("help"))
|
||||
{
|
||||
cerr << "Usage : " << argv[0] << "<frame0> <frame1> [<output_flow>]" << endl;
|
||||
parser.printMessage();
|
||||
return 0;
|
||||
}
|
||||
string frame0_name = parser.get<string>("@frame0");
|
||||
string frame1_name = parser.get<string>("@frame1");
|
||||
string file = parser.get<string>("@output");
|
||||
if (frame0_name.empty() || frame1_name.empty() || file.empty())
|
||||
{
|
||||
cerr << "Usage : " << argv[0] << " [<frame0>] [<frame1>] [<output_flow>]" << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
Mat frame0 = imread(argv[1], IMREAD_GRAYSCALE);
|
||||
Mat frame1 = imread(argv[2], IMREAD_GRAYSCALE);
|
||||
Mat frame0 = imread(frame0_name, IMREAD_GRAYSCALE);
|
||||
Mat frame1 = imread(frame1_name, IMREAD_GRAYSCALE);
|
||||
|
||||
if (frame0.empty())
|
||||
{
|
||||
cerr << "Can't open image [" << argv[1] << "]" << endl;
|
||||
cerr << "Can't open image [" << parser.get<string>("frame0") << "]" << endl;
|
||||
return -1;
|
||||
}
|
||||
if (frame1.empty())
|
||||
{
|
||||
cerr << "Can't open image [" << argv[2] << "]" << endl;
|
||||
cerr << "Can't open image [" << parser.get<string>("frame1") << "]" << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -184,9 +194,8 @@ int main(int argc, const char* argv[])
|
||||
|
||||
Mat out;
|
||||
drawOpticalFlow(flow, out);
|
||||
|
||||
if (argc == 4)
|
||||
writeOpticalFlowToFile(flow, argv[3]);
|
||||
if (!file.empty())
|
||||
writeOpticalFlowToFile(flow, file);
|
||||
|
||||
imshow("Flow", out);
|
||||
waitKey();
|
||||
|
Reference in New Issue
Block a user