Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -33,18 +33,22 @@ def is_ffmpeg_available():
|
|
| 33 |
except (subprocess.CalledProcessError, FileNotFoundError):
|
| 34 |
return False
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
if mask_coords:
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
else:
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
def extract_first_frame(video_file_path):
|
| 50 |
cap = cv2.VideoCapture(video_file_path)
|
|
@@ -61,6 +65,7 @@ def frames_to_video(frames, output_path, fps, frame_size):
|
|
| 61 |
out.write(frame)
|
| 62 |
out.release()
|
| 63 |
return True
|
|
|
|
| 64 |
|
| 65 |
def remove_watermark_process(video_path, coords_input=None):
|
| 66 |
if not is_ffmpeg_available():
|
|
|
|
| 33 |
except (subprocess.CalledProcessError, FileNotFoundError):
|
| 34 |
return False
|
| 35 |
|
| 36 |
+
|
| 37 |
+
def remove_watermark_from_frame(frame, mask_coords):
|
| 38 |
+
if mask_coords is None:
|
| 39 |
+
return frame
|
| 40 |
+
|
| 41 |
+
# 讘讚讬拽讛 讗诐 谞砖诇讞 tuple 专讙讬诇 (x1, y1, x2, y2)
|
| 42 |
+
if isinstance(mask_coords[0], int):
|
| 43 |
+
x1, y1, x2, y2 = mask_coords
|
| 44 |
else:
|
| 45 |
+
(x1, y1), (x2, y2) = mask_coords
|
| 46 |
+
|
| 47 |
+
mask = np.zeros(frame.shape[:2], dtype=np.uint8)
|
| 48 |
+
mask[y1:y2, x1:x2] = 255
|
| 49 |
+
frame = cv2.inpaint(frame, mask, 3, cv2.INPAINT_TELEA)
|
| 50 |
+
return frame
|
| 51 |
+
|
| 52 |
|
| 53 |
def extract_first_frame(video_file_path):
|
| 54 |
cap = cv2.VideoCapture(video_file_path)
|
|
|
|
| 65 |
out.write(frame)
|
| 66 |
out.release()
|
| 67 |
return True
|
| 68 |
+
|
| 69 |
|
| 70 |
def remove_watermark_process(video_path, coords_input=None):
|
| 71 |
if not is_ffmpeg_available():
|