文章

顯示從 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

Map Mat and IplImage | 連結Mat和IplImage

Because of using mat as mask filter, so I map mat to IplImage. The code below are IplImage to mat and mat to IplImage. Because those are pointer pointing to the same address,  they will affect the value. 因為打算用mat做mask filter的關系,所以要連結IplImage和mat。 以下的方法是 mat to iplimage 和 iplimage to mat。因為指向同一地址,所以任何一方作改變都會改變原始的數值。 //IplImage to Mat IplImage *img; cv::Mat mat(img, 0); //Mat to IplImage cv::Mat mat; IplImage *img = new IplImage(mat);