Professional Documents
Culture Documents
Overview
Challenge problem
Problem statement Source code overview Sliding-window detectors and Haar features Milestone requirements
OpenCV tutorial
Challenge Problem
Challenge Problem
Important Dates
team
milestone
final submission
Command-line Options
<directory> is the root directory containing (subdirectories of) all the training images -c <filename> writes learned parameters to a file after training using CClassifier::saveState() -h provides help -v gives verbose output
<AVI filename> is the name of the video you want to test on (e.g. easy.avi) -c <filename> configures the classifier with parameters from a file using CClassifier::loadState() -g <filename> displays ground truth labels from an XML file -h provides help -o <filename> saves classifications to an XML file (same format as g) -v gives verbose output -x disables display of the video (if you dont have X-windows)
CObject Class
class CObject { public: CvRect rect; std::string label;
public: // constructors CObject(); CObject(const CObject&); CObject(const CvRect&, const std::string&); // destructor virtual ~CObject(); // helper functions void writeAsXML(std::ostream&); void draw(IplImage *, CvScalar, CvFont *); CvRect intersect(const CObject&); int overlap(const CObject&); // operators CObject& operator=(const CObject&); };
CClassifier Class
class CClassifier { protected: CvRNG rng; CvMat *parameters; // TO DO: ADD YOUR MEMBER VARIABLES HERE public: // constructors and destructors CClassifier(); virtual ~CClassifier(); // load and save classifier configuration virtual bool loadState(const char *); virtual bool saveState(const char *); // run the classifier over a single frame virtual bool run(const IplImage *, CObjectList *);
// train the classifier using given set of files virtual bool train(TTrainingFileList&);
protected: // TO DO: ADD YOUR MEMBER FUNCTIONS HERE };
Overview
Challenge problem
Problem statement Source code overview Sliding-window detectors and Haar features Milestone requirements
OpenCV tutorial
Haar Features
Milestone Requirements
Build a decision tree classifier for the mug class using Haar features
Load positive and negative training images Convert to grayscale Resize to 64-by-64 Extract (given list of) Haar features Train decision tree Implement runtime code to run classifier over all scales (you can assume height = width for the milestone) and shifts (in increments of 8 pixels) within each video frame
Remember: after the milestone you are free to use whatever features and classifiers you like
Overview
Challenge problem
Problem statement Source code overview Sliding-window detectors and Haar features Milestone requirements
OpenCV tutorial
What is OpenCV?
The Open Computer Vision Library is a collection of algorithms and sample code for various computer vision problems:
libcxcore: core data structures and linear algebra library libcv: computer vision library libhighgui: media and graphics i/o handling libml: machine learning library (decision trees, boosting, neural networks)
Originally developed by Intel; now supported by Willow Garage Wiki has lots of information and API documentation
http://opencvlibrary.sourceforge.net/
Install ffmpeg
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg ./configure --prefix=<home> --enable-shared make && make install
Install opencv
http://sourceforge.net/projects/opencvlibrary/
tar -xvf opencv-1.0.0.tar.gz ./configure --prefix=<home> \ CPPFLAGS="-I<home>/include" \ LDFLAGS="-L<home>/lib" make && make install
1 1 exp T x ( i )
CvMat *logistic(const CvMat *X, const CvMat *theta) { assert(X->cols == theta->rows); CvMat *Y = cvCreateMat(X->rows, 1, CV_32FC1); for (int i = 0; i < X->rows; i++) { double sigma = 0.0; for (int j = 0; j < X->cols; j++) { sigma += cvmGet(X, i, j) * cvmGet(theta, j, 0); } cvmSet(Y, i, 0, 1.0 / (1.0 + exp(-1.0 * sigma)); } return Y; } // caller must free Y with cvReleaseMat
Overview
Challenge problem
Problem statement Source code overview Sliding-window detectors and Haar features Milestone requirements
OpenCV tutorial
OpenCV Tips
cvReleaseImage, cvReleaseMat
Try to allocate and free memory outside of loops if possible Image size is width-by-height; matrix size is rows-by-columns
[Viola and Jones, 2001], [Wolf, Serre and Poggio, 2004], [Lowe, 2004], [Dalal and Triggs, 2005], [Torralba, Murphy, and Freeman, 2007].
The milestone uses sliding-window based detector, but there are other techniques that you can try
template matching, chamfer matching/shape matching, bag-of-features with locality constraints, eigenspace representation, scene context, color
Try to normalize your features for intensity variation Filter the output of your classifiers and use motion estimation to predict where an object in frame n will be in frame n+1 Anything that works!
Coding Tips
Use OpenCV and other libraries, e.g., GSL, SVMLight, STAIR Vision Library (SVL)
Automate testing early Consider how you will avoid overfitting Test features without training an entire classifier (e.g., entropy function in Matlab) Visualization code usually pays off Profile your code and optimize bottlenecks (e.g., use integral images) Start early!
Example Results
A simple decision tree classifier trained using Haar features is not all that good so dont expect brilliant results
Milestone Results
Finally