def show_tool_01(real, pred, show_shape):
"""
"""
real_shape = real.shape
pred_shape = pred.shape
_real = imgs_display(real, show_shape)
_pred = gray2rgb(imgs_display(pred, show_shape))
select_imgs = []
def tool(event, x, y, flags, param):
inx = int(x/real_shape[1])
iny = int(y/real_shape[2])
def find():
px = inx*pred_shape[1]
py = iny*pred_shape[2]
p = np.copy(_pred)
# cv2.putText(p, "x:%s y:%s px:%s py:%s"%(x,y,px,py), (px,py), cv2.FONT_HERSHEY_SIMPLEX, 0.2, (255, 255, 255), 1)
cv2.rectangle(p, (px, py), (px+pred_shape[1], py+pred_shape[2]), (0, 255, 0), 2)
cv2.imshow("PRED", p)
if event == cv2.EVENT_LBUTTONDOWN:
select_imgs = param[0]
select_imgs.append(pred[inx + iny*show_shape[1]])
select_imgs = select_imgs[-10*10:]
cv2.imshow("SELECT", imgs_display(np.array(select_imgs), [10]*2))
elif event == cv2.EVENT_MOUSEMOVE:
find()
elif event == cv2.EVENT_LBUTTONUP:
# cv2.destroyWindow(win_name)
pass
cv2.namedWindow("REAL")
cv2.setMouseCallback("REAL", tool, [select_imgs])
cv2.imshow("PRED", _pred)
# keep looping until the 'q' key is pressed
while True:
# display the image and wait for a keypress
cv2.imshow("REAL", _real)
key = cv2.waitKey(1) & 0xFF
if key == ord('q'):
break
cv2.destroyAllWindows()
评论列表
文章目录