opencv_海爾訓練剖析_L1

在opencv 下載下來之後

不管你是   opencv2.1版本   、 opencv2411版本  、 opencv3.0版本

都有一個檔案叫做

opencv_createsamples.exe





















為何要特別抓這個檔案出來做探討呢???

opencv開發者都知道  在opencv  這個路徑「C:\opencv2.1\data\haarcascades」裏頭

有一堆預設的  海爾分類器


Haar分類器又稱Viola-Jones識別器,
是Viola和Jones這兩個學者提出的理論,主要是為了提取人臉的 Haar 特徵,
使用積分圖對特徵進行快速計算
之後選出少的關鍵特徵,送入由強分類器組成的級聯分類器進行迭代訓練



Viola在2001年提出《Rapid Object Detection using a Boosted Cascade of Simple Features》

Jones在2004年提出《Robust Real-Time Face Detection》


【註: Haar分類器由 Haar 特徵提取、離散強分類器、強分類級聯器組成。】

在AdaBoost算法的基礎上,使用Haar-like小波特徵和積分圖方法進行人臉檢測,

這兩位學者並不是最早提出小波特徵的人,
但是他們設計了針對人臉檢測更有效的特徵,
並對AdaBoost訓練出的強分類器進行級聯。
對人臉偵測歷史上畫下了里程碑
因此當時提出的這個算法又被稱為Viola-Jones檢測器。
























Haar-like矩形特徵是用於物體偵測的數學圖像特徵。
這種矩形特徵模板是由兩個或兩個以上全等的黑白矩形相鄰組合而成,





矩形特徵值 = 白色矩形的灰度值總和 - 黑色矩形的灰度值總和





偵對一些簡單的圖形結構 : Ex : 線段、邊緣較為敏感

























如果把這樣的矩形放在一個非人臉區域,
那麼計算出的特徵值應該和人臉特徵值不一樣,









這些矩形主要目的就是為了把人臉特徵量化,以區分是人臉和不是人臉。



一般對已知物體類別總數的識別方式我們稱之為分類,
並且訓練的數據是有標籤的,
比如已經明確指定了是人臉還是非人臉,這是一種有監督學習。


為捨麼稱呼海爾特徵為 "Haar-like  feature" 呢?

這個名字是我從圖書館《Learning OpenCV》中文版這本書中提到的

Haar分類器使用到Haar特徵,但這種說法不恰當,

應該稱為 「類Haar特徵」 , 也就是 "Haar-like"的意思。




【實驗部分】



可實現  像是   人臉追蹤






















當然  有誤判的情形(門的上方雙窗口被誤視為眼睛)



























身體檢測
(兩個人 ---> 背景白色)

























人多時候的海爾分類器效果並不好








其他還有很多像是眼睛、嘴巴、鼻子、上半身、下半身等等已經訓練好的分類器xml檔
可以讓開發者作實驗

總計19項目
haarcascade_eye.xml
haarcascade_eye_tree_eyeglasses.xml
haarcascade_frontalface_alt.xml
haarcascade_frontalface_alt_tree.xml
haarcascade_frontalface_alt2.xml
haarcascade_frontalface_default.xml
haarcascade_fullbody.xml
haarcascade_lefteye_2splits.xml
haarcascade_lowerbody.xml
haarcascade_mcs_eyepair_big.xml
haarcascade_mcs_eyepair_small.xml
haarcascade_mcs_lefteye.xml
haarcascade_mcs_mouth.xml
haarcascade_mcs_nose.xml
haarcascade_mcs_righteye.xml
haarcascade_mcs_upperbody.xml
haarcascade_profileface.xml
haarcascade_righteye_2splits.xml
haarcascade_upperbody.xml



  在  2411版本  還可以觀察到  別於  之前  舊版(2.1)  還添加了

微笑識別等分類器



總計24項目

haarcascade_eye.xml
haarcascade_eye_tree_eyeglasses.xml
haarcascade_frontalface_alt.xml
haarcascade_frontalface_alt_tree.xml
haarcascade_frontalface_alt2.xml
haarcascade_frontalface_default.xml
haarcascade_fullbody.xml
haarcascade_lefteye_2splits.xml
haarcascade_licence_plate_rus_16stages.xml
haarcascade_lowerbody.xml
haarcascade_mcs_eyepair_big.xml
haarcascade_mcs_eyepair_small.xml
haarcascade_mcs_leftear.xml
haarcascade_mcs_lefteye.xml
haarcascade_mcs_mouth.xml
haarcascade_mcs_nose.xml
haarcascade_mcs_rightear.xml
haarcascade_mcs_righteye.xml
haarcascade_mcs_upperbody.xml
haarcascade_profileface.xml
haarcascade_righteye_2splits.xml
haarcascade_russian_plate_number.xml
haarcascade_smile.xml
haarcascade_upperbody.xml

























那你會好奇問說   我們難道不能訓練自己的「海爾分類器」嗎??

當然可以

在opencv2411路徑  " C:\opencv2411\sources\doc "  中
你可以找到官方針對海爾分類器如何訓練的說明文件


























點開之後就會看到






















Introduction

This document describes how to train and use a cascade of boosted classifiers for rapid object detection. A large set of over-complete haar-like features provide the basis for the simple individual classifiers. Examples of object detection tasks are face, eye and nose detection, as well as logo detection.

介紹

本文介紹了如何訓練和使用提高分類器的級聯快速物體檢測。
一個巨大過完備的Haar特徵提供簡單的個人分類的基礎。物件檢測任務舉例有像是
臉部,眼睛和鼻子的檢測,以及標誌檢測。


The sample detection task in this document is logo detection, since logo detection does not require the collection of large set of registered and carefully marked object samples. Instead we assume that from one prototype image, a very large set of derived object examples can be derived (createsamples utility, see below).


本文檔中的樣本偵測任務是採用「標誌檢測」,
因為「標誌偵測」不需要極大量的註冊並仔細標記的物件樣本的採集。
相反,我們假定從一個原型圖像,一個非常大的組的衍生的物件的例子可以被導出(createsamples效用,見下文)。













留言

  1. 不好意思 請問一下
    我想要偵測眼睛 但是都偵測不到
    有什麼辦法可以提高精確度嘛

    回覆刪除

張貼留言

這個網誌中的熱門文章

經得起原始碼資安弱點掃描的程式設計習慣培養(五)_Missing HSTS Header

經得起原始碼資安弱點掃描的程式設計習慣培養(三)_7.Cross Site Scripting(XSS)_Stored XSS_Reflected XSS All Clients

(2021年度)駕訓學科筆試準備題庫歸納分析_法規是非題