import json
import cv2
import numpy as np
f = open('/home/lixuan/下载/icecream_seg_12.6.json')
for data in f.readlines():
data = data.strip()
Dict = json.loads(data)
content = Dict['content']
annotations = Dict['annotation']
w = annotations[0]['imageWidth']
h = annotations[0]['imageHeight']
mask = np.ones((h, w), dtype=np.uint8) + 254
for annotation in annotations:
points = np.array(annotation['points'])
points[:,0] *= w
points[:,1] *= h
points = np.array(points,dtype=np.int)
cv2.fillPoly(mask, [points], 53)
cv2.imwrite('stuff/{}'.format(content.split('/icecream_seg_12.6/')[-1].replace('jpg','png')),mask)
生成stuff
最新推荐文章于 2025-08-25 22:33:19 发布