本文共 3080 字,大约阅读时间需要 10 分钟。
Android 4.4.2 系统下 USB 摄像头驱动配置与使用说明
在 Android 4.4.2 系统下配置并使用 USB 摄像头可能会遇到一些问题。本文将详细介绍解决方案和相关配置步骤。
一、系统编译与依赖为了确保 USB 摄像头驱动正常工作,需要先编译系统并安装相关依赖项。以下是需要注意的版本信息:
二、需要修改的文件在配置过程中,以下文件需要重点关注:
三、代码修改说明在 V4L2CameraDevice2.cpp 文件中,主要修改了以下部分:
Mutex::Autolock locker(&mObjectLock);if (isConnected()) { LOGW("%s: camera device is already connected.", __FUNCTION__); return NO_ERROR;}// open v4l2 camera deviceint ret = openCameraDev(halInfo);if (ret != OK) { return ret;}// get sensor type from driverswitch((v4l2_sensor_type)getSensorType()) {case V4L2_SENSOR_TYPE_YUV: LOGV("the sensor is YUV sensor"); mSensor_Type = V4L2_SENSOR_TYPE_YUV; break;case V4L2_SENSOR_TYPE_RAW: LOGV("the sensor is RAW sensor"); mSensor_Type = V4L2_SENSOR_TYPE_RAW; break;default: if(mIsUsbCamera) { LOGV("the sensor is UVC sensor wyb add 2018/10/26 13:58"); mSensor_Type = V4L2_SENSOR_TYPE_YUV; } else { LOGE("get the sensor type failed wyb add 2018/10/26 14:59"); goto END_ERROR; } break;}halInfo->fast_picture_mode = (int)mSensor_Type;memcpy((void*)&mHalCameraInfo, (void*)halInfo, sizeof(HALCameraInfo)); // 主图像裁剪calculateCrop(&mRectCrop, mNewZoom, mMaxZoom, mFrameWidth/2, mFrameHeight/2);// 子图像裁剪(仅在快拍模式下)if (mHalCameraInfo.fast_picture_mode) { calculateCrop(&mThumbRectCrop, mNewZoom, mMaxZoom, mThumbWidth, mThumbHeight);} 三、配置文件修改在 camera.cfg 文件中,需要调整以下参数:
key_camera_exif_make = MAKE_AllWinnerkey_camera_exif_model = MODEL_f1
camera_id = 0camera_facing = 0use_builtin_isp = 0camera_orientation = 90camera_device = /dev/video0
三、驱动加载与测试在 BoardConfig.mk 文件中,需要加载以下驱动:
# gpuinsmod /system/vendor/modules/pvrsrvkm.koinsmod /system/vendor/modules/dc_sunxi.ko# csi moduleinsmod /system/vendor/modules/videobuf-core.koinsmod /system/vendor/modules/videobuf-dma-contig.koinsmod /system/vendor/modules/cci.koinsmod /system/vendor/modules/actuator.koinsmod /system/vendor/modules/vfe_os.koinsmod /system/vendor/modules/vfe_subdev.koinsmod /system/vendor/modules/dw9714_act.koinsmod /system/vendor/modules/hi253.koinsmod /system/vendor/modules/ov8858_4lane.koinsmod /system/vendor/modules/vfe_v4l2.ko# usb module / UVCinsmod /system/vendor/modules/videobuf2-core.koinsmod /system/vendor/modules/videobuf2-memops.koinsmod /system/vendor/modules/videobuf2-vmalloc.koinsmod /system/vendor/modules/uvcvideo.ko
四、开发调试在开发过程中需要注意以下几点:
通过以上配置和修改,可以在 Android 4.4.2 系统下正常使用 USB 摄像头功能。如有特殊问题,请根据日志信息逐步排查并调整相应配置。
转载地址:http://ygdp.baihongyu.com/