fix/upload-outputs-and-hough-shape

#2
Files changed (2) hide show
  1. app.py +2 -2
  2. pipeline/autolines.py +7 -2
app.py CHANGED
@@ -54,7 +54,7 @@ def on_upload(video_path):
54
  """New clip: size the slider, show frame 0, reset lines/frame state."""
55
  if not video_path:
56
  return (gr.update(maximum=1, value=0), None, "Upload a clip to begin.",
57
- 0, None, [], "")
58
  n, fps = probe_video(video_path)
59
  n_max = max(n - 1, 0)
60
  frame = grab_frame(video_path, 0)
@@ -367,4 +367,4 @@ with gr.Blocks(title="VAR Offside Visualizer") as demo:
367
 
368
  if __name__ == "__main__":
369
  demo.queue().launch(server_name="0.0.0.0", server_port=7860,
370
- theme=THEME, css=RF_CSS)
 
54
  """New clip: size the slider, show frame 0, reset lines/frame state."""
55
  if not video_path:
56
  return (gr.update(maximum=1, value=0), None, "Upload a clip to begin.",
57
+ 0, None, [], "", [], 0)
58
  n, fps = probe_video(video_path)
59
  n_max = max(n - 1, 0)
60
  frame = grab_frame(video_path, 0)
 
367
 
368
  if __name__ == "__main__":
369
  demo.queue().launch(server_name="0.0.0.0", server_port=7860,
370
+ theme=THEME, css=RF_CSS)
pipeline/autolines.py CHANGED
@@ -60,7 +60,12 @@ def merge_lines(wmask):
60
  minLineLength=70, maxLineGap=30)
61
  if segs is None:
62
  return []
63
- segs = segs[:, 0]
 
 
 
 
 
64
  used = np.zeros(len(segs), bool)
65
  merged = []
66
  for i in range(len(segs)):
@@ -167,4 +172,4 @@ def propose_lines(frame_rgb):
167
  # button still reaches the other one.
168
  if len(fams) == 2:
169
  fams = [fams[1], fams[0]]
170
- return fams
 
60
  minLineLength=70, maxLineGap=30)
61
  if segs is None:
62
  return []
63
+ # cv2.HoughLinesP is documented to return shape (N, 1, 4), but some
64
+ # OpenCV builds/wheels squeeze the middle axis and hand back (N, 4)
65
+ # directly. reshape(-1, 4) works for both layouts, whereas segs[:, 0]
66
+ # silently mis-indexes on the squeezed form (each "segment" ends up a
67
+ # bare scalar, which then fails to unpack in _seg_angle/_line_from_seg).
68
+ segs = segs.reshape(-1, 4)
69
  used = np.zeros(len(segs), bool)
70
  merged = []
71
  for i in range(len(segs)):
 
172
  # button still reaches the other one.
173
  if len(fams) == 2:
174
  fams = [fams[1], fams[0]]
175
+ return fams