[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
特征:像素经过运算之后得到的某一个结果。
<>Harr特征
haar特征主要分为以下几类:
特征 = 整个区域权重1 + 黑色权重权重2
= (黑+白)1+黑(-2)
= 黑 + 白-黑2
= 白- 黑
遍历过程
从上到下从左到右依次遍历,要考虑图片以及模板大小。
当图片size=100100 模板size=1010,需要100张模板才能覆盖再有很多次缩放之后运算量就会很大。就引入了积分图。
积分图主要的思想:将图像从起点开始到各个点所形成的矩形区域像素之和作为一个数组的元素保存在内存中,当要计算某个区域的像素和时可以直接索引数组的元素,不用重新计算这个区域的像素和,从而加快了计算(这有个相应的称呼,叫做动态规划算法)。积分图能够在多种尺度下,使用相同的时间(常数时间)来计算不同的特征,因此大大提高了检测速度。
<>Adaboost分类器
Adaboost是一种迭代算法,其核心思想是针对同一个训练集训练不同的分类器(弱分类器),然后把这些弱分类器集合起来,构成一个更强的最终分类器(强分类器)。
强分类器(级联)<–弱分类器(计算强分类器特征)<–node结点
最多有3个haar特征对应一个node结点。
训练终止条件:
1、循环最大次数
2、最小检测概率
训练步骤
1、初始化数据权值分布-每个数据分配相等权值
2、遍历阈值p 找出最小阈值
3、
4、权值分布更新
#1 load xml ; 2 load jpg ; 3 haar gray ; 4 detect 5 ;draw import cv2 import
numpyas np #load xml face_xml = cv2.CascadeClassifier(
'haarcascade_frontalface_default.xml') eye_aml = cv2.CascadeClassifier(
'haarcascade_eye.xml') #load jpg img = cv2.imread('face.jpg')
#cv2.imshow('src',img) #haar(openCV) gray gray = cv2.cvtColor(img,cv2.
COLOR_BGR2GRAY) #detect 1 data 2 scale 3 5 faces = face_xml.detectMultiScale(
gray,1.3,5) print("faces=",len(faces)) #draw for (x,y,w,h) in faces: cv2.
rectangle(img,(x,y),(x+w,y+h),(255,0,0),2) roi_face = gray[y:y+h,x:x+w]
roi_color= img[y:y+h,x:x+w] eyes = eye_aml.detectMultiScale(roi_face) print(
'eye=',len(eyes)) for (e_x,e_y,e_w,e_h) in eyes: cv2.rectangle(roi_color,(e_x,
e_y),(e_x+e_w,e_y+e_h),(0,255,0),2) cv2.imshow("img",img) cv2.waitKey(0)