Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions imgLabel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
if showdot:
image = go2frame(cap, frame_no, info)
showdot = False
5 changes: 3 additions & 2 deletions predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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')
Expand Down