本文整理汇总了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;
}
}
}
}