文章

顯示從 6月, 2011 起發佈的文章

face detection | 臉部偵測

This is the basic face detection method provided by OpenCV. The algorithm behind is Haar-like feature*. The database (haarcascade_frontalface_alt2.xml) that is needed is in the opencv directory that you installed. This database only can detect front face. Flow: 1. load database(.xml) -> 2. cvHaarDetectObjects() detect face -> 3. receive data in cvrect format 這裡的臉部偵測是用OpenCV提供的基本功能。演算法是哈爾特徵*,數據庫(haarcascade_frontalface_alt2.xml)在安裝opencv的位置內。 流程: 1. 讀入數據庫(.xml) -> 2. 用cvHaarDetectObjects()辯認臉部 -> 3. 以cvrect接收位置 1. OpenCV provide function to read in database, if data read in is failed, cvLoad will return 0, so we can use if(!cascade) to check. 讀入數據庫的話可以直接使用OpenCV函式,如果讀入不成功的話 cvLoad 會歸還 0, 所以可以用if(!cascade)檢查。 CvHaarClassifierCascade *cascade=NULL; cascade = (CvHaarClassifierCascade*)cvLoad( CASCADEPATH, 0, 0, 0 ); if (!cascade)      exit(0); 2. if cascade successfully loaded in, we can load our source, after that call cvHaarDetectObjects(), remem