opencv行人检测
来源:互联网 发布:开源软件许可翻译 编辑:程序博客网 时间:2024/05/20 23:36
行人检测是视觉领域很热也很有用的一个主题,特别是在无人驾驶中,行人检测的重要性不言而喻。
在之前进行了人脸检测之后,行人检测就显得简单多了。过程大致与人脸检测一样,都是先加载分类器,然后进行多尺度检测。就偷懒不再赘述。感兴趣的可以看人脸检测的这一篇文章:OpenCV实践之路——人脸检测(C++/Python)
图片检测
#include<opencv2/highgui/highgui.hpp>#include<opencv2/imgproc/imgproc.hpp>#include<opencv2/objdetect.hpp>#include<iostream>usingnamespace std;usingnamespace cv;intmain(int argc, char **argv){Matimg;vector<Rect> found;/*if (argc != 2) {printf("can't find picture\n");return -1;}*/img = imread("F:\\1.jpg",1);HOGDescriptordefaultHog;defaultHog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());//默认模型,这个模型数据在OpenCV源码中是一堆常量数字,//这些数字是通过原作者提供的行人样本INRIAPerson.tar训练得到的defaultHog.detectMultiScale(img, found);// 画出长方形,框出人for (int i = 0; i < found.size(); i++) {Rect r = found[i];rectangle(img, r.tl(), r.br(), Scalar(0, 0, 255), 3);}namedWindow("Detect pedestrain", WINDOW_AUTOSIZE);imshow("Detect pedestrain", img);char c = waitKey(0);return0;}结果:
视频检测代码
#include<opencv2/highgui/highgui.hpp>#include<opencv2/imgproc/imgproc.hpp>#include<opencv2/objdetect.hpp>#include<iostream>usingnamespace std;usingnamespace cv;intmain(int argc, char **argv){Matimg;VideoCapturecap;vector<Rect> found;if(argc != 2) {printf("can't find picture\n");return -1;}cap.open(argv[1]);//img = cv::imread(argv[1]);while(1) {cap >> img;if (img.empty())break;HOGDescriptordefaultHog;defaultHog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());//默认模型,这个模型数据在OpenCV源码中是一堆常量数字,//这些数字是通过原作者提供的行人样本INRIAPerson.tar训练得到的defaultHog.detectMultiScale(img, found);// 画出长方形,框出人for (int i = 0; i < found.size(); i++) {Rect r = found[i];rectangle(img, r.tl(), r.br(), Scalar(0, 0, 255), 3);}namedWindow("Detect pedestrain", WINDOW_AUTOSIZE);imshow("Detect pedestrain", img);char c = waitKey(33);if (c == 27)break;}return0;}
阅读全文
0 0
- OpenCV中行人检测
- Opencv HOG检测行人
- Opencv HOG检测行人
- OpenCV中行人检测
- Opencv HOG行人检测
- 行人检测 opencv
- OpenCV行人检测
- opencv行人检测代码
- opencv行人跟踪检测
- opencv行人检测
- opencv学习-hog行人检测
- OpenCV 2.4+ C++ 行人检测
- 【行人检测】opencv自带
- OpenCV实现HOG行人检测
- 【opencv】hog做行人检测
- OpenCV 实现HOG行人检测
- OpenCV:人脸检测和行人检测
- QT5+OpenCV团块运动检测&行人检测
- redis的两种持久化
- 以LeNet为例分析CNN中的参数量
- 在Ubuntu下安装Python3.6.0
- apache性能测试工具ab使用详解
- 从损失函数的角度详解常见机器学习算法(1)
- opencv行人检测
- 线程并发学习----队列(Queue)
- poj1459
- 图论第五次课
- 浅谈React的类型检测——PropTypes
- HOG特征提取实现方法
- canvas (2) 上色、渐变
- (七)java并发包
- ssl2863-石子合并【dp练习】