本文介绍了真的混淆集previewCallback在Android中,需要咨询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要建一个应用程序在Android上采取帧的摄像头,对它们进行处理,然后显示在surfaceView框架,以及通过在画布和drawbitmap和所有的SurfaceView绘图。

I'm building an application on Android to take frames from the camera, process them, and then display the frame on a surfaceView, as well as drawing on the SurfaceView via the canvas and drawbitmap and all.

只是为了检查,是SurfaceView和位图和画布做到这一点的最好方法是什么?我的速度后我。

Just to check, is SurfaceView and Bitmaps and Canvases the best way to do it ? I'm after speed.

假设答案以上是肯定的,问题是:我应该在哪里把下面的函数

Assuming the answer to the above is Yes, the question would be: Where should I place the following function

camera_object.setPreviewCallback(new PreviewCallback()
     public void onPreviewFrame(byte[] data, Camera camera){

我应该把它放在的onCreate()或者我应该把它放在surfaceCreated()或surfaceChanged()?

should I place it in onCreate() or should I place it in surfaceCreated() or surfaceChanged() ?

我声明我mainactivity类,如下所示:

I declared my mainactivity class as follows:

public class MainActivity extends Activity implements SurfaceHolder.Callback, Camera.PreviewCallback
{

和在类的Eclipse迫使我在MainActivity类的previewframe创建替代功能如下:

and in that class Eclipse forces me to create an override function for onpreviewframe in the MainActivity class as follows

public void onPreviewFrame(byte[] data, Camera camera){
}

但它永远不会被调用。我应该尝试使用这个功能吗?是它更好地使用它?或者是它只是一个Eclipse的事情?

but it never gets called. Should I try to use this function ? is it better to use it ? or is it just an Eclipse thing ?

请指教

推荐答案

你叫集previewDisplay()启动preVIEW()和set$p$pviewCallback(this)从应用程序吗?如果没有,你不会得到任何调用上previewFrame()。事实上,如果使用的是SurfaceView,那么回调preVIEW缓冲区是正在显示在屏幕上的实际缓冲器的副本。所以,如果你想显示这些复制的缓冲区,你需要创建一个新的视图,并覆盖它。这将是低效率的。我会建议你使用SurfaceTexture来代替,而onFrameAvailable'回调来获取帧,然后绘制及放大器;手动显示。这样的一个例子可以在<一个中找到href="http://grep$c$c.com/file/repository.grep$c$c.com/java/ext/com.google.android/android-apps/4.0.1_r1/com/android/camera/panorama/PanoramaActivity.java">PanoramaActivity $ C $默认了C Android摄像头应用程序。

Are you calling setPreviewDisplay(), startPreview() and setPreviewCallback(this) from the app? Without that you will not get any calls to onPreviewFrame(). In fact if you are using SurfaceView, then the callback preview buffers are a copy of the actual buffers that are being displayed on the screen. So if you want to display these copied buffers, you need to create a new view and overwrite it. This would be inefficient. I would suggest you use SurfaceTexture instead and use 'onFrameAvailable' callback to get the frames and then draw & display manually. An example of this can be found in the PanoramaActivity code of the default Android Camera App.

这篇关于真的混淆集previewCallback在Android中,需要咨询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 05:46