Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,14 +1,18 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
from PIL import Image
|
|
|
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
def capture_image(
|
|
|
|
|
|
|
|
|
|
| 6 |
return image
|
| 7 |
|
| 8 |
-
# 使用 Gradio
|
| 9 |
demo = gr.Interface(
|
| 10 |
fn=capture_image,
|
| 11 |
-
inputs=gr.
|
| 12 |
outputs="image",
|
| 13 |
live=True,
|
| 14 |
title="摄像头拍照",
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
from PIL import Image
|
| 3 |
+
import numpy as np
|
| 4 |
|
| 5 |
+
# 定义一个从视频帧中获取图像的函数
|
| 6 |
+
def capture_image(video):
|
| 7 |
+
# 获取视频的第一帧
|
| 8 |
+
frame = video[0]
|
| 9 |
+
image = Image.fromarray(frame)
|
| 10 |
return image
|
| 11 |
|
| 12 |
+
# 使用 Gradio 创建界面,使用摄像头捕捉视频
|
| 13 |
demo = gr.Interface(
|
| 14 |
fn=capture_image,
|
| 15 |
+
inputs=gr.Video(source="webcam"),
|
| 16 |
outputs="image",
|
| 17 |
live=True,
|
| 18 |
title="摄像头拍照",
|