1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Minor refactoring in several C++ samples:

- bgfg_segm
- peopledetect
- opencv_version
- dnn/colorization
- tapi/opencl_custom_kernel
- tapi/dense_optical_flow (renamed tvl1_optical_flow)
This commit is contained in:
Maksim Shabunin
2018-02-19 18:53:17 +03:00
parent dc1d9ae973
commit 1ae02c0cc4
7 changed files with 304 additions and 426 deletions
+12 -8
View File
@@ -1,3 +1,7 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/video.hpp"
@@ -10,10 +14,10 @@ using namespace cv;
int main(int argc, const char** argv)
{
const String keys = "{c camera||use video stream from camera (default is NO)}"
"{fn file_name|../data/tree.avi|video file}"
"{m method|mog2|method: background subtraction algorithm ('knn', 'mog2')}"
"{h help||show help message}";
const String keys = "{c camera | 0 | use video stream from camera (device index starting from 0) }"
"{fn file_name | | use video file as input }"
"{m method | mog2 | method: background subtraction algorithm ('knn', 'mog2')}"
"{h help | | show help message}";
CommandLineParser parser(argc, argv, keys);
parser.about("This sample demonstrates background segmentation.");
if (parser.has("help"))
@@ -21,7 +25,7 @@ int main(int argc, const char** argv)
parser.printMessage();
return 0;
}
bool useCamera = parser.has("camera");
int camera = parser.get<int>("camera");
String file = parser.get<String>("file_name");
String method = parser.get<String>("method");
if (!parser.check())
@@ -31,13 +35,13 @@ int main(int argc, const char** argv)
}
VideoCapture cap;
if (useCamera)
cap.open(0);
if (file.empty())
cap.open(camera);
else
cap.open(file.c_str());
if (!cap.isOpened())
{
cout << "Can not open video stream: '" << (useCamera ? "<camera 0>" : file) << "'" << endl;
cout << "Can not open video stream: '" << (file.empty() ? "<camera>" : file) << "'" << endl;
return 2;
}