Skip to content

Detection, classification and counting of bottle caps from a video. Computer Vision project, Hochschule Bonn-Rhein-Sieg, Wintersemester 2020/21. 🎓

Notifications You must be signed in to change notification settings

s-esposito/CV-DetectTheBottleCap

Repository files navigation

H-BRS logo

Bottle Cap Detection Competition WS 20/21

Computer Vision challenge project, Hochschule Bonn-Rhein-Sieg, Wintersemester 2020/21. I have been asked to detect and count all bottle caps contained in a at rectangular container from a video, being also able to differentiate them according to the class they belong to.

Example

Input video Expected result
input video example

Motivation

This project is intended to be an hands on experience with a classic computer vision problem, allowing a better understanding of theoretical ideas behind it. Although this is a toy problem, the techniques developed to approach it can be used, with the necessary modifications, to solve more complex problems.

Object detection

Object Detection and 3 classes classification problem:

  • BottleCap_FaceUp
  • BottleCap_FaceDown
  • BottleCap_Deformed

The region of interest (ROI) is a rectangular-shaped with homogenous color, and it can also contain distractors objects, which we need to be able to distinguish those from the bottle caps. Also, objects outside the ROI should not be taken into account.

General input video sequence

General Sequence:

  • Start from a static (but not necessarily empty) scene;
  • Objects are thrown into the ROI;
  • The scene to becomes static;
  • Objects are removed from the ROI.

Tech/framework used

Dependences

  • OpenCV - Open Source Computer Vision Library.
  • Tensorflow 2 - The most popular Deep Learning framework created by Google.
  • tqdm - Fast, extensible progress bar for loops and CLI.

Usage example

Weights

The trained CNN weights can be downloaded here and should be placed inside the weights folder.

Launch the program given an input file.

python main.py -i example_1.mp4 -r results
python main.py -i example_2.mp4 -r results

Tests

The main components of the solution's algorithm can be tested separately.

Full dataset

In order to perform all tests, you need the complete dataset, which can be downloaded from here and should be placed inside the dataset folder.

  • Extract a static frame (minimum movements)
cd test_modules/test_static_frame_detection/
python main.py -v dataset/videos/CV20_video_1.mp4 -t dataset/images/CV20_image_1.png [-r ./results]
  • Extraction of the ROI and outsiders objects filtering
cd test_modules/test_roi_detection/
python main.py -f dataset/images/CV20_image_1.png -a dataset/annotations/CV20_label_renamed_1.json [-r ./results]
  • Object detection predictions
cd test_modules/test_object_detection/
python main.py -f ../../dataset/images/CV20_image_1.png -a ../../dataset/annotations/CV20_label_renamed_1.json [-r ./results]
  • Object detection results analysis (notebook)
notebooks/eval_predictions.ipynb

Credits

Credits to any blogposts or repo that contributed in this project development are cited and linked inside the code.

Meta

Stefano Esposito – [email protected]

https://github.com/yourname/github-link

About

Detection, classification and counting of bottle caps from a video. Computer Vision project, Hochschule Bonn-Rhein-Sieg, Wintersemester 2020/21. 🎓

Topics

Resources

Stars

Watchers

Forks

Languages