Recently I came across a quite curious question:
How many places to sit are there in London?
Even if the answer shows no immediate use in a real-world scenario, it got me thinking. I was intrigued and now had to know how I could answer it.
The only problem is that this question does not specify which London.
It could be the biplane flying boat, the ship, the company, the music label, or the asteroid. But even if you stick to the city of London, you still have a list of cities with the same name.
That's why I decided to pick a more interesting definition: the 2005 american movie, starring Captain America Chris Evans, Jessica Biel and Jason Statham.
Had I ever heard of this movie? No. Does it look like I'd watch it? Also no.
But that's the reason we automate things, right? Do stuff we don't want to.
So, as any other person would do, I implemented a program that uses deep learning-based object detectors (in this case, Single Shot Detectors) and a pre-trained convolutional neural network model (Caffe) to detect chairs and sofas, track those objects, and count every time one of those items appeared on the screen playing whichever video you chose.
- Clone this repository
git clone github.com/viniciusvviterbo/banqo
cd banqo
yay -S python-dlib
- (Optional) Create and activate a virtual environment
virtualenv .venv
source .venv/bin/activate
- Install the project dependencies
pip3 install -r requirements.txt
python banqo.py [-h] [-p PROTOTXT] [-m MODEL] [-i INPUT] [-o OUTPUT] [-c CONFIDENCE] [-s SKIP_FRAMES]
- PROTOTXT: Path to the Coffe prototxt file;
- MODEL: Path to the pre-trained CNN model;
- INPUT: Path to the input video. If not informed, the program will use the webcam as a data source;
- OUTPUT: Path to the output video. If not informed, the program will not register any of the video generated;
- CONFIDENCE: Minimum probability threshold which helps to filter out weak detections.;
- SKIP_FRAMES: Number of frames to skip between detection phases;
Example:
python3 banqo.py --input videos/example_video.mp4
python3 banqo.py \
--prototxt mobilenet_ssd/MobileNetSSD_deploy.prototxt \
--model mobilenet_ssd/MobileNetSSD_deploy.caffemodel \
--input input/example_video_in.mp4 \