Script for hat/beard classifying using opencv face detector.
Images are classified into two categories.
-
The presence of a headgear (class
hat): any headgear (hat, cap, etc.) is present or any headgear is completely absent. -
The presence of facial hair (class
beard): mustache, beard, noticeable stubble or any facial hair is completely absent.
There are HatBeardClassifier and SimpleFaceDetector classes provided.
See main.py as example of using these classes.
Install Python 3.x.
Clone repository and cd to project directory:
git clone https://github.com/Chifffa/hat_beard_classifier.git
cd hat_beard_classifierInstall dependencies:
pip install -r requirements.txtRun this to detect all faces in webcam 0 and classify them:
python main.py -v 0Or run this to process the video file:
python main.py -v path/to/video/file.aviWebcam/video will be shown frame-by-frame with all found and classified faces. Press q to stop and exit.
Run this to detect all faces in images in folder image_folder and classify them:
python main.py --images path/to/image_folderOr run this to classify whole images without face detection:
python main.py --images path/to/image_folder --no_detectorProcessed images will be shown frame-by-frame with all found and classified faces. Press any key to
continue to next image or press q to exit.


