Commit 502970b3 authored by berak's avatar berak

cvv: fix small memleak in demo

parent ff59193d
...@@ -28,13 +28,6 @@ template<class T> std::string toString(const T& p_arg) ...@@ -28,13 +28,6 @@ template<class T> std::string toString(const T& p_arg)
} }
void
usage()
{
printf("usage: cvv_demo [-r WxH]\n");
printf("-h print this help\n");
printf("-r WxH change resolution to width W and height H\n");
}
int int
...@@ -44,35 +37,29 @@ main(int argc, char** argv) ...@@ -44,35 +37,29 @@ main(int argc, char** argv)
// parser keys // parser keys
const char *keys = const char *keys =
"{ help h usage ? | | show this message }" "{ help h usage ? | | show this message }"
"{ resolution r |0x0| resolution to width and height in the format WxH }"; "{ width W | 0| camera resolution width. leave at 0 to use defaults }"
"{ height H | 0| camera resolution height. leave at 0 to use defaults }";
CommandLineParser parser(argc, argv, keys); CommandLineParser parser(argc, argv, keys);
string res(parser.get<string>("resolution"));
if (parser.has("help")) { if (parser.has("help")) {
usage(); parser.printMessage();
return 0; return 0;
} }
if (res != "0x0") { int res_w = parser.get<int>("width");
char dummych; int res_h = parser.get<int>("height");
resolution = new cv::Size();
if (sscanf(res.c_str(), "%d%c%d", &resolution->width, &dummych, &resolution->height) != 3) {
cout << res << " not a valid resolution" << endl;
return 1;
}
}
// setup video capture // setup video capture
cv::VideoCapture capture(0); cv::VideoCapture capture(0);
if (!capture.isOpened()) { if (!capture.isOpened()) {
std::cout << "Could not open VideoCapture" << std::endl; std::cout << "Could not open VideoCapture" << std::endl;
return 3; return 1;
} }
if (resolution) { if (res_w>0 && res_h>0) {
printf("Setting resolution to %dx%d\n", resolution->width, resolution->height); printf("Setting resolution to %dx%d\n", res_w, res_h);
capture.set(CV_CAP_PROP_FRAME_WIDTH, resolution->width); capture.set(CV_CAP_PROP_FRAME_WIDTH, res_w);
capture.set(CV_CAP_PROP_FRAME_HEIGHT, resolution->height); capture.set(CV_CAP_PROP_FRAME_HEIGHT, res_h);
delete resolution;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment