2

I developing application for Android OS which helps you to draw with help of camera. App works in way that capture frames from camera trough onPreviewFrame(byte[] data, Camera camera), and from here picture is converted to binary black/white. In general app works, but i have following question:

  1. Capture image trough onPreviewFrame is really slow. For now i skip frames but method is still slow.

    YuvImage yuvImage = new YuvImage(data, ImageFormat.NV21, width, height, null);
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    yuvImage.compressToJpeg(new Rect(0,0,width, height), 100, baos);
    byte [] imageData = baos.toByteArray();
    Bitmap bmp = BitmapFactory.decodeByteArray(imageData , 0, imageData .length);
    bmp = Bitmap.createScaledBitmap(bmp, surfaceView.getMeasuredHeight(), surfaceView.getMeasuredWidth(), false);
    Bitmap bmps = ImageHelper.rotate(bmp, kot);
    

    Is there any way to get picture faster?

  2. I also noticed that every couple frames picutre is not the same (different histogram), although phone is completely still and light is the same.

emrys57
  • 6,679
  • 3
  • 39
  • 49
Mihael Meklav
  • 335
  • 2
  • 6
  • 17

1 Answers1

0

I would think you should use the NDK as pointed out. You might want to do this type of processing on another thread too, not in the main thread.

Small point about your (2). How different are the histograms? Most camera sensors and processing will vary and it will be hard to produce an exact histogram due to noise and variations in the 3A algorithms.

jimbo
  • 416
  • 1
  • 4
  • 14