這篇文章主要講解了“Android怎么實現(xiàn)外接USB攝像頭”,文中的講解內(nèi)容簡單清晰,易于學(xué)習(xí)與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學(xué)習(xí)“Android怎么實現(xiàn)外接USB攝像頭”吧!
10年積累的網(wǎng)站設(shè)計制作、成都網(wǎng)站設(shè)計經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認識你,你也不認識我。但先網(wǎng)站制作后付款的網(wǎng)站建設(shè)流程,更有大通免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
系統(tǒng)必須支持 android.hardware.usb.host
/system/etc/permissions下需要添加host的聲明
<feature name=“android.hardware.usb.host” />
此外,還必須啟用Kernel的 UVC 設(shè)備內(nèi)核。
+CONFIG_USB_VIDEO_CLASS=y
+CONFIG_MEDIA_USB_SUPPORT=y
要在相應(yīng)的設(shè)備細分版本中啟用外接攝像頭提供程序,以便添加必要的 SELinux 權(quán)限、外接攝像頭配置以及外接攝像頭提供程序依賴項,請完成以下步驟:
將外接攝像頭配置文件和外接攝像頭庫添加到 device.mk。
+PRODUCT_PACKAGES += android.hardware.camera.provider@2.4-impl
+PRODUCT_PACKAGES += android.hardware.camera.provider@2.4-external-service
+PRODUCT_COPY_FILES +=
+device/manufacturerX/productY/external_camera_config.xml:$(TARGET_COPY_OUT_VENDOR )/etc/external_camera_config.xml
將外接攝像頭提供程序名稱添加到設(shè)備 Treble HAL 清單。
<hal format=“hidl”>
<name>android.hardware.camera.provider</name>
<transport arch=“32+64”>passthrough</transport>
<impl level=“generic”></impl>
<version>2.4</version>
<interface>
<name>ICameraProvider</name>
<instance>legacy/0</instance>
+ <instance>external/0</instance>
</interface>
</hal>
(選做)如果設(shè)備在 Treble 直通模式下運行,請更新 sepolicy,以便 cameraserver 可以訪問 UVC 攝像頭。
+# for external camera
+allow cameraserver device:dir r_dir_perms;
+allow cameraserver video_device:dir r_dir_perms;
+allow cameraserver video_device:chr_file rw_file_perms;
external_camera_config.xml的示例
<ExternalCamera> <Provider> <ignore> <!-- Internal video devices to be ignored by external camera HAL --> <id>0</id> <!-- No leading/trailing spaces --> <id>1</id> </ignore> </Provider> <!-- See ExternalCameraUtils.cpp for default values of Device configurations below--> <Device> <!-- Max JPEG buffer size in bytes--> <MaxJpegBufferSize bytes="8388608"/> <!-- 8MB (> 2594x1944 YUV420) --> <!-- Size of v4l2 buffer queue when streaming >= 30fps --> <!-- Larger value: more request can be cached pipeline (less janky) --> <!-- Smaller value: use less memory --> <NumVideoBuffers count="4"/> <!-- Size of v4l2 buffer queue when streaming < 30fps --> <NumStillBuffers count="2"/> <!-- List of maximum fps for various output sizes --> <!-- Any image size smaller than the size listed in Limit row will report fps (as minimum frame duration) up to the fpsBound value. --> <FpsList> <!-- width/height must be increasing, fpsBound must be decreasing--> <Limit width="640" height="480" fpsBound="30.0" /> <Limit width="1280" height="720" fpsBound="30.0" /> <Limit width="1920" height="1080" fpsBound="30.0" /> <!-- image size larger than the last entry will not be supported--> </FpsList> </Device></ExternalCamera>
您可以通過修改 external_camera_config.xml 文件來自定義外接攝像頭提供程序。具體而言,客戶可以自定義以下參數(shù):
內(nèi)部攝像頭的排除視頻節(jié)點
支持的圖片大小和幀速率上限
Inflight 緩沖區(qū)數(shù)量(在卡頓與內(nèi)存之間進行權(quán)衡)
除了這些參數(shù)之外,您還可以添加自己的參數(shù)或開發(fā)自己的配置。
感謝各位的閱讀,以上就是“Android怎么實現(xiàn)外接USB攝像頭”的內(nèi)容了,經(jīng)過本文的學(xué)習(xí)后,相信大家對Android怎么實現(xiàn)外接USB攝像頭這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯(lián),小編將為大家推送更多相關(guān)知識點的文章,歡迎關(guān)注!
新聞標題:Android怎么實現(xiàn)外接USB攝像頭
網(wǎng)頁路徑:http://aaarwkj.com/article26/iighcg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制網(wǎng)站、網(wǎng)站維護、自適應(yīng)網(wǎng)站、App設(shè)計、定制開發(fā)、手機網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)