Skip to content

Commit 2b5ce2b

Browse files
committed
Rename validation functions to private by prefixing with an underscore and update references accordingly.
1 parent 0bd35e8 commit 2b5ce2b

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

bbox_visualizer/core/_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import List, Tuple
44

55

6-
def validate_bbox(bbox: List[int]) -> None:
6+
def _validate_bbox(bbox: List[int]) -> None:
77
"""Validate bounding box format and values.
88
99
Args:
@@ -24,7 +24,7 @@ def validate_bbox(bbox: List[int]) -> None:
2424
)
2525

2626

27-
def validate_color(color: Tuple[int, int, int]) -> None:
27+
def _validate_color(color: Tuple[int, int, int]) -> None:
2828
"""Validate BGR color values.
2929
3030
Args:
@@ -56,7 +56,7 @@ def _check_and_modify_bbox(
5656
Returns:
5757
Adjusted bounding box coordinates [x_min, y_min, x_max, y_max]
5858
"""
59-
validate_bbox(bbox)
59+
_validate_bbox(bbox)
6060
bbox = [value if value > 0 else margin for value in bbox]
6161
bbox[2] = bbox[2] if bbox[2] < img_size[1] else img_size[1] - margin
6262
bbox[3] = bbox[3] if bbox[3] < img_size[0] else img_size[0] - margin

bbox_visualizer/core/flags.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
from typing import List, Tuple
77

8-
from ._utils import _check_and_modify_bbox, validate_bbox, validate_color
8+
from ._utils import _check_and_modify_bbox, _validate_bbox, _validate_color
99
from .rectangle import draw_rectangle
1010
from .labels import add_label
1111

@@ -41,8 +41,8 @@ def add_T_label(
4141
Returns:
4242
Image with added T-shaped label
4343
"""
44-
validate_color(text_bg_color)
45-
validate_color(text_color)
44+
_validate_color(text_bg_color)
45+
_validate_color(text_color)
4646
bbox = _check_and_modify_bbox(bbox, img.shape)
4747
(label_width, label_height), baseline = cv2.getTextSize(
4848
label, font, size, thickness
@@ -126,9 +126,9 @@ def draw_flag_with_label(
126126
Returns:
127127
Image with added flag label
128128
"""
129-
validate_color(line_color)
130-
validate_color(text_bg_color)
131-
validate_color(text_color)
129+
_validate_color(line_color)
130+
_validate_color(text_bg_color)
131+
_validate_color(text_color)
132132
bbox = _check_and_modify_bbox(bbox, img.shape)
133133
(label_width, label_height), baseline = cv2.getTextSize(
134134
label, font, size, thickness
@@ -204,8 +204,8 @@ def add_multiple_T_labels(
204204
if len(bboxes) != len(labels):
205205
raise ValueError("Number of bounding boxes must match number of labels")
206206

207-
validate_color(text_bg_color)
208-
validate_color(text_color)
207+
_validate_color(text_bg_color)
208+
_validate_color(text_color)
209209
for label, bbox in zip(labels, bboxes):
210210
img = add_T_label(
211211
img,
@@ -249,9 +249,9 @@ def draw_multiple_flags_with_labels(
249249
if len(bboxes) != len(labels):
250250
raise ValueError("Number of bounding boxes must match number of labels")
251251

252-
validate_color(line_color)
253-
validate_color(text_bg_color)
254-
validate_color(text_color)
252+
_validate_color(line_color)
253+
_validate_color(text_bg_color)
254+
_validate_color(text_color)
255255
for label, bbox in zip(labels, bboxes):
256256
img = draw_flag_with_label(
257257
img,

bbox_visualizer/core/labels.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
"""Functions for drawing labels."""
1+
"""Functions for adding text labels to bounding boxes."""
22

33
import cv2
44
import numpy as np
55
from typing import List, Tuple
66

7-
from ._utils import _check_and_modify_bbox, validate_bbox, validate_color
7+
from ._utils import _check_and_modify_bbox, _validate_bbox, _validate_color
88

99
font = cv2.FONT_HERSHEY_SIMPLEX
1010

@@ -39,8 +39,8 @@ def add_label(
3939
Returns:
4040
Image with added label
4141
"""
42-
validate_color(text_bg_color)
43-
validate_color(text_color)
42+
_validate_color(text_bg_color)
43+
_validate_color(text_color)
4444
bbox = _check_and_modify_bbox(bbox, img.shape)
4545

4646
(text_width, text_height), baseline = cv2.getTextSize(label, font, size, thickness)
@@ -147,8 +147,8 @@ def add_multiple_labels(
147147
if len(bboxes) != len(labels):
148148
raise ValueError("Number of bounding boxes must match number of labels")
149149

150-
validate_color(text_bg_color)
151-
validate_color(text_color)
150+
_validate_color(text_bg_color)
151+
_validate_color(text_color)
152152
for label, bbox in zip(labels, bboxes):
153153
img = add_label(
154154
img, label, bbox, size, thickness, draw_bg, text_bg_color, text_color, top

bbox_visualizer/core/rectangle.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy as np
55
from typing import List, Tuple
66

7-
from ._utils import _check_and_modify_bbox, validate_bbox, validate_color
7+
from ._utils import _check_and_modify_bbox, _validate_bbox, _validate_color
88

99

1010
def draw_rectangle(
@@ -28,7 +28,7 @@ def draw_rectangle(
2828
Returns:
2929
Image with drawn rectangle
3030
"""
31-
validate_color(bbox_color)
31+
_validate_color(bbox_color)
3232
bbox = _check_and_modify_bbox(bbox, img.shape)
3333

3434
output = img.copy()
@@ -67,7 +67,7 @@ def draw_multiple_rectangles(
6767
"""
6868
if not bboxes:
6969
raise ValueError("List of bounding boxes cannot be empty")
70-
validate_color(bbox_color)
70+
_validate_color(bbox_color)
7171
for bbox in bboxes:
7272
img = draw_rectangle(img, bbox, bbox_color, thickness, is_opaque, alpha)
7373
return img

0 commit comments

Comments
 (0)