First, let's see how we can use a cascade classifier to detect objects. Actually, we have already used cascade classifiers in this book. In Chapter 4, Fun with Faces, we used a pretrained cascade classifier to detect faces in real time. The pretrained cascade classifier we used was one of the OpenCV built-in cascade classifiers and can be found in the data directory of the OpenCV installation:
$ ls ~/programs/opencv/share/opencv4/haarcascades/
haarcascade_eye_tree_eyeglasses.xml haarcascade_lefteye_2splits.xml
haarcascade_eye.xml haarcascade_licence_plate_rus_16stages.xml
haarcascade_frontalcatface_extended.xml haarcascade_lowerbody.xml
haarcascade_frontalcatface.xml haarcascade_profileface.xml
haarcascade_frontalface_alt2.xml haarcascade_righteye_2splits.xml
haarcascade_frontalface_alt_tree.xml haarcascade_russian_plate_number.xml
haarcascade_frontalface_alt...