Skip to content

Commit ec5cd92

Browse files
sc0v0neshoumikchow
authored andcommitted
build: rename folder demo to examples and create jupyter notebooks expand examples functions this package
1 parent e4b8262 commit ec5cd92

File tree

7 files changed

+637
-0
lines changed

7 files changed

+637
-0
lines changed

examples/env_examples.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#! /bin/bash
2+
python3 -m venv venv
3+
source venv/bin/activate
4+
pip install -r requirements_example.txt

examples/multiple_objects.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import json
2+
3+
import bbox_visualizer as bbv
4+
import cv2
5+
6+
img = cv2.imread('../images/source_multiple.jpg')
7+
annotation = json.load(open('../images/source_multiple.json'))
8+
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
9+
10+
labels = []
11+
bboxes = []
12+
for shape in annotation['shapes']:
13+
labels.append(shape['label'])
14+
mins = shape['points'][0]
15+
maxs = shape['points'][1]
16+
bboxes.append(mins + maxs)
17+
18+
img_with_boxes = bbv.draw_multiple_rectangles(img, bboxes)
19+
img_with_boxes_2 = img_with_boxes.copy()
20+
21+
img_with_boxes = bbv.add_multiple_labels(img_with_boxes, labels, bboxes)
22+
img_with_T_labels = bbv.add_multiple_T_labels(img_with_boxes_2, labels, bboxes)
23+
24+
img_with_flags = bbv.draw_multiple_flags_with_labels(img, labels, bboxes)

examples/multiple_objects_example.ipynb

Lines changed: 260 additions & 0 deletions
Large diffs are not rendered by default.

examples/requirements_example.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
opencv-python>=4.1.0.25
2+
notebook==7.0.4
3+
bbox-visualizer==0.1.0
4+
matplotlib==3.8.0

examples/simple_example.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
# Initialize example bbox-visualizer
3+
4+
Your machine use system operation Ubuntu/Pop_OS!:
5+
6+
Execute next steps:
7+
8+
```bash
9+
10+
cd examples
11+
12+
```
13+
14+
Run script to preparate environmet:
15+
16+
```bash
17+
18+
bash env_examples.sh
19+
20+
```

examples/single_object.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import json
2+
3+
import bbox_visualizer as bbv
4+
import cv2
5+
6+
img = cv2.imread('../images/source_single.jpg')
7+
annotation = json.load(open('../images/source_single.json'))
8+
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
9+
10+
points = annotation['shapes'][0]['points']
11+
label = annotation['shapes'][0]['label']
12+
(xmin, ymin), (xmax, ymax) = points
13+
bbox = [xmin, ymin, xmax, ymax]
14+
15+
img_with_box = bbv.draw_rectangle(img, bbox)
16+
img_with_box_2 = img_with_box.copy()
17+
18+
img_label = bbv.add_label(img_with_box, label, bbox)
19+
img_T_label = bbv.add_T_label(img_with_box_2, label, bbox)
20+
21+
img_flag = bbv.draw_flag_with_label(img, label, bbox)

examples/single_object_example.ipynb

Lines changed: 304 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)