tester.py 文件源码

python
阅读 36 收藏 0 点赞 0 评论 0

项目:pycaffe-yolo 作者: Zehaos 项目源码 文件源码
def draw_label(self, image, label):
        img_shape = np.shape(image)
        mask = label[:, :, 0]
        locations = np.where(mask > 0)
        img = Image.fromarray(image)
        drawobj = ImageDraw.Draw(img)
        #print mask
        for [i, j] in zip(locations[0], locations[1]):
            l = label[i][j][:]
            yolo_box = l[1:5]
            x = yolo_box[0]
            y = yolo_box[1]
            w = yolo_box[2]
            h = yolo_box[3]
            width = w*img_shape[1]
            height = h*img_shape[0]
            xmin = int(x*img_shape[1] - 0.5*width)
            ymin = int(y*img_shape[0] - 0.5*height)
            xmax = int(xmin+width)
            ymax = int(ymin+height)
            drawobj.rectangle([xmin, ymin, xmax, ymax], outline="blue")
            drawobj.point([0.5*(xmin+xmax), 0.5*(ymin+ymax)])
            for k in range(0, 7):
                drawobj.line([448/7.0*k, 0, 448/7.0*k, 448])
                drawobj.line([0, 448 / 7.0 * k, 448, 448 / 7.0 * k])
            #print label[i][j]
        img.show()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号