渐高FPS的实时计算机视觉处理方式 [英] Ways of getting high FPS for real time computer vision processing

查看:288
本文介绍了渐高FPS的实时计算机视觉处理方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的目标是获得尽可能高的FPS越好。我会很乐意与BW小帧,​​但FPS应该是最大的。
getSupported previewFpsRange 在HTC野火S返回(9,30)。但是,当我尝试绘制最简单的处理preVIEW图像在视觉上得到大约12-15 FPS最大值。
设置参数后,和启动preVIEW()方法调用我这样做:

My goal is to get as high FPS as possible. I will be happy with BW small frames, but FPS should be maximum. getSupportedPreviewFpsRange on HTC WildFire S returns (9, 30). But when I try to draw preview image with most simple processing it visually get at about 12-15 FPS max. After setting Parameters and startPreview() method call I do this:

camera.setPreviewCallback(new Camera.PreviewCallback() {
          @Override
          public void onPreviewFrame(byte[] bytes, Camera camera) {
            Bitmap bitmap = Bitmap.createBitmap(size.width, size.height, Bitmap.Config.ARGB_8888);
            int[] colors = new int[size.width * size.height];
            for (int i=0; i < colors.length; i++){
              colors[i] = getBWColor(bytes[i]);
            }
            bitmap.setPixels(colors, 0, size.width, 0, 0, size.width, size.height);
            secondView.setImageBitmap(bitmap);
          }
        });
      }

private static int getBWColor(byte b){
    int res = 255;
    for(int i=0;i<3;i++){
      res = (res << 8) + b;
    }
    return res;
  }

有没有办法得到它尽可能快的? =(

Is there way to get it as fast as possible? =(

推荐答案

首先,使用<一个href=\"http://developer.android.com/reference/android/hardware/Camera.html#set$p$pviewCallbackWithBuffer%28android.hardware.Camera.$p$pviewCallback%29\"相对=nofollow>集previewCallbackWithBuffer(),它重用一个缓冲区,没有向每一帧分配新的缓冲区。检查我的<一个href=\"http://stackoverflow.com/questions/8371055/apply-custom-filters-to-camera-output/8372731#8372731\">older回答,有一个例子,如何使用它。

First, use setPreviewCallbackWithBuffer(), it reuses one buffer and does not have to allocate new buffer on every frame. Check my older answer, there is an example how to use it.

比,不做任何昂贵opeartion在previewFrame(),该数据的时间是有限的,这是每一个新的帧重写。你应该做在另一个线程的处理。

Than, do not do any expensive opeartion in onPreviewFrame(), the time of the data is limited, it is rewritten on each new frame. You should do the processing in another thread.

当然,不创造新的位图每帧上的颜色阵列,这样做只是一次。

And of course do not create new bitmap a the colors array on each frame, do it just once.

这篇关于渐高FPS的实时计算机视觉处理方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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