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


C++ VideoStream::get_current_frame_number方法代码示例

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


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

示例1: runDetection

void PedestrianDetector::runDetection() {
    // open the video stream
    VideoStream *vid = read_video_stream(config["dataset"]);
    vid->open();

    std::vector<BoundingBox> candidates;
    double hit_threshold = config["detector_opts"]["hit_threshold"].asDouble();

    std::ofstream out_file;
    if (config["output"]["save_log"].asBool()) {
        //std::cout << "It's going to save a log file in " << config.logFilename << std::endl;
        out_file.open(config["output"]["out_filename"].asString());
        if (out_file.fail()) {
            std::cerr << "open failure: " << strerror(errno) << '\n';
        }
    }

    while (!vid->has_ended()) {
        cv::Mat frame = vid->get_next_frame();

        // resize frame if needed.
        if (config["detector_opts"]["resize_image"].asDouble() != 1.0) {
            double f = config["detector_opts"]["resize_image"].asDouble();
            cv::resize(frame, frame, cv::Size(), f, f);
        }

        // begin timer
        clock_t frame_start = clock();

        std::vector<BoundingBox> detections;
        // if calibration is required and the candidates were not build yet
        if (config["detector_opts"]["use_calibration"].asBool()) {
            if (candidates.size() == 0) {
                candidates = generateCandidatesWCalibration(frame.rows, frame.cols, NULL);
                std::cout << "Number of candidates: " << candidates.size() << std::endl; 
            }

            // std::cout << "Its going to debug..." << std::endl;
            
            std::vector<cv::Mat> pyramid_images;
            std::vector<float> pyramid_scales;
            pyramid_images = computeImagePyramid(frame, pyramid_scales, 1.05);
            associateScaleToCandidates(candidates, pyramid_scales, frame.rows);

            // debugCandidates(frame, candidates, pyramid_scales);

            detections = detectWCandidates(candidates, pyramid_images, pyramid_scales, hit_threshold);

            std::cout << "Number of detections: " << detections.size() << std::endl;
            
        }
        else {
            std::vector<cv::Mat> pyramid_images;
            std::vector<float> pyramid_scales;
            pyramid_images = computeImagePyramid(frame, pyramid_scales, 1.05);

            detections = detectBaseline(pyramid_images, pyramid_scales, hit_threshold);
        }

        showDetections(frame, detections, cv::Scalar(0,200,0));
        detections = nonMaxSuppression(detections);
        showDetections(frame, detections, cv::Scalar(0,0,200));

        clock_t frame_end = clock();
        std::cout << "TIME: " << (double(frame_end - frame_start) / CLOCKS_PER_SEC) << std::endl;
        // end timer
        
        int f = vid->get_current_frame_number();
        if (config["output"]["save_frames"].asBool()) {
            std::stringstream ss;
            ss << config["output"]["out_folder"].asString() << format_int(f, 4) << ".jpg";
            std::cout << "Saving frame " << ss.str() << std::endl;
            cv::imwrite(ss.str(), frame);

        }

        if (config["output"]["save_log"].asBool()) {
            for (int i = 0; i < detections.size(); ++i) {
                out_file << f << " " << detections[i].bb.x << " " 
                         << detections[i].bb.y << " "  
                         << detections[i].bb.height << " "
                         << detections[i].bb.width << " "
                         << detections[i].score << std::endl;
            }
        }
    }
}
开发者ID:gustavofuhr,项目名称:pedestrian_detector_calibrated,代码行数:87,代码来源:pedestrian_detector.cpp


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