BBTools is a Python library for bounding box manipulations.
First, clone the project to your local machine:
git clone https://github.com/alexPhimanesone/BBTools.git
Make sure you're using Python 3.8 or later.
-
Navigate to the project directory:
cd BBTools
-
Install the dependencies
pip install requirements
-
Install the package locally
pip install .
python unrotate_annotations.py --help
usage: unrotate_annotations.py [-h] [--annot_file ANNOTATION_FILE] [--out_file OUTPUT_FILE] [--p_length P_LENGTH] [--p_width P_WIDTH]
Convert from oriented bounding boxes in format [cx, cy, w, h, angle] to straight boxes in format [tlx, tly, w, h]
options:
-h, --help show this help message and exit
--annot_file ANNOTATION_FILE
Name of the .csv file in MOTChallenge format.
--out_file OUTPUT_FILE
Name of the output .csv file
--p_length P_LENGTH proportion of the length to remove in the corners.
--p_width P_WIDTH proportion of the width to remove in the corners.
Command line example:
python unrotate_annotations.py --annot_file data/annotation_example.csv --out_file annotation_example_straight.csv
# Plot straight rectangles on image
python plot_csv_rectangles.py
import numpy as np
import bb_tools.obb_to_sbb
OBBs = np.array([[ 10.0, 5.0, 15.0, 20.0, 30],
[-20.0, -40.0, 20.0, 30.0, 300]])
SBBs, _ = bb_tools.obb_to_sbb.get_SBBs(OBBs, p_length=0.1, p_width=0.1)