您好,登錄后才能下訂單哦!
這篇文章主要講解了“gradio攝像頭獲取照片和視頻怎么實現”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“gradio攝像頭獲取照片和視頻怎么實現”吧!
需要安裝 gradio,安裝辦法就是 pip install gradio
再次需要加入到path路徑。
ffmpeg.exe
ffprobe.exe
ffmpeg.exe
三者缺一不可,并需要加入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
輸入圖片、視頻
輸出圖片、視頻
接口三個參數:
方法
輸入【輸入為2個,一個是webcam的image,一個是webcam的video】
輸出【image,video】
運行直接就是接口launch,這個方法。 該方法參數較多,常用參數有:
share 是否為接口創建可公開共享的鏈接。創建一個SSH隧道,使您的UI可以從任何地方訪問。如果沒有提供,則每次默認設置為False,除非在谷歌Colab中運行。當localhost不可訪問(例如谷歌Colab)時,不支持設置share=False。
server_name 要使應用程序在本地網絡上可訪問,將此設置為“0.0.0.0”。可以通過環境變量GRADIO SERVER NAME設置。如果為None,將使用“127.0.0.1”。顯示提示:如果為True,將偶爾顯示關于新Gradio功能的提示
server_port 將在此端口上啟動gradio應用程序(如果可用)。可以通過環境變量GRADIO服務器端口設置。如果為None,將搜索從7860開始的可用端口。 參數較多就不看了。
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攝像頭獲取照片和視頻怎么實現這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。