>本文詳細介紹瞭如何將圖像從Raspberry Pi攝像機流式傳輸到Web瀏覽器,最終將其集成到虛擬現實(VR)查看器中。 該過程利用RPI CAM Web界面以實現簡單性和有效性。
密鑰點:
raspivid
raspivid
> >軟件設置:
啟用相機:使用
啟用相機。sudo raspi-config
,sudo apt-get update
安裝RPI CAM Web接口:sudo rpi-update
),然後運行installer(git clone https://github.com/silvanmelchior/RPi_Cam_Web_Interface.git
cd RPi_Cam_Web_Interface
chmod u x RPi_Cam_Web_Interface_Installer.sh; ./RPi_Cam_Web_Interface_Installer.sh install
> javascript集成:
>使用這樣的URL通過JavaScript訪問攝像頭圖像(用Pi的IP和文件夾替換):"http://192.168.0.12/picam/cam_pic.php?time=" new Date().getTime()
提供的代碼(在GitHub上可用)將此圖像流集成到基於三分的VR Viewer中。 animate()
函數可獲取圖像,更新畫布並刷新三個紋理。 在三個場景中根據需要調整帆布尺寸和相機位置。
部署:
>將JavaScript代碼部署到PI的Web服務器(例如,/var/www
)。 在必要時使用sudo chown -R pi www
授予寫入權限,或通過git進行管理。
結論:
以上是使用JavaScript將Raspberry Pi攝像頭流式傳輸到VR的詳細內容。更多資訊請關注PHP中文網其他相關文章!