freealise commited on
Commit
1b9c8e0
1 Parent(s): c911ef4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -131,14 +131,13 @@ def infer(url_in,interpolation,fps_output):
131
  ret, frame1 = depth_map.read()
132
  prvs = cv2.cvtColor(frame1, cv2.COLOR_RGB2GRAY)
133
  res = np.zeros_like(prvs)
134
- while(1):
135
  ret, frame2 = depth_map.read()
136
- if not ret:
137
- print('No frames grabbed!')
138
  break
139
  next = cv2.cvtColor(frame2, cv2.COLOR_RGB2GRAY)
140
  flow = cv2.calcOpticalFlowFarneback(prvs, next, None, 0.5, 3, 15, 3, 5, 1.2, 0)
141
- alpha = 0.5
142
  beta = (1.0 - alpha)
143
  res = cv2.addWeighted(flow, alpha, res, beta, 0.0)
144
  prvs = next
 
131
  ret, frame1 = depth_map.read()
132
  prvs = cv2.cvtColor(frame1, cv2.COLOR_RGB2GRAY)
133
  res = np.zeros_like(prvs)
134
+ while(depth_map.isOpened()):
135
  ret, frame2 = depth_map.read()
136
+ if ret == False:
 
137
  break
138
  next = cv2.cvtColor(frame2, cv2.COLOR_RGB2GRAY)
139
  flow = cv2.calcOpticalFlowFarneback(prvs, next, None, 0.5, 3, 15, 3, 5, 1.2, 0)
140
+ alpha = 1.0/len(frames_list)
141
  beta = (1.0 - alpha)
142
  res = cv2.addWeighted(flow, alpha, res, beta, 0.0)
143
  prvs = next