#include <stdio.h>
#include <iostream>
#include <time.h>
+#include <unistd.h>
#include "oble.h"
#include "idle_x11.h"
using namespace std;
+static string cascade_filename = "";
+
// argument for cvFlip(src, dest, FLIP_TYPE)
#define MIRROR 1
}
}
+int parse_opts(int argc, char **argv)
+{
+ int index, c;
+ //int opterr=0, optopt=0, optind=0;
+ //char *optarg;
+ // int getopt(int argc, char **argv, const char *options);
+ opterr = 0;
+ const char *options = "c:";
+ while((c = getopt(argc, argv, options)) != -1)
+ switch(c)
+ {
+ case 'c':
+ cascade_filename = string(optarg);
+ printf("option c, argument = %s\n", optarg);
+ case '?':
+ if(optopt == 'c')
+ printf("option -%c requires an argument.\n", optopt);
+ else if(isprint (optopt))
+ printf("unknown option `-%c'.\n", optopt);
+ else
+ printf("unknown option char `\\x%x'.\n", optopt);
+ goto known_args_processed;
+ default:
+ abort();
+ }
+known_args_processed:
+
+ for(index = optind; index < argc; index++)
+ printf("Non-option arg %s\n", argv[index]);
+
+ return 0;
+}
+
// A Simple Camera Capture Framework.
int main(int argc, char** argv)
{
- CvHaarClassifierCascade* cascade = load_object_detector(argv[1]);
+ if(parse_opts(argc, argv)) return 0;
+
+ if(cascade_filename == "") cascade_filename = string(argv[1]);
+ CvHaarClassifierCascade* cascade =
+ load_object_detector(cascade_filename.c_str());
CvCapture* capture = cvCaptureFromCAM(CV_CAP_ANY);
if(!capture) {