本文整理汇总了Python中imgaug.BoundingBoxesOnImage方法的典型用法代码示例。如果您正苦于以下问题:Python imgaug.BoundingBoxesOnImage方法的具体用法?Python imgaug.BoundingBoxesOnImage怎么用?Python imgaug.BoundingBoxesOnImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类imgaug
的用法示例。
在下文中一共展示了imgaug.BoundingBoxesOnImage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_on_same_height_width
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_on_same_height_width(self):
bb1 = ia.BoundingBox(y1=10, x1=20, y2=30, x2=40)
bb2 = ia.BoundingBox(y1=15, x1=25, y2=35, x2=45)
bbsoi = ia.BoundingBoxesOnImage([bb1, bb2], shape=(40, 50, 3))
bbsoi_projected = self._func(bbsoi, (40, 50))
assert bbsoi_projected.bounding_boxes[0].y1 == 10
assert bbsoi_projected.bounding_boxes[0].x1 == 20
assert bbsoi_projected.bounding_boxes[0].y2 == 30
assert bbsoi_projected.bounding_boxes[0].x2 == 40
assert bbsoi_projected.bounding_boxes[1].y1 == 15
assert bbsoi_projected.bounding_boxes[1].x1 == 25
assert bbsoi_projected.bounding_boxes[1].y2 == 35
assert bbsoi_projected.bounding_boxes[1].x2 == 45
assert bbsoi_projected.shape == (40, 50)
示例2: test_on_upscaled_by_2_with_shape_given_as_array
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_on_upscaled_by_2_with_shape_given_as_array(self):
bb1 = ia.BoundingBox(y1=10, x1=20, y2=30, x2=40)
bb2 = ia.BoundingBox(y1=15, x1=25, y2=35, x2=45)
bbsoi = ia.BoundingBoxesOnImage([bb1, bb2], shape=(40, 50, 3))
bbsoi_projected = self._func(bbsoi, np.zeros((40*2, 50*2, 3), dtype=np.uint8))
assert bbsoi_projected.bounding_boxes[0].y1 == 10*2
assert bbsoi_projected.bounding_boxes[0].x1 == 20*2
assert bbsoi_projected.bounding_boxes[0].y2 == 30*2
assert bbsoi_projected.bounding_boxes[0].x2 == 40*2
assert bbsoi_projected.bounding_boxes[1].y1 == 15*2
assert bbsoi_projected.bounding_boxes[1].x1 == 25*2
assert bbsoi_projected.bounding_boxes[1].y2 == 35*2
assert bbsoi_projected.bounding_boxes[1].x2 == 45*2
assert bbsoi_projected.shape == (40*2, 50*2, 3)
示例3: test_clip_out_of_image
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_clip_out_of_image(self):
bb1 = ia.BoundingBox(y1=10, x1=20, y2=30, x2=40)
bb2 = ia.BoundingBox(y1=15, x1=25, y2=35, x2=51)
bbsoi = ia.BoundingBoxesOnImage([bb1, bb2], shape=(40, 50, 3))
bbsoi_clip = self._func(bbsoi)
assert len(bbsoi_clip.bounding_boxes) == 2
assert bbsoi_clip.bounding_boxes[0].y1 == 10
assert bbsoi_clip.bounding_boxes[0].x1 == 20
assert bbsoi_clip.bounding_boxes[0].y2 == 30
assert bbsoi_clip.bounding_boxes[0].x2 == 40
assert bbsoi_clip.bounding_boxes[1].y1 == 15
assert bbsoi_clip.bounding_boxes[1].x1 == 25
assert bbsoi_clip.bounding_boxes[1].y2 == 35
assert np.isclose(bbsoi_clip.bounding_boxes[1].x2, 50)
示例4: test_from_xyxy_array_float
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_from_xyxy_array_float(self):
xyxy = np.float32([
[0.0, 0.0, 1.0, 1.0],
[1.0, 2.0, 3.0, 4.0]
])
bbsoi = ia.BoundingBoxesOnImage.from_xyxy_array(xyxy, shape=(40, 50, 3))
assert len(bbsoi.bounding_boxes) == 2
assert np.allclose(bbsoi.bounding_boxes[0].x1, 0.0)
assert np.allclose(bbsoi.bounding_boxes[0].y1, 0.0)
assert np.allclose(bbsoi.bounding_boxes[0].x2, 1.0)
assert np.allclose(bbsoi.bounding_boxes[0].y2, 1.0)
assert np.allclose(bbsoi.bounding_boxes[1].x1, 1.0)
assert np.allclose(bbsoi.bounding_boxes[1].y1, 2.0)
assert np.allclose(bbsoi.bounding_boxes[1].x2, 3.0)
assert np.allclose(bbsoi.bounding_boxes[1].y2, 4.0)
assert bbsoi.shape == (40, 50, 3)
示例5: test_from_xyxy_array_float_3d
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_from_xyxy_array_float_3d(self):
xyxy = np.float32([
[
[0.0, 0.0],
[1.0, 1.0]
],
[
[1.0, 2.0],
[3.0, 4.0]
]
])
bbsoi = ia.BoundingBoxesOnImage.from_xyxy_array(xyxy, shape=(40, 50, 3))
assert len(bbsoi.bounding_boxes) == 2
assert np.allclose(bbsoi.bounding_boxes[0].x1, 0.0)
assert np.allclose(bbsoi.bounding_boxes[0].y1, 0.0)
assert np.allclose(bbsoi.bounding_boxes[0].x2, 1.0)
assert np.allclose(bbsoi.bounding_boxes[0].y2, 1.0)
assert np.allclose(bbsoi.bounding_boxes[1].x1, 1.0)
assert np.allclose(bbsoi.bounding_boxes[1].y1, 2.0)
assert np.allclose(bbsoi.bounding_boxes[1].x2, 3.0)
assert np.allclose(bbsoi.bounding_boxes[1].y2, 4.0)
assert bbsoi.shape == (40, 50, 3)
示例6: test_from_xyxy_array_int32
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_from_xyxy_array_int32(self):
xyxy = np.int32([
[0, 0, 1, 1],
[1, 2, 3, 4]
])
bbsoi = ia.BoundingBoxesOnImage.from_xyxy_array(xyxy, shape=(40, 50, 3))
assert len(bbsoi.bounding_boxes) == 2
assert np.allclose(bbsoi.bounding_boxes[0].x1, 0.0)
assert np.allclose(bbsoi.bounding_boxes[0].y1, 0.0)
assert np.allclose(bbsoi.bounding_boxes[0].x2, 1.0)
assert np.allclose(bbsoi.bounding_boxes[0].y2, 1.0)
assert np.allclose(bbsoi.bounding_boxes[1].x1, 1.0)
assert np.allclose(bbsoi.bounding_boxes[1].y1, 2.0)
assert np.allclose(bbsoi.bounding_boxes[1].x2, 3.0)
assert np.allclose(bbsoi.bounding_boxes[1].y2, 4.0)
assert bbsoi.shape == (40, 50, 3)
示例7: test_from_point_soups__2d_array
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_from_point_soups__2d_array(self):
xy = np.float32([
[7, 3,
11, 5,
1, 7,
12, 19]
])
bbsoi = ia.BoundingBoxesOnImage.from_point_soups(
xy, shape=(40, 50, 3))
assert len(bbsoi.bounding_boxes) == 1
assert bbsoi.bounding_boxes[0].x1 == 1
assert bbsoi.bounding_boxes[0].y1 == 3
assert bbsoi.bounding_boxes[0].x2 == 12
assert bbsoi.bounding_boxes[0].y2 == 19
assert bbsoi.shape == (40, 50, 3)
示例8: test_from_point_soups__2d_list
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_from_point_soups__2d_list(self):
xy = [
[7, 3,
11, 5,
1, 7,
12, 19]
]
bbsoi = ia.BoundingBoxesOnImage.from_point_soups(
xy, shape=(40, 50, 3))
assert len(bbsoi.bounding_boxes) == 1
assert bbsoi.bounding_boxes[0].x1 == 1
assert bbsoi.bounding_boxes[0].y1 == 3
assert bbsoi.bounding_boxes[0].x2 == 12
assert bbsoi.bounding_boxes[0].y2 == 19
assert bbsoi.shape == (40, 50, 3)
示例9: test_to_xy_array
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_to_xy_array(self):
xyxy = np.float32([
[0.0, 0.0, 1.0, 1.0],
[1.0, 2.0, 3.0, 4.0]
])
bbsoi = ia.BoundingBoxesOnImage.from_xyxy_array(xyxy, shape=(40, 50, 3))
xy_out = bbsoi.to_xy_array()
expected = np.float32([
[0.0, 0.0],
[1.0, 1.0],
[1.0, 2.0],
[3.0, 4.0]
])
assert xy_out.shape == (4, 2)
assert np.allclose(xy_out, expected)
assert xy_out.dtype.name == "float32"
示例10: test_fill_from_xyxy_array___array_with_two_coords
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_fill_from_xyxy_array___array_with_two_coords(self):
xyxy = np.array(
[(100, 101, 102, 103),
(200, 201, 202, 203)], dtype=np.float32)
bbsoi = ia.BoundingBoxesOnImage(
[ia.BoundingBox(1, 2, 3, 4),
ia.BoundingBox(10, 20, 30, 40)],
shape=(2, 2, 3))
bbsoi = bbsoi.fill_from_xyxy_array_(xyxy)
assert len(bbsoi.bounding_boxes) == 2
assert bbsoi.bounding_boxes[0].x1 == 100
assert bbsoi.bounding_boxes[0].y1 == 101
assert bbsoi.bounding_boxes[0].x2 == 102
assert bbsoi.bounding_boxes[0].y2 == 103
assert bbsoi.bounding_boxes[1].x1 == 200
assert bbsoi.bounding_boxes[1].y1 == 201
assert bbsoi.bounding_boxes[1].x2 == 202
assert bbsoi.bounding_boxes[1].y2 == 203
示例11: test_fill_from_xy_array___array_with_two_coords
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_fill_from_xy_array___array_with_two_coords(self):
xy = np.array(
[(100, 101),
(102, 103),
(200, 201),
(202, 203)], dtype=np.float32)
bbsoi = ia.BoundingBoxesOnImage(
[ia.BoundingBox(1, 2, 3, 4),
ia.BoundingBox(10, 20, 30, 40)],
shape=(2, 2, 3))
bbsoi = bbsoi.fill_from_xy_array_(xy)
assert len(bbsoi.bounding_boxes) == 2
assert bbsoi.bounding_boxes[0].x1 == 100
assert bbsoi.bounding_boxes[0].y1 == 101
assert bbsoi.bounding_boxes[0].x2 == 102
assert bbsoi.bounding_boxes[0].y2 == 103
assert bbsoi.bounding_boxes[1].x1 == 200
assert bbsoi.bounding_boxes[1].y1 == 201
assert bbsoi.bounding_boxes[1].x2 == 202
assert bbsoi.bounding_boxes[1].y2 == 203
示例12: test_fill_from_xy_array___list_with_two_coords
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_fill_from_xy_array___list_with_two_coords(self):
xy = [(100, 101),
(102, 103),
(200, 201),
(202, 203)]
bbsoi = ia.BoundingBoxesOnImage(
[ia.BoundingBox(1, 2, 3, 4),
ia.BoundingBox(10, 20, 30, 40)],
shape=(2, 2, 3))
bbsoi = bbsoi.fill_from_xy_array_(xy)
assert len(bbsoi.bounding_boxes) == 2
assert bbsoi.bounding_boxes[0].x1 == 100
assert bbsoi.bounding_boxes[0].y1 == 101
assert bbsoi.bounding_boxes[0].x2 == 102
assert bbsoi.bounding_boxes[0].y2 == 103
assert bbsoi.bounding_boxes[1].x1 == 200
assert bbsoi.bounding_boxes[1].y1 == 201
assert bbsoi.bounding_boxes[1].x2 == 202
assert bbsoi.bounding_boxes[1].y2 == 203
示例13: test_shift_
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_shift_(self):
bb1 = ia.BoundingBox(y1=10, x1=20, y2=30, x2=40)
bb2 = ia.BoundingBox(y1=15, x1=25, y2=35, x2=51)
bbsoi = ia.BoundingBoxesOnImage([bb1, bb2], shape=(40, 50, 3))
bbsoi_shifted = bbsoi.shift_(y=2)
assert len(bbsoi_shifted.bounding_boxes) == 2
assert bbsoi_shifted.bounding_boxes[0].y1 == 10 + 2
assert bbsoi_shifted.bounding_boxes[0].x1 == 20
assert bbsoi_shifted.bounding_boxes[0].y2 == 30 + 2
assert bbsoi_shifted.bounding_boxes[0].x2 == 40
assert bbsoi_shifted.bounding_boxes[1].y1 == 15 + 2
assert bbsoi_shifted.bounding_boxes[1].x1 == 25
assert bbsoi_shifted.bounding_boxes[1].y2 == 35 + 2
assert bbsoi_shifted.bounding_boxes[1].x2 == 51
assert bbsoi_shifted is bbsoi
示例14: test_shift
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_shift(self):
bb1 = ia.BoundingBox(y1=10, x1=20, y2=30, x2=40)
bb2 = ia.BoundingBox(y1=15, x1=25, y2=35, x2=51)
bbsoi = ia.BoundingBoxesOnImage([bb1, bb2], shape=(40, 50, 3))
bbsoi_shifted = bbsoi.shift(y=2)
assert len(bbsoi_shifted.bounding_boxes) == 2
assert bbsoi_shifted.bounding_boxes[0].y1 == 10 + 2
assert bbsoi_shifted.bounding_boxes[0].x1 == 20
assert bbsoi_shifted.bounding_boxes[0].y2 == 30 + 2
assert bbsoi_shifted.bounding_boxes[0].x2 == 40
assert bbsoi_shifted.bounding_boxes[1].y1 == 15 + 2
assert bbsoi_shifted.bounding_boxes[1].x1 == 25
assert bbsoi_shifted.bounding_boxes[1].y2 == 35 + 2
assert bbsoi_shifted.bounding_boxes[1].x2 == 51
assert bbsoi_shifted is not bbsoi
示例15: test_invert_to_keypoints_on_image_
# 需要导入模块: import imgaug [as 别名]
# 或者: from imgaug import BoundingBoxesOnImage [as 别名]
def test_invert_to_keypoints_on_image_(self):
bbsoi = ia.BoundingBoxesOnImage(
[ia.BoundingBox(0, 1, 2, 3),
ia.BoundingBox(10, 20, 30, 40)],
shape=(1, 2, 3))
kpsoi = ia.KeypointsOnImage(
[ia.Keypoint(100, 101), ia.Keypoint(102, 103),
ia.Keypoint(104, 105), ia.Keypoint(106, 107),
ia.Keypoint(110, 120), ia.Keypoint(130, 140),
ia.Keypoint(150, 160), ia.Keypoint(170, 180)],
shape=(10, 20, 30))
bbsoi_inv = bbsoi.invert_to_keypoints_on_image_(kpsoi)
assert len(bbsoi_inv.bounding_boxes) == 2
assert bbsoi_inv.shape == (10, 20, 30)
assert bbsoi_inv.bounding_boxes[0].x1 == 100
assert bbsoi_inv.bounding_boxes[0].y1 == 101
assert bbsoi_inv.bounding_boxes[0].x2 == 106
assert bbsoi_inv.bounding_boxes[0].y2 == 107
assert bbsoi_inv.bounding_boxes[1].x1 == 110
assert bbsoi_inv.bounding_boxes[1].y1 == 120
assert bbsoi_inv.bounding_boxes[1].x2 == 170
assert bbsoi_inv.bounding_boxes[1].y2 == 180