oguzakif commited on
Commit
dcc7275
1 Parent(s): 8b73802

first frames added to seg and inpainted results

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -134,8 +134,11 @@ def getBoundaries(mask):
134
  def track_and_mask(vid, masked_frame, original_list, mask_list, in_fps, dt_string):
135
  x, y, w, h = getBoundaries(masked_frame)
136
  f = 0
137
-
 
 
138
  video_capture = cv2.VideoCapture()
 
139
  if video_capture.open(vid):
140
  width, height = int(video_capture.get(cv2.CAP_PROP_FRAME_WIDTH)), int(
141
  video_capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
@@ -163,19 +166,17 @@ def track_and_mask(vid, masked_frame, original_list, mask_list, in_fps, dt_strin
163
  # track
164
  state = siamese_track(
165
  state, frame, mask_enable=True, refine_enable=True, device=device)
166
- original_list.append(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
167
- location = state['ploygon'].flatten()
168
- mask = state['mask'] > state['p'].seg_thr
169
- frame[:, :, 2] = (mask > 0) * 255 + \
170
  (mask == 0) * frame[:, :, 2]
171
 
172
- mask = mask.astype(np.uint8) # convert to an unsigned byte
173
- mask = mask * 255
174
- mask_list.append(mask)
175
- #cv2.polylines(frame, [np.int0(location).reshape(
176
- # (-1, 1, 2))], True, (0, 255, 0), 3)
177
-
178
- video_writer.write(frame)
179
  f = f + 1
180
 
181
  video_capture.release()
 
134
  def track_and_mask(vid, masked_frame, original_list, mask_list, in_fps, dt_string):
135
  x, y, w, h = getBoundaries(masked_frame)
136
  f = 0
137
+
138
+ #add first mask frame of the video by default
139
+ mask_list.append(masked_frame)
140
  video_capture = cv2.VideoCapture()
141
+
142
  if video_capture.open(vid):
143
  width, height = int(video_capture.get(cv2.CAP_PROP_FRAME_WIDTH)), int(
144
  video_capture.get(cv2.CAP_PROP_FRAME_HEIGHT))
 
166
  # track
167
  state = siamese_track(
168
  state, frame, mask_enable=True, refine_enable=True, device=device)
169
+
170
+ original_list.append(cv2.cvtColor(frame, cv2.COLOR_BGR2RGB))
171
+ mask = state['mask'] > state['p'].seg_thr
172
+ frame[:, :, 2] = (mask > 0) * 255 + \
173
  (mask == 0) * frame[:, :, 2]
174
 
175
+ mask = mask.astype(np.uint8) # convert to an unsigned byte
176
+ mask = mask * 255
177
+ mask_list.append(mask)
178
+
179
+ video_writer.write(frame)
 
 
180
  f = f + 1
181
 
182
  video_capture.release()