<cascade>
is an XML file that is compatible with the constructor for OpenCV's CascadeClassifier
class. For
an example of how to use CascadeClassifier
, refer back to our implementation of FaceTracker
in Chapter 4, Tracking Faces with Haar Cascades. By copying and modifying FaceTracker
and Cameo
, you should be able to create a simple test application that draws rectangles around tracked instances of your custom target.
Perhaps in your first attempts at cascade training, you will not get reliable tracking results. To improve your training results, do the following:
Consider making your classification problem more specific. For example, a
bald, shaven, male face without glasses
cascade might be easier to train than a generalface
cascade. Later, as your results improve, you can try to expand your problem again.Gather more training images, many more!
Ensure that
<negative_description>
contains all the negative training images and only the negative training images.Ensure that
<positive_description>
contains all the positive training images and only the positive training images.Ensure that the sub-rectangles specified in
<positive_description>
are accurate.Review and experiment with the optional flags to
<opencv_createsamples>
and<opencv_traincascade>
. The flags are described in the official documentation at http://docs.opencv.org/doc/user_guide/ug_traincascade.html.
Good luck and good image-hunting!