Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -5,19 +5,22 @@ import cv2
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
def image_to_video(image):
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
if not os.path.exists('output'): # 'output' ๋๋ ํ ๋ฆฌ๊ฐ ์์ผ๋ฉด ์์ฑ
|
| 13 |
os.makedirs('output')
|
| 14 |
-
output_path = os.path.join('output', output_path)
|
| 15 |
|
| 16 |
-
height, width,
|
| 17 |
size = (width, height)
|
| 18 |
-
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
| 19 |
|
| 20 |
-
video = cv2.VideoWriter(output_path, fourcc, 30, size)
|
| 21 |
|
| 22 |
if not video.isOpened():
|
| 23 |
print("๋น๋์ค ์์ฑ์๊ฐ ํ์ผ์ ์ด์ง ๋ชปํ์ต๋๋ค.")
|
|
|
|
| 5 |
import os
|
| 6 |
|
| 7 |
def image_to_video(image):
|
| 8 |
+
# PIL ์ด๋ฏธ์ง๋ฅผ NumPy ๋ฐฐ์ด๋ก ๋ณํํ๊ณ , RGB ํ์์ผ๋ก ๋ณํ
|
| 9 |
+
image_array = np.array(image.convert('RGB'))
|
| 10 |
+
|
| 11 |
+
# OpenCV๋ BGR ํ์์ ์ฌ์ฉํ๋ฏ๋ก RGB์์ BGR๋ก ์์ ์ฑ๋์ ์ฌ์ ๋ ฌ
|
| 12 |
+
image_array = cv2.cvtColor(image_array, cv2.COLOR_RGB2BGR)
|
| 13 |
|
| 14 |
+
output_path = 'output_video.mp4'
|
| 15 |
+
if not os.path.exists('output'):
|
|
|
|
| 16 |
os.makedirs('output')
|
| 17 |
+
output_path = os.path.join('output', output_path)
|
| 18 |
|
| 19 |
+
height, width, layers = image_array.shape
|
| 20 |
size = (width, height)
|
| 21 |
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
| 22 |
|
| 23 |
+
video = cv2.VideoWriter(output_path, fourcc, 30, size)
|
| 24 |
|
| 25 |
if not video.isOpened():
|
| 26 |
print("๋น๋์ค ์์ฑ์๊ฐ ํ์ผ์ ์ด์ง ๋ชปํ์ต๋๋ค.")
|