Esempio n. 1
0
int main (int argc, char * argv[] )
#endif
{
    int ans = 0;
    int camera_id = -1;
    bool camid_user_specified = false;
    VisionPipeLine::working_mode_t working_mode = VisionPipeLine::MODE_KEYBOARD; 
    bool opt_show_help = false;
    int pos = 1;

    // create the calibration result folder if it isn't existed.
    std::string config_path;
    config_path = getPlatformConfigPrefix();
    config_path += FILEPATH_LOC_CALIB_FOLDER;
    mkdir(config_path.c_str(), 0755);

    g_config_mgr.loadConfigFromFile();
    g_config_bundle.load();

    camera_id = g_config_bundle.default_cam_id;

    while (pos < argc) {
        char * current_opt = argv[pos];

        if (strcmp(current_opt, "-h") == 0 || strcmp(current_opt, "--help") == 0 ) {
            opt_show_help = true;
        } else if (strcmp(current_opt, "-m") == 0 ) {
            const char * modestr = argv[++pos];
            if (strcmp(modestr, "sketch") == 0) {
                working_mode = VisionPipeLine::MODE_SKETCHPAD;
            }  else if (strcmp(modestr, "calib") == 0) {
                working_mode = VisionPipeLine::MODE_CALIBRATION;
            }
        }  else {
            camera_id = atoi(argv[pos]);
            camid_user_specified = true;
        }
        ++pos;
    }

    if (opt_show_help) {
        show_help(argc, argv);
        return 0;
    }

    CameraSelector camsel;
    camsel.setPredefinedCamera(camera_id, camid_user_specified);

    camera_id = camsel.doModal();
    if (camera_id == -1) return 0;

  

    if (!dev_connect(camera_id)) {
        printf("error, cannot connect to the device. \n");
        return -2;
    }


    UpdateChecker::GetInstance()->sendQueryRequest(IsTargetProductPresent()?RELEASE_VENDOR_TYPE:"3rd", RELEASE_PRODUCT_TYPE, RELEASE_VERSION_INFO);
   

    

    g_config_bundle.default_cam_id = camera_id;
    
    // flush config
    g_config_bundle.flush();
    g_config_mgr.flushConfigFile();

    VisionPipeLine pipeline(cam_input);

    if (pipeline.init()) {
        pipeline.setWorkingMode(working_mode);

        std::string updateurl;
        bool update_checked = false;
        while(pipeline.heartBeat() && !checkPlatformExitFlag()) {
            if (UpdateChecker::GetInstance()->isResponseReady() && !update_checked) {
                update_checked = true;
                if (UpdateChecker::GetInstance()->getResponseUrl(updateurl)) {
                    pipeline.setUpgradeAvailable(updateurl);
                }
            }
        }
         
        
    }

    dev_disconnect();
    return ans;
}