Kernel 打开 UVC Camera 驱动


kernel/linux-4.9/arch/arm64/configs/xxxx_defconfig
kernel/linux-4.9/arch/arm64/configs/xxxx_extra_modem_defconfig

内核配置开关如下:

CONFIG_VIDEO_V4L2_SUBDEV_API=y
CONFIG_USB_VIDEO_CLASS=y
CONFIG_MEDIA_USB_SUPPORT=y
CONFIG_V4L_PLATFORM_DRIVERS=y

在这里插入图片描述


禁止Android Camera

# frameworks/av/services/camera/libcameraservice$ git diff .
diff --git a/services/camera/libcameraservice/CameraService.cpp b/services/camera/libcameraservice/CameraService.cpp
index 2bf42b6..2b0346b 100644
--- a/services/camera/libcameraservice/CameraService.cpp
+++ b/services/camera/libcameraservice/CameraService.cpp
@@ -1286,6 +1286,18 @@ Status CameraService::connectHelper(const sp<CALLBACK>& cameraCb, const String8&
             (halVersion == -1) ? "default" : std::to_string(halVersion).c_str(),
             static_cast<int>(effectiveApiLevel));
 
+    // 20201016 disable android camea +++
+    if(clientName8 == "com.huawei.dmsdpdevice") {
+        ALOGI("com.huawei.dmsdpdevice is forbid, ID \"%s\"", cameraId.string());
+        return STATUS_ERROR_FMT(ERROR_CAMERA_IN_USE,
+            "com.huawei.dmsdpdevice is forbid, ID \"%s\"",
+            cameraId.string());
+    }
+    // 20201016 disable android camea +++
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
UVCCamera是一个基于libusb库的开源库,用于与USB摄像头进行通信和控制。它提供了一组函数和工具,可以用于打开、关闭、读取和写入USB摄像头的数据。 虽然libusb库本身可以用于与USB设备进行通信,但使用UVCCamera库可以更方便地处理与UVC(USB Video Class)兼容的USB摄像头的操作。UVCCamera库封装了与UVC协议相关的细节,提供了更高级的API接口。 以下是一个使用UVCCamera打开USB摄像头并捕获图像的示例: ```c #include <stdio.h> #include <stdlib.h> #include <uvccamera/uvccamera.h> int main() { uvccamera_t camera; // 初始化UVCCamera库 if (uvccamera_init(&camera) < 0) { printf("无法初始化UVCCamera库!\n"); return 1; } // 查找和打开第一个可用的USB摄像头 if (uvccamera_open(camera, 0) < 0) { printf("无法打开USB摄像头!\n"); uvccamera_deinit(camera); return 1; } // 设置摄像头参数 uvccamera_set_format(camera, UVCCAMERA_FORMAT_MJPEG); uvccamera_set_resolution(camera, 640, 480); // 开始捕获图像 if (uvccamera_start_capturing(camera) < 0) { printf("无法开始图像捕获!\n"); uvccamera_close(camera); uvccamera_deinit(camera); return 1; } // 读取图像数据 unsigned char* image_data; size_t image_size; if (uvccamera_get_frame(camera, &image_data, &image_size) < 0) { printf("无法获取图像数据!\n"); uvccamera_stop_capturing(camera); uvccamera_close(camera); uvccamera_deinit(camera); return 1; } // 在这里可以对图像数据进行处理和显示 // 停止图像捕获 uvccamera_stop_capturing(camera); // 关闭USB摄像头 uvccamera_close(camera); // 释放UVCCamera库资源 uvccamera_deinit(camera); return 0; } ``` 请注意,上述示例中涉及到的函数和数据结构都是来自于UVCCamera库,你需要在编译时链接该库,并根据你的具体需求进行适当的配置和处理。 希望这能帮到你!如果还有其他问题,请随时提问。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

"小夜猫&小懒虫&小财迷"的男人

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值