当前位置: 首页>>代码示例>>C++>>正文


C++ CommandLineOptions::addOption方法代码示例

本文整理汇总了C++中CommandLineOptions::addOption方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandLineOptions::addOption方法的具体用法?C++ CommandLineOptions::addOption怎么用?C++ CommandLineOptions::addOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandLineOptions的用法示例。


在下文中一共展示了CommandLineOptions::addOption方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: fd

int 
main(int argc, char* argv[])
{
    LibraryInitializer li;

    // parse arguments

    CommandLineOptions opt;
    opt.addOption('v', "videosource",            true,  "Use video source");
    opt.addOption('i', "images",                 false, "Use images");
    opt.addOption('d', "face-detector",          true,  "face detector file");
    opt.addOption('e', "eye-detector",           true,  "eye detector file");
    opt.addOption('m', "mouth-detector",         true,  "mouth detector file");
    opt.addOption('l', "low-resolution",         false, "Use resolution of 320x240 pixels");
    opt.addOption('s', "search-regions",         false, "Show eye and mouth search regions");
    opt.addOption(     "fps",                    false, "Display frames per second");
    opt.addOption('r', "draw-search-rectangles", false, "Draw the search rectangles (i.e. head, eye, etc.)");

    if (argc < 3)
    {
        printf(help_str, opt.helpString().c_str());
        exit(1);
    }

    string fd_fn, ed_fn, md_fn, videosource;
    bool low_resolution, display_fps, use_videosource, use_images, search_regions, display_search_rectangles;
    vector<string> images;
    try
    {
        images                    = opt.parse(argc, argv);
        fd_fn                     = opt.getArgument<string>("face-detector");
        ed_fn                     = opt.getArgument<string>("eye-detector", "");
        md_fn                     = opt.getArgument<string>("mouth-detector", "");
        videosource               = opt.getArgument<string>("videosource", "");
        low_resolution            = opt.parameterSet("low-resolution") > 0;
        display_fps               = opt.parameterSet("fps") > 0;
        use_videosource           = opt.parameterSet("videosource") > 0;
        use_images                = opt.parameterSet("images") > 0;
        search_regions            = opt.parameterSet("search-regions") > 0;
        display_search_rectangles = opt.parameterSet("draw-search-rectangles") > 0;
    }
    catch (CommandLineOptionException e)
    {
        printf(help_str, opt.helpString().c_str());
        exit(1);
    }

    if (!use_videosource && !use_images)
    {
        printf("Either '-v' or '-i' must be given\n");
        printf(help_str, opt.helpString().c_str());
        exit(1);
    }

    // Set up detectors
    BinaryPatternFaceDetector fd(fd_fn);
    fd.setScaleStep(1.2);
    fd.setNeighborDist(1.3);
    auto_ptr<BinaryPatternEyeDetector> ed;
    if (!ed_fn.empty())
        ed.reset(new BinaryPatternEyeDetector(ed_fn));
    auto_ptr<BinaryPatternMouthDetector> md;
    if (!md_fn.empty())
        md.reset(new BinaryPatternMouthDetector(md_fn));

    // Eye center detector
    typedef IsophoteEyeCenterDetector<double> iecd_t; // can be instantiated as float and double (choice defines the algorithmic precision [vs. run-time])
    iecd_t iecd;

    /* default parameters */
    // ...
    double isophote_row_sigma = 1;
    double isophote_col_sigma = 1;
    // options
    bool set_auto_isophote_sigma = false;

    // Set up GUI
    GuiThread thread;
    ImageWindow* imgwin = new ImageWindow("Detector Demo (cam)");
    thread.addClient(imgwin);
    // parameter control 
    okapi::WidgetWindow* win_params = new okapi::WidgetWindow("Parameter Window", 350/*widget width*/, 250/*label width*/);
    thread.addClient(win_params);
    // start the GUI thread
    thread.start();
    // set initial values
    win_params->setSlider("isophote row sigma (sigma)",          isophote_row_sigma, 0, 5);
    win_params->setSlider("isophote col sigma (sigma)",          isophote_col_sigma, 0, 5);     
    win_params->setButton("set auto sigma",                      set_auto_isophote_sigma);     
    win_params->setButton("display search rectangles",           display_search_rectangles);

    double old_ts = -1;
    double fps = -1;

    // Set up VideoSource
    auto_ptr<VideoSource> src;
    if (use_videosource)
    {
        if (videosource.empty() || videosource == "")
        {
//.........这里部分代码省略.........
开发者ID:bschauerte,项目名称:isophote-eye-center-detection,代码行数:101,代码来源:EyeCenterDetectorDemo.cpp


注:本文中的CommandLineOptions::addOption方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。