RK3399的Android系统驱动UVC摄像头

Android studio版本 : 3.5.2
Android版本 :7.1
PC操作系统 :win10系统
摄像头: USB摄像头
参考项目:https://github.com/saki4510t/UVCCamera
硬件平台:RK3399

一、导入工程

在这里插入图片描述
同步工程。如果同步时间较长就关闭工程,再打开工程。

二、工程设置

  1. NDK的版本
    在这里插入图片描述
    https://developer.android.google.cn/ndk/downloads/older_releases.html
    下载android-ndk-r16b-windows-x86_64.zip
    注意NDK的版本。
  2. Gradle 设置
    在这里插入图片描述

三、程序修改

1.android7.0以后已经不需要android:background="#ff000000" 背景设置,将其删除。修改layout的文件activity_main.xml。
在这里插入图片描述
2.如果程序可以运行,但是无法显示摄像头画面,将UVCCamera-master\UVCCamera\libuvccamera\src\main\jni\Application.mk 中的#NDK_TOOLCHAIN_VERSION := 4.9 注释打开;

3.AndroidManifest.xml文件里android:theme="@style/AppTheme"改成 android:theme="@style/Theme.AppCompat.Light.NoActionBar"
在这里插入图片描述

四、各个demo介绍

1 ) USBCameraTest0
This is most simple project that only show how to start/stop previewing using SurfaceView.
这是最简单的项目,只显示如何使用SurfaceView来启动/停止预览。
2 ) USBCameraTest
This is most simple project that only show how to start/stop previewing. This is almost same as USBCameraTest0, but use customized TextureView to show camera images instead of using SurfaceView.
这是最简单的项目,只显示如何启动/停止预览。这与USBCameraTest0几乎相同,但是使用自定义的TextureView代替SurfaceView来显示相机图像。
3 ) USBCameraTest2
This is sample project that show how to record video from UVC camera(without audio) as .MP4 file using MediaCodec encoder. This sample requires API>=18 because MediaMuxer is only supported API>=18.
这是一个示例项目,演示如何使用MediaCodec编码器将UVC相机(无音频)的视频记录为.MP4​​文件。此示例需要API> = 18,因为MediaMuxer仅支持API> = 18。

4 ) USBCameraTest3
This is sample project that show how to record video(from UVC camera) with audio(from internal mic) as .MP4 file. This also shows several ways to capture still image. This sample may most useful as base project of your customized app.
这是一个示范项目,演示如何将音频(来自内部麦克风)和视频(来自UVC相机)录制为.MP4​​文件。这也显示了几种捕捉静止图像的方式。此示例可能最适用于您的定制应用程序的基础项目。

5 ) USBCameraTest4
This sample shows the way to access UVC camera and save video images on background service. This is one of the most complex sample because this requires IPC using AIDL.
本示例显示了访问UVC相机并将视频图像保存到后台服务的方式。这是最复杂的示例之一,因为这需要使用AIDL的IPC。

6 ) USBCameraTest5
This is almost same as USBCameraTest3 but save video images using IFrameCallback interface instead of using input Surface from MediaCodec encoder.
In most case, you should not use IFrameCallback to save images because IFrameCallback is much slower than using Surface. But IFrameCallback will be useful if you want to get video frame data and process them by yourself or passing them to other external library as byte buffer.
这与USBCameraTest3几乎相同,但使用IFrameCallback接口保存视频图像,而不是使用来自MediaCodec编码器的输入Surface。
在大多数情况下,您不应使用IFrameCallback来保存图像,因为IFrameCallback比使用Surface要慢很多。但是,如果您想获取视频帧数据并自行处理它们或将它们作为字节缓冲区传递给其他外部库,则IFrameCallback将非常有用。

7 ) USBCameraTest6
This shows how to split video images to multiple Surface. You can see video images side by side view on this app. This sample also show how to use EGL to render image. If you want to show video images after adding visual effect/filter effects, this sample may help you.
这显示了如何将视频图像分割为多个Surface。你可以在这个应用程序中看到视频图像并排观看。这个例子还展示了如何使用EGL来渲染图像。如果您想在添加视觉效果/滤镜效果后显示视频图像,则此示例可能会对您有所帮助。

8 ) USBCameraTest7
This shows how to use two camera and show video images from each camera side-by side. This is still experimental and may have some issue.
这显示了如何使用两个摄像头并显示来自每个摄像头的视频图像。这仍然是实验性的,可能有一些问题。

9 ) usbCameraTest8 This shows how to set/get uvc controls. Currently this supports brightness and contrast only.
usbCameraTest8这显示了如何设置/获取uvc控件。目前这只支持亮度和对比度。

发布了11 篇原创文章 · 获赞 24 · 访问量 7625

猜你喜欢

转载自blog.csdn.net/shajiayu1/article/details/103152433