Python 官方文档:入门教程 => 点击学习
目录1.环境设置1.1gradio安装2.FFmpeg安装2.简单小程序2.1 引入gradio2.2 定义方法2.3 定义接口2.4 运行3.执行情况3.1 终端日志输出3.2 截
需要安装 gradio,安装办法就是 pip install gradio
再次需要加入到path路径。
下载地址: https://www.jb51.net/softjc/760881.html
三者缺一不可,并需要加入path中去。
import gradio as gr
def snap(image, video):
return [image, video]
demo = gr.Interface(
snap,
[gr.Image(source="WEBcam", tool=None), gr.Video(source="webcam")],
["image", "video"],
)
if __name__ == "__main__":
demo.launch(share=True)
简单,直接引入import gradio as gr
接口三个参数:
运行直接就是接口launch,这个方法。 该方法参数较多,常用参数有:
I:\miniconda3\envs\PyTorch\python.exe C:\Users\Administrator\PyCharmProjects\PythonProject\webcam.py
Running on local URL: Http://127.0.0.1:7860
Running on public URL: https://244c15fc39f9f7e0f0.gradio.live
This share link expires in 72 hours. For free permanent hosting and GPU upgrades (NEW!), check out Spaces: https://huggingface.co/spaces
ffmpeg version 2023-03-30-git-4d216654ca-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
built with GCc 12.2.0 (Rev10, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzMQ --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3D --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 58. 5.100 / 58. 5.100
libavcodec 60. 7.100 / 60. 7.100
libavfORMat 60. 4.101 / 60. 4.101
libavdevice 60. 2.100 / 60. 2.100
libavfilter 9. 5.100 / 9. 5.100
libswscale 7. 2.100 / 7. 2.100
libswresample 4. 11.100 / 4. 11.100
libpostproc 57. 2.100 / 57. 2.100
Input #0, matroska,webm, from 'C:\Users\Administrator\AppData\Local\Temp\8cbad405b8474e983e4c02b34a954a697e25b5a5\sample.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Video: h364 (Constrained Baseline), yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 30.30 fps, 30 tbr, 1k tbn (default)
Stream mapping:
Stream #0:0 -> #0:0 (h364 (native) -> vp9 (libvpx-vp9))
Press [q] to stop, [?] for help
[libvpx-vp9 @ 00000253d48ee780] v1.13.0-182-g5b05f6f3a
[libvpx-vp9 @ 00000253d48ee780] Neither bitrate nor constrained quality specified, using default CRF of 32
Output #0, webm, to 'C:\Users\Administrator\AppData\Local\Temp\8cbad405b8474e983e4c02b34a954a697e25b5a5\sample_flip.webm':
Metadata:
encoder : Lavf60.4.101
Stream #0:0(eng): Video: vp9, yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], q=2-31, 30 fps, 1k tbn (default)
Metadata:
encoder : Lavc60.7.100 libvpx-vp9
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
[matroska,webm @ 00000253d46a4400] File ended prematurely at pos. 354269 (0x567dd)
frame= 121 fps= 27 q=21.0 Lsize= 105kB time=00:00:04.03 bitrate= 213.1kbits/s speed=0.884x
video:104kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.271754%
ffmpeg version 2023-03-30-git-4d216654ca-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-d3d11va --enable-dxva2 --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil 58. 5.100 / 58. 5.100
libavcodec 60. 7.100 / 60. 7.100
libavformat 60. 4.101 / 60. 4.101
libavdevice 60. 2.100 / 60. 2.100
libavfilter 9. 5.100 / 9. 5.100
libswscale 7. 2.100 / 7. 2.100
libswresample 4. 11.100 / 4. 11.100
libpostproc 57. 2.100 / 57. 2.100
Input #0, matroska,webm, from 'C:\Users\Administrator\AppData\Local\Temp\d1d0cb0ab1d6909a5688d4f324734e1f908ed912\sample.webm':
Metadata:
encoder : Chrome
Duration: N/A, start: 0.000000, bitrate: N/A
Stream #0:0(eng): Video: h364 (Constrained Baseline), yuv420p(progressive), 640x480, SAR 1:1 DAR 4:3, 30.30 fps, 62.50 tbr, 1k tbn (default)
Stream mapping:
Stream #0:0 -> #0:0 (h364 (native) -> vp9 (libvpx-vp9))
Press [q] to stop, [?] for help
[libvpx-vp9 @ 00000271722bd640] v1.13.0-182-g5b05f6f3a
[libvpx-vp9 @ 00000271722bd640] Neither bitrate nor constrained quality specified, using default CRF of 32
Output #0, webm, to 'C:\Users\Administrator\AppData\Local\Temp\d1d0cb0ab1d6909a5688d4f324734e1f908ed912\sample_flip.webm':
Metadata:
encoder : Lavf60.4.101
Stream #0:0(eng): Video: vp9, yuv420p(progressive), 640x480 [SAR 1:1 DAR 4:3], q=2-31, 30 fps, 1k tbn (default)
Metadata:
encoder : Lavc60.7.100 libvpx-vp9
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
[matroska,webm @ 0000027171ce4400] File ended prematurely at pos. 348559 (0x5518f)
frame= 127 fps= 26 q=30.0 Lsize= 228kB time=00:00:04.20 bitrate= 444.9kbits/s speed=0.873x
video:227kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.601271%
图片、视频直接点下载图片即可。
以上就是gradio 和 摄像头获取照片和视频的详细内容,更多关于gradio 摄像头获取照片视频的资料请关注编程网其它相关文章!
--结束END--
本文标题: 通过gradio和摄像头获取照片和视频实现过程
本文链接: https://lsjlt.com/news/202883.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
2024-03-01
2024-03-01
2024-03-01
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
2024-02-29
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0