溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Android怎么實現外接USB攝像頭

發布時間:2022-04-07 17:00:26 來源:億速云 閱讀:3892 作者:iii 欄目:編程語言

這篇文章主要講解了“Android怎么實現外接USB攝像頭”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“Android怎么實現外接USB攝像頭”吧!

實現

系統必須支持 android.hardware.usb.host

/system/etc/permissions下需要添加host的聲明
<feature name=“android.hardware.usb.host” />

此外&#xff0c;還必須啟用Kernel的 UVC 設備內核。

+CONFIG_USB_VIDEO_CLASS=y
+CONFIG_MEDIA_USB_SUPPORT=y

要在相應的設備細分版本中啟用外接攝像頭提供程序&#xff0c;以便添加必要的 SELinux 權限、外接攝像頭配置以及外接攝像頭提供程序依賴項&#xff0c;請完成以下步驟&#xff1a;

  • 將外接攝像頭配置文件和外接攝像頭庫添加到 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

  • 將外接攝像頭提供程序名稱添加到設備 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>

  • &#xff08;選做&#xff09;如果設備在 Treble 直通模式下運行&#xff0c;請更新 sepolicy&#xff0c;以便 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 文件來自定義外接攝像頭提供程序。具體而言&#xff0c;客戶可以自定義以下參數&#xff1a;

  • 內部攝像頭的排除視頻節點

  • 支持的圖片大小和幀速率上限

  • Inflight 緩沖區數量&#xff08;在卡頓與內存之間進行權衡&#xff09;

除了這些參數之外&#xff0c;您還可以添加自己的參數或開發自己的配置。

感謝各位的閱讀,以上就是“Android怎么實現外接USB攝像頭”的內容了,經過本文的學習后,相信大家對Android怎么實現外接USB攝像頭這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是億速云,小編將為大家推送更多相關知識點的文章,歡迎關注!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女