Vizualization for Detection and Tracking
Project description
VizDeT
Vizualization for Detection and Tracking
📦 PyPi | |
🐍 Conda | |
📖 Documentation | |
🔧 CI |
VIZDET - VIZualization for DEtection and Tracking. This library provides a simple interface to plot detection bounding boxes and their labels on an image. It enables the use of custom fonts, allowing you to create visually pleasing detection plots.
The purpose of this library is enable detection model creators to use an out-of-the-box library for presenting and visually evaluating their detection models, focusing their time on writing the detection models instead. Main features of vizdet are:
- Easy to use, enabling you to create detection plots with ease with minimal code
- Use of custom fonts to make the plots look beautiful and write special unicode characters and characters from non-latin scipts
- Customizable graphical parameters - customize plots according to your taste
- Out of the box options cover the main usecases for object detection, as well as (multi) object tracking - just plug in the detection/tracking results from your model, and you're ready to go
- Lightweight, with the only dependency being OpenCV (and Numpy)
Installation instructions
This module requires the freetype OpenCV module, which is not included in the PyPI repository package, so I recommend you install the package with conda (create a conda environment first):
conda install vizdet -c conda-forge
Quickstart
Let's create our first detection plot. Download this image and place it in your working directory. Then, execute this script (you'll also need to install matplotlib to visualize the results)
import cv2
import matplotlib.pyplot as plt
from vizdet import BBoxes, InfoBox
# Prepare our detection results
boxes = [
[ 6, 74, 156, 266],
[160, 80, 299, 258],
[283, 83, 469, 262],
[358, 250, 428, 273],
[ 0, 221, 48, 254],
[156, 244, 257, 270],
[272, 205, 319, 252],
[ 46, 254, 117, 278],
]
labels = [1, 1, 1, 0, 0, 0, 0, 0]
probs = [0.997, 0.995, 0.997, 0.975, 0.976, 0.993, 0.993, 0.992]
classes = ['rollerblade', 'person']
# Create text for info box
into_title = 'Number of objects'
info_desc = [f'{labels.count(idx)} {cl}s' for idx, cl in enumerate(classes)]
# Read image
img = cv2.imread('race.png')
# Prepare objects to draw
bboxes = BBoxes(labels_list=classes)
infobox = InfoBox(width=150)
# Draw detection results on the image
bboxes.draw(img, boxes, labels=labels, scores=probs)
infobox.draw(img, (440, 315), info_desc, into_title)
# Plot results
plt.imshow(img[::-1])
The result should be equal to the image above. We drew the detection boxes, shown their labels and probabilities, as well as an information box given some information what is on the image.
All the drawing is done by the BBoxes
and InfoBox
classes, which have a simple and intuitive interface. The default font (FiraGO) is used, but this could also be modified. Note that this looks much better than what you would get with the default OpenCV Hershey font.
The result ( img
) is a simply numpy array - not some custom plot object that you would get with Matplotlib or similar libraries. This enables you to further customize the image using other tools, if you would like, or to compose multiple images into a video and so on. The possibilities are endless 😉
License
This source code of this project is released under the Apache 2.0 License, which is available in the LICENSE
file.
The project also contains the FiraGO font, which is distributed under the SIL Open Font License. The test
directory also includes the FiraMono font, also released under the SIL Open Font License. A copy of the Open Font License is included in the OFL.txt
file.
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog.
[0.1.8] - 2021-07-26
Added
- Package now available to install from conda
[0.1.7] - 2021-05-18
Added
- Basic documentation on ReadTheDocs.
[0.1.6] - 2021-05-15
Changed
- Change argument names for
BBoxes
:boxes_coords
->bboxes
,items_ids
->ids
andlabels_conf
->scores
.
[0.1.5] - 2021-04-25
Fixed
- Improve type checking for integers to take into account numpy integers.
[0.1.4] - 2021-04-24
Added
- Throw an error is
boxes
elements inbboxes_coords
are not integers. - Explicitly allow numpy array as arguments to
BBoxes.draw
Fixed
- Improved check for
None
arguments inBBoxes
.
[0.1.3] - 2021-04-04
Changed
- Change default font sizes for
InfoBox
.
[0.1.2] - 2021-04-03
Added
- The
BBoxes
,InfoBox
,Label
andFont
classes, that can draw bouding objects on the image using custom TrueType fonts.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file vizdet-0.1.8.tar.gz
.
File metadata
- Download URL: vizdet-0.1.8.tar.gz
- Upload date:
- Size: 381.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c5c6df978dd3417a9f738d382ea6a20bea8dbad7cdec3be2a26b38c0d34658b7 |
|
MD5 | 1461371973495981666fe251c714cf05 |
|
BLAKE2b-256 | 3373e36e03f95c5704f2e831652f497fc6be3b774ff66b73696b08f47bd3af58 |
File details
Details for the file vizdet-0.1.8-py3-none-any.whl
.
File metadata
- Download URL: vizdet-0.1.8-py3-none-any.whl
- Upload date:
- Size: 377.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d23d58561ac3f4da77a7142559289fc488932abcef21d3350e391eb3be3584e |
|
MD5 | a5a68f6c5479e898cd4f2d202dada1cd |
|
BLAKE2b-256 | 974d2b6e9bc0f3376314e2ee28c11dd0aeeee196407da8513b8b5e9fa86c92b3 |