openCV study-Moudle7_object deteciton目标检测

https://docs.opencv.org/master/d2/d64/tutorial_table_of_content_objdetect.html

https://github.com/makelove/OpenCV-Python-Tutorial

 


理论:

https://www.cnblogs.com/ello/archive/2012/04/28/2475419.html#!comments

注:聚类和分类的区别是什么?一般对已知物体类别总数的识别方式我们称之为分类,并且训练的数据是有标签的,比如已经明确指定了是人脸还是非人脸,这是一种有监督学习。也存在可以处理类别总数不确定的方法或者训练的数据是没有标签的,这就是聚类,不需要学习阶段中关于物体类别的信息,是一种无监督学习。

其中包括Mahalanobis距离、K均值、朴素贝叶斯分类器、决策树、Boosting、随机森林、Haar分类器、期望最大化、K近邻、神经网络、支持向量机。

我们要探讨的Haar分类器实际上是Boosting算法的一个应用

Haar分类器 =  Haar-like特征 + 积分图方法 + AdaBoost + 级联; 

Haar-like特征: 特征描述 就是前面学的,梯度变换的的部分(边缘,线条,中心 etc) , 多特征-可以定义多个分类筛选函数f1,f2,f3...

积分图方法: 计算特征描述的数学技巧(可以提高处理速度)

AdaBoost :AdaBoost是一种具有一般性的分类器提升算法。把某一个弱分类器,的准确率提升的数学技巧---,FP 的数据放入样本反复N 次训练,以提高训练结果。

决策树:激活函数,和阈值比较,输出0/1。-层就是一个分类器。多层,就是多个分类器的级联

(强分类器)级联: 如上图的多层决策树,就是级联的结果  。

级联的英文:


应用:

1.训练模型( https://docs.opencv.org/3.3.0/d7/d8b/tutorial_py_face_detection.html) open CV 提供了训练好的分类器。直接应用

2.应用模型检测任意图片

3.输出目标检测结果,包含(boundary box  坐标<x,y> ,大小,标签

cv::CascadeClassifier::detectMultiScale method, which returns boundary rectangles for the detected faces or eyes.


void cv::CascadeClassifier::detectMultiScale	(	InputArray 	image,
std::vector< Rect > & 	objects,
std::vector< int > & 	numDetections,
double 	scaleFactor = 1.1,
int 	minNeighbors = 3,
int 	flags = 0,
Size 	minSize = Size(),
Size 	maxSize = Size() 
)		
Python:
objects	=	cv.CascadeClassifier.detectMultiScale(	image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]	)
objects, numDetections	=	cv.CascadeClassifier.detectMultiScale2(	image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize]]]]]	)
objects, rejectLevels, levelWeights	=	cv.CascadeClassifier.detectMultiScale3(	image[, scaleFactor[, minNeighbors[, flags[, minSize[, maxSize[, outputRejectLevels]]]]]]	)
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
image	Matrix of the type CV_8U containing an image where objects are detected.
objects	Vector of rectangles where each rectangle contains the detected object, the rectangles may be partially outside the original image.
numDetections	Vector of detection numbers for the corresponding objects. An object's number of detections is the number of neighboring positively classified rectangles that were joined together to form the object.
scaleFactor	Parameter specifying how much the image size is reduced at each image scale.
minNeighbors	Parameter specifying how many neighbors each candidate rectangle should have to retain it.
flags	Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.
minSize	Minimum possible object size. Objects smaller than that are ignored.
maxSize	Maximum possible object size. Objects larger than that are ignored. If maxSize == minSize model is evaluated on single scale.

CV_Lesson55_Haar级联分类器_目标检测.py

练习: 做一个视频的人脸追踪。TBD

CV_Lesson56_Haar级联分类器_人眼识别_视频.py


TBD : 用新的数据集(准备数据,标注), 训练模型学习一个新的特征,比如交通标示, etc. 

行人检测的code,库文件有问题。 

 


 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值