Train a cascade classifier
Environment
- Python 2.7.15
- Windows 10
- opencv 3.4.3
Prepare Steps
- Clone the repository
git clone https://github.com/mrnugget/opencv-haar-classifier-training
- Install opencv. Reference the post face detection in python using webcam
- Samples
- positive sample for detect the object
- negative sample without the object
- How many images? 5000 is better than 1000
- factors:
- CPU power
- Quality of images
- Huge images
- Time
- Good samples
Experiments Steps
- Prepare 40 positive samples and 600 negative samples
- Prepare 40 positive samples. They have to differ in lighting and background.
- Collecting these pictures from:
- From internet
- Extract from video
- Scan
- Take a picture
- Crop pictures
- Collecting these pictures from:
- Resize image with FastStone Photo Resizer.
- Put these positive samples into the directory D:\Temp\opencv-haar-classifier-training\positive_images
- Write the path of image to a text file
find ./positive_images -iname "*.jpg" > positives.txt
Try the same function on Windows 10 with command:
dir /b/s positive_images\*.jpg>positives.txt
- Prepare 600 negative samples.
- Collecting these pictures from:
- Extract from video
- Collecting these pictures from:
- Save the list of paths to a text file
find ./negative_images -iname "*.jpg" > negatives.txt