使用USB摄像头的Andr​​oid应用 [英] Use USB Camera on Android application

查看:178
本文介绍了使用USB摄像头的Andr​​oid应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要显示通过USB摄像头连接到我的平板电脑的Andr​​oid 3.2传输的视频。但我还没有对如何做到这一点的想法。

I need to display a video transmitted by an USB Camera connected to my tablet on Android 3.2. But I haven't any idea on how to do it.

我不能使用平板电脑的摄像头,因为我的平板电脑固定在船上。

I can't use the tablet's camera, because my tablet is fixed on board.

THX。

推荐答案

讨论成立仅当USB摄像头内的传感器是兼容UVC(大多数今天的相机标准)。

The discussion holds true only if the sensor inside USB camera is UVC compliant(most of todays' cameras are compliant).

默认情况下,没有安卓的API可用于外接摄像头。所以,如果你是认真对待这个项目,你做的工作会涉及到Android应用程序层上编写,讨论的核心驱动程序固件,然后显示数据。

当你插入一个USB摄像头,还有,你首先需要检查一些东西。

When you insert a USB camera, There are few things that you need to check first.

1)是相机获得的功率从USB端口?(要做到这一点您的USB端口应该具有USB-OTG支持 - USB端口可以同时作为目标和主机,检查是否灯相机(如果有的话)的发光或不?)

1) Is your camera getting power from USB port?(For this to happen your USB port should have USB-OTG support- USB port can act both as target and host, Check whether the lights on camera(if any) are glowing or not?)

2)的是在/ dev目录中得到创建的节点?(只有在情况下,内核V4L2和UVC支持启用,节点将被创建)。如果是越来越创建的节点,现在你有机会获得真正的硬件是USB摄像头和你的工作将是从这里方便。检查做ls -l命令的/ dev / V *里面的Andr​​oid文件系统,并检查video0的或VIDEO1是否被创建。

2) Is node getting created in /dev directory?(Only in case the kernel has v4l2 and UVC support enabled,node will be created). If node is getting created, now you have access to the real hardware that is USB camera and your job is going to be easy from here on. to check do ls -l /dev/v* inside the android file system and check whether video0 or video1 is being created.

4)如果创建的节点,您需要编写固件(UVC),并获得来自实际硬件的框架。它(UVC)支持交谈V4L2层在不同的控制调用内核并把你的帧。

4) If node is created, you need to write a firmware(UVC) and acquire a frame from the real hardware. It(UVC) supports different ioctl calls that talk to the v4l2 layer in the kernel and will fetch you the frames.

这些框架将是主要的格式YUYV422或YUYV420格式。

These frames would be mostly of format YUYV422 or YUYV420 format.

在收到的帧,转换成RGB或JPEG(Android已经支持转换),并显示任何你喜欢的帆布或ImageView的上。

Once you receive the frames, convert into RGB or Jpeg (Android has support to convert ) and display on the canvas or imageview whichever you like.

有关记录,你可能需要使用的ffmpeg编码。这将图像转换成视频。

For recording you might have to use ffmpeg for encoding. This will convert the images into video.

让我知道,如果你有兴趣,需要更多的支持...... !!!!

Let me know in case you are interested and need more support...!!!!

这篇关于使用USB摄像头的Andr​​oid应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆