def test_keep_inside(self):
inds_inside, anchors = self.inds_inside, self.anchors
min_x = anchors[:, 0].min()
min_y = anchors[:, 1].min()
max_x = anchors[:, 2].max()
max_y = anchors[:, 3].max()
canvas = np.zeros(
(int(max_y - min_y) + 1,
int(max_x - min_x) + 1), dtype=np.uint8)
anchors[:, 0] -= min_x
anchors[:, 1] -= min_y
anchors[:, 2] -= min_x
anchors[:, 3] -= min_y
for i, anchor in enumerate(anchors):
anchor = list(six.moves.map(int, anchor))
_canvas = np.zeros(
(int(max_y - min_y) + 1,
int(max_x - min_x) + 1), dtype=np.uint8)
cv.rectangle(
_canvas, (anchor[0], anchor[1]), (anchor[2], anchor[3]), 255)
cv.rectangle(
canvas, (anchor[0], anchor[1]), (anchor[2], anchor[3]), 255)
cv.imwrite('tests/anchors_inside_{}.png'.format(i), _canvas)
cv.imwrite('tests/anchors_inside.png'.format(i), canvas)
test_anchor_target_layer.py 文件源码
python
阅读 20
收藏 0
点赞 0
评论 0
评论列表
文章目录