Skip to main content

Posts

Showing posts with the label Viola and jones

Nose Tracking using Kalman Filter and Viola and Jones Classifier

class atsKalman { public:     atsKalman()     {         KalmanFilter KF(4, 2, 0);         Mat_<float> state(4, 1); /* (x, y, Vx, Vy) */         Mat processNoise(4, 1, CV_32F);         Mat_<float> measurement(2,1);         measurement.setTo(Scalar(0));         KFs = KF;         measurements = measurement;     }     void setKalman(int x, int y)     {         KFs.statePre.at<float>(0) = x;         KFs.statePre.at<float>(1) = y;         KFs.statePre.at<float>(2) = 0;         KFs.statePre.at<float>(3) = 0;       ...

build a cascade of boosted classifiers based on Haar-like features

Step 1 - Tools Needed: You can find these executables as part of the opencv default installation. they are located in the BIN folder Samples: you should have alot of positive and negative images. Take note that compressed images such as jpeg have certain issues therefore selecting a BMP image is recommended. Create folders for the Negative and Positive images and include an info file aswell Basically there should be four sets of images that you work on: - a positive sample set representing your object that you want to train - another positive sample set for testing purpose - a negative sample set (or so-called backgrounds) for training - and another negative sample set for testing, too so your 2 folders containing the images are: /opencv/project/negative /opencv/project/positive as well as the info file: -train.txt -test.txt To work with these images in the utilities, a list of the files is needed. Using Win32 as host OS, you can get the list via command promt...

Viola and Jones Face identification

Check your Opencv2.2/data/haarcascades folder for a list of XML files you can use to identify human faces, bodies, nose, mouth, eyes and so on... just replace the xml file in the code with your desired data. NOTE: when you run this file in VisualStudio 2010, it will output an error. make sure you run the EXE file from the command prompt and place that XML file in the same directory as the EXE #include <stdlib.h> #include <stdio.h> #include <math.h> #include <string.h> #include<opencv2\opencv.hpp> #include <opencv2\highgui\highgui.hpp> CvHaarClassifierCascade *cascade; CvMemStorage *storage; void detectFaces( IplImage *img ); int main( int argc, char** argv ) { CvCapture *capture; IplImage *frame; int key =0; cascade = ( CvHaarClassifierCascade* )cvLoad("haarcascade_mcs_nose.xml", 0, 0, 0 ); storage = cvCreateMemStorage( 0 ); capture = cvCaptureFromCAM( 0 ); assert( cascade ...