在Android视频处理视频处理、Android

2023-09-12 08:37:42 作者:清风扶醉月

我使用的是Android 2.2的Eclipse。

I'm using Android 2.2 with Eclipse.

我想提出来捕获视频的应用程序,并为每一帧,它作为一个位图,用于处理它的的方法发送,并返回一个新的位图的,并给出了处理位图。

I would like to make an application that captures video, and for each frame, its send it as a bitmap to a method that processes it and returns a new bitmap and shows the processed bitmap.

我不是很熟悉的Andr​​oid,所以请,任何人都可以送我去,我需要看一下做这样的事情的资源?

I am not very familiar with Android, so please, can anyone send me to the resources I need to look at to do such a thing?

推荐答案

这是很简单的实现使用Android SDK执行以下步骤:

It is simple enough to accomplish the following steps using the Android SDK:

拍摄距离相机位图数据的preVIEW帧。 相机。previewCallback 将返回一个数据重新$ P $的字节[] psenting帧的数量可能的图像格式。 修改像素数据。由于数据回来为原始字节,从而调整数据是比较容易的......这里正在申请的算法,你想要做的特定图像处理的难度。没有任何的内置音效(pre-4.0),可以简单地应用到图像,所以你必须自己编写。 也可以脱$ C C的数据$成位图对象,以与像素的工作更容易。在2.2中,你必须使用NDK和jnigraphics的选项与位图的原生code,这是比在Java层显著更快像素的工作。 把你得到的位图的内容,并显示它。对于快速移动的数据,你想上​​显示这是一个 SurfaceView ;使用 lockCanvas() unlockCanvasAndPost()可以从 SurfaceHolder 的视图包含 Capture the preview frames from the camera as bitmapped data. Camera.PreviewCallback will return a byte[] of data representing the frame in a number of possible image formats. Modify the pixel data. Since the data comes back as raw bytes, making adjustments to the data is relatively easy...the difficulty here is applying an algorithm for the particular image processing you want to do. There aren't any built-in effects (pre-4.0) that can be applied simply to images so you will have to write your own. It is also possible to decode the data into a Bitmap object to make working with the pixels easier. In 2.2, you have the option of using the NDK and jnigraphics to work with a Bitmap's pixels in native code, which is significantly faster than at the Java layer. Take the contents of your resultant Bitmap and display it. For fast moving data, you would want to display this on a SurfaceView; using the lockCanvas() and unlockCanvasAndPost() methods available from the SurfaceHolder that view contains.

如果这一切你想要做的,你可以用小的困难做到这一点。然而,这是不一样的捕获视频。安卓目前不提供挂钩为您帧出流成实时的连接codeD视频容器(MPEG4,3GP等)。它的视频拍摄功能被包装紧紧到 MediaRecorder 来控制从帧捕获过程中一路写EN codeD的视频。你需要一个第三部分的库,例如FFMPEG(其中已建成并运行使用NDK层的一些Android应用程序倍),以帮助你修改的帧的编码过程。

If this is all you are wanting to do, you could accomplish this with little difficulty. However, this is not the same as capturing video. Android does not currently provide hooks for you to stream frames out into an encoded video container (MPEG4, 3GP, etc.) in real-time. It's video capture capabilities are wrapped up tightly into the MediaRecorder which controls the process from frame capture all the way to writing the encoded video. You would need a 3rd part library such as FFMPEG (which has been built and run using the NDK layer a number of times in Android applications) to assist in the encoding process of your modified frames.

我知道你有一个2.2的目标,而Android 4.0确实在这里提供一些救济,因为他们已经发布了NDK的新版本,它可让用户拥有更多的发言权递给之前从流中读取图像数据时,会发生什么在presentation层。但是,我没有花足够的时间与它知道它是否可以推荐给您的情况。

I know you have a 2.2 target, but Android 4.0 does provide some relief here as they have released a new version of the NDK which allows one to have more say in what happens when reading image data from a stream before handing it to the presentation layer. However, I have not spent enough time with it to know whether it could be recommended for your situation.