diff --git a/imgLabel.py b/imgLabel.py index c206094..7993cdc 100644 --- a/imgLabel.py +++ b/imgLabel.py @@ -63,9 +63,9 @@ # >: fast forward 36 frames # # <: fast backward 36 frames # # # # # # # # # # # # # # # # # - +showdot = False def ball_label(event, x, y, flags, param): - global frame_no, info, image + global frame_no, info, image, showdot if event == cv2.EVENT_LBUTTONDOWN: h, w, _ = image.shape info[frame_no]['x'] = x/w @@ -76,6 +76,8 @@ def ball_label(event, x, y, flags, param): info[frame_no]['x'] = -1 info[frame_no]['y'] = -1 info[frame_no]['Ball'] = 0 + + showdot = True saved_success = False frame_no = 0 @@ -162,4 +164,6 @@ def ball_label(event, x, y, flags, param): image = go2frame(cap, frame_no, info) print("Frame No.{}".format(frame_no)) else: - image = go2frame(cap, frame_no, info) \ No newline at end of file + if showdot: + image = go2frame(cap, frame_no, info) + showdot = False \ No newline at end of file diff --git a/predict.py b/predict.py index c0804b5..ba6673c 100644 --- a/predict.py +++ b/predict.py @@ -65,7 +65,8 @@ success = True frame_count = 0 num_final_frame = 0 -ratio = h / HEIGHT +h_ratio = h / HEIGHT +w_ratio = w / WIDTH out = cv2.VideoWriter(out_video_file, fourcc, fps, (w, h)) while success: @@ -123,7 +124,7 @@ else: img = frame_queue[i].copy() cx_pred, cy_pred = get_object_center(h_pred[i]) - cx_pred, cy_pred = int(ratio*cx_pred), int(ratio*cy_pred) + cx_pred, cy_pred = int(w_ratio*cx_pred), int(h_ratio*cy_pred) vis = 1 if cx_pred > 0 and cy_pred > 0 else 0 # Write prediction result f.write(f'{frame_count-(num_frame*batch_size)+i},{vis},{cx_pred},{cy_pred}\n')