Opencv的DPM算法提取图片目标

本文介绍了如何在Windows环境下,利用OpenCV 3.4.0和opencv_contrib进行DPM算法的行人检测。首先,文章提到了配置环境的具体步骤,接着提供了代码的GitHub链接和使用方法,包括模型路径、图片目录和处理文件名文件的设置。最后,文章提及了运行示例和可能遇到的问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

使用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
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值