- Detect objects in images, videos and video streaming from a webcam.
- A YOLOv3 predictor writen in python with keras.
- Product of a personal investigation to internalize myself in the matter.
- Strongly based :) on YOLOv3 and keras-yolo3.
Sample Video
Webcam Screenshot
Sample Image
- anaconda
- 7z
- A respectable video card. i.e. GeForce GTX 1060 or higher (Recommended).
- A respectable webcam. i.e Logitech c922 (Recommended).
Step 1: Create project environment.
conda env create --file environment.yml
Step 2: Extract network weights.
7z x model_data/yolo.h5.7z.001 -o./model_data
Step 3: Before all you need activate object-detector environment every time you use it with this:
source activate object-detector
or forget use it creating a bash/zsh alias:
-
bash
echo -e "export PATH=.:\$PATH:$PATH" >> ~/.bashrc echo "alias object-detector='source activate object-detector;python object-detector.py'" >> ~/.bashrc source ~/.bashrc
-
zsh
echo -e "export PATH=.:\$PATH:$PATH" >> ~/.zshrc echo "alias object-detector='source activate object-detector;python object-detector.py'" >> ~/.zshrc source ~/.zshrc
with this you can use object detector as a regular command in the following way:
object-detector params
instead of:
source activate object-detector
python object-detector.py params
-
Detect objects in an image:
object-detector \ --input-image input/image.jpg \ --output output/processed_image.jpg \ --predict-bounding-boxes
-
Detect objects on video:
object-detector \ --input-video input/video.mp4 \ --output output/processed_video.mp4 \ --predict-bounding-boxes \ --show-preview
-
Detect objects in a video streaming from webcam:
object-detector \ --input-webcam 0 \ --output output/processed_video.mp4 \ --output-fps 10 \ --predict-bounding-boxes \ --show-preview
Note:
--input-webcam
:0
is the integrated laptop webcam video port number, but also you can use another ports for external webcams or external video input devices. Values: From 0 to N. -
Press ESC key to end process. When input is a video this end process before process all video.
-
To view all options:
$ object-detector --help usage: object-detector [-h] [--input-image INPUT_IMAGE] [--input-video INPUT_VIDEO] [--output OUTPUT] [--input-webcam INPUT_WEBCAM] [--output-fps OUTPUT_FPS] [--show-preview] [--preview-width PREVIEW_WIDTH] [--predict-bounding-boxes] YOLO object detector :) optional arguments: -h, --help show this help message and exit --input-image INPUT_IMAGE Path of an image file. --input-video INPUT_VIDEO Path of a video file. --output OUTPUT Path of an output file. --input-webcam INPUT_WEBCAM Input video port. Available ports: [0, 2] (/dev/videoX). --output-fps OUTPUT_FPS Output video FPS. Often used with webcam input videos --show-preview Show preview window. --preview-width PREVIEW_WIDTH Preview window width. --predict-bounding-boxes Predict & plot bounding boxes
Note:You can see that
--input-webcam
description shows video ports of currently active devices. In this case:0
: Integrated laptop webcam.2
: External USB webcam.
-
...window.cpp:698: error: (-2:Unspecified error) The function is not implemented.
pip install --upgrade pip pip install opencv-contrib-python
-
macOS: Webcam input only works under classic terminal but not in another like iterm.
- Jupiter notebook to make transfer learning to predict another classes.
- Use Nvidia NVENC encoder/decoder (Process video using GPU cuda cores) to increase video frame rate.
- Rewrite yolo model to improve my understanding of the model.