original frame insertion place changed
Browse files
app.py
CHANGED
@@ -165,7 +165,7 @@ def track_and_mask(vid, original_frame, masked_frame):
|
|
165 |
|
166 |
if not ret:
|
167 |
break
|
168 |
-
|
169 |
# frame = cv2.resize(frame, (w - w % 8, h - h % 8))
|
170 |
if f == 0:
|
171 |
target_pos = np.array([x + w / 2, y + h / 2])
|
@@ -177,6 +177,8 @@ def track_and_mask(vid, original_frame, masked_frame):
|
|
177 |
# track
|
178 |
state = siamese_track(
|
179 |
state, frame, mask_enable=True, refine_enable=True, device=device)
|
|
|
|
|
180 |
location = state['ploygon'].flatten()
|
181 |
mask = state['mask'] > state['p'].seg_thr
|
182 |
frame[:, :, 2] = (mask > 0) * 255 + \
|
@@ -184,12 +186,10 @@ def track_and_mask(vid, original_frame, masked_frame):
|
|
184 |
|
185 |
mask = mask.astype(np.uint8) # convert to an unsigned byte
|
186 |
mask = mask * 255
|
|
|
187 |
cv2.polylines(frame, [np.int0(location).reshape(
|
188 |
(-1, 1, 2))], True, (0, 255, 0), 3)
|
189 |
|
190 |
-
original_frame_list.append(frame)
|
191 |
-
mask_list.append(mask)
|
192 |
-
|
193 |
video_writer.write(frame)
|
194 |
video_writer2.write(mask)
|
195 |
f = f + 1
|
|
|
165 |
|
166 |
if not ret:
|
167 |
break
|
168 |
+
|
169 |
# frame = cv2.resize(frame, (w - w % 8, h - h % 8))
|
170 |
if f == 0:
|
171 |
target_pos = np.array([x + w / 2, y + h / 2])
|
|
|
177 |
# track
|
178 |
state = siamese_track(
|
179 |
state, frame, mask_enable=True, refine_enable=True, device=device)
|
180 |
+
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
|
181 |
+
original_frame_list.append(frame)
|
182 |
location = state['ploygon'].flatten()
|
183 |
mask = state['mask'] > state['p'].seg_thr
|
184 |
frame[:, :, 2] = (mask > 0) * 255 + \
|
|
|
186 |
|
187 |
mask = mask.astype(np.uint8) # convert to an unsigned byte
|
188 |
mask = mask * 255
|
189 |
+
mask_list.append(mask)
|
190 |
cv2.polylines(frame, [np.int0(location).reshape(
|
191 |
(-1, 1, 2))], True, (0, 255, 0), 3)
|
192 |
|
|
|
|
|
|
|
193 |
video_writer.write(frame)
|
194 |
video_writer2.write(mask)
|
195 |
f = f + 1
|