使用Opencv的DPM算法进行检测行人,并提取存储
使用环境:win10+opencv3.4.0+opencv_contrib3.4.0+VS2017
环境配置方法: 参考该博客 https://www.cnblogs.com/aiwuzhi/p/7334514.html
本文代码GitHub地址:
---
待更新
---
使用方法:
编译本项目后,有三个参数:
model_path : 使用的模型,使用的模型在Opencv_contrib的包里
image_dir : 图片所在目录
image_list : 所处理文件名的文件
注意const string model_path = "D:\dpm\inriaperson.xml"; 是固定的
需要设置你的inriaperson.xml所在目录
编译完成后,可以只行exe文件
例:
PedestrianDetectorbyDPM.exe D:\dataset D:\test\files
第一个参数给image_dir,第二个参数给image_list
#include "dpm.hpp"
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <stdio.h>
#include <iostream>
#include <fstream>
#include<vector>
#include <io.h>
#include <string>
#include <sstream>
using namespace cv;
using namespace cv::dpm;
using namespace std;
const string model_path = "D:\\dpm\\inriaperson.xml";
int save_results(const string id, const vector<DPMDetector::ObjectDetection> ds, ofstream &out);
static void help()
{
cout << "\nThis example shows object detection on image sequences using \"Deformable Part-based Model (DPM) cascade detection API\n"
"Call:\n"
"./example_dpm_cascade_detect_sequence <model_path> <image_dir>\n"
"The image names has to be provided in \"files.txt\" under <image_dir>.\n"
<< endl;
}
static bool readImageLists(const string &file, vector<string> &imgFileList)
{
ifstream in(file.c_str(), ios::binary);
if (in.is_op