def draw_rois(out,im_scale, rois,bbox,cls):
CV_AA = 16
print bbox.shape
for i in range(len(rois)):
n,x1,y1,x2,y2 = rois[i]
canvas = out.copy()
cv.rectangle(canvas, (x1, y1), (x2, y2), (255, 0, 0), 1, CV_AA)
cls_id=np.argmax(cls[i])
if cls[i][cls_id]>0.1 and cls_id != 0:
x1 = int(x1)
x2 = int(x2)
y1 = int(x1)
y2 = int(y2)
ret, baseline = cv.getTextSize(
CLASSES[cls_id], cv.FONT_HERSHEY_SIMPLEX, 0.8, 1)
cv.rectangle(out, (x1, y2 - ret[1] - baseline),
(x1 + ret[0], y2), (0, 0, 255), -1)
cv.putText(out, CLASSES[cls_id], (x1, y2 - baseline),
cv.FONT_HERSHEY_SIMPLEX, 0.8, (255, 255, 255), 1, CV_AA)
for j in range(0,84,4):
x1,y1,x2,y2 = bbox[i][j:j+4]
cv.rectangle(canvas, (x1, y1), (x2, y2), (255, 255, 0), 1, CV_AA)
cv.imshow("res",canvas)
cv.waitKey(0)
return out
评论列表
文章目录