Skip to content

Commit c7124a4

Browse files
committed
Rename child_shapes for clarity
1 parent 17f364d commit c7124a4

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/cpp/models/include/models/results.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,11 @@ struct Contour {
315315
std::string label;
316316
float probability;
317317
std::vector<cv::Point> shape;
318-
std::vector<std::vector<cv::Point>> child_shapes;
318+
std::vector<std::vector<cv::Point>> excluded_shapes;
319319

320320
friend std::ostream& operator<<(std::ostream& os, const Contour& contour) {
321321
return os << contour.label << ": " << std::fixed << std::setprecision(3) << contour.probability << ", "
322-
<< contour.shape.size() << ", " << contour.child_shapes.size();
322+
<< contour.shape.size() << ", " << contour.excluded_shapes.size();
323323
}
324324
};
325325

src/python/model_api/models/result/segmentation.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,28 +149,31 @@ def rotated_rects(self, value):
149149

150150

151151
class Contour:
152-
"""Represents a contour object with label, probability, shape, and optional excluded shapes.
152+
"""Represents a semantic segmentation mask as internals of a contour with "holes".
153153
Args:
154154
label (str): The label of the contour.
155155
probability (float): The probability associated with the contour.
156-
shape (np.ndarray | list[tuple[int, int]]): The shape of the contour.
157-
child_shapes (list[np.ndarray] | list[tuple[int, int]] | None, optional): Shapes of excluded contours. Defaults to None.
156+
shape (np.ndarray | list[tuple[int, int]]): The shape of the contour. Shape is represented as a
157+
list of 2d points or an equivalent numpy array (N, 2).
158+
excluded_shapes (list[np.ndarray] | list[tuple[int, int]] | None, optional): Shapes of excluded contours.
159+
If empty, the main shape is simply connected. Otherwise, excluded_shapes
160+
represent "holes". Defaults to None.
158161
"""
159162

160163
def __init__(
161164
self,
162165
label: str,
163166
probability: float,
164167
shape: np.ndarray | list[tuple[int, int]],
165-
child_shapes: list[np.ndarray] | list[tuple[int, int]] | None = None,
168+
excluded_shapes: list[np.ndarray] | list[tuple[int, int]] | None = None,
166169
):
167170
self.shape = shape
168171
self.label = label
169172
self.probability = probability
170-
self.child_shapes = child_shapes
173+
self.excluded_shapes = excluded_shapes
171174

172175
def __str__(self):
173-
num_children = len(self.child_shapes) if self.child_shapes is not None else 0
176+
num_children = len(self.excluded_shapes) if self.excluded_shapes is not None else 0
174177
return f"{self.label}: {self.probability:.3f}, {len(self.shape)}, {num_children}"
175178

176179
def __repr__(self):

0 commit comments

Comments
 (0)