Get frames from camera's phone in android

后端 未结 1 1594
逝去的感伤
逝去的感伤 2020-12-10 19:50

I would like to get frames from camera\'s phone. So, i try to capture video and i use matlab to find frames per second of this video, i got 250 frames per 10 seconds. But wh

相关标签:
1条回答
  • 2020-12-10 19:58

    That's true; Android video recorder does not use Camera.PreviewCallback, and it may be much faster than what you get with Java callbacks. The reason is that it can send the video frame from camera to the hardware encoder inside the kernel, without ever putting the pixels into user space.

    However, I have reliably achieved 30 FPS in Java on advanced devices, like Nexus 4 or Galaxy S3. The secrets are: to avoid garbage collection by using Camera.setPreviewCallbackWithBuffer(), and to push the callbacks off the UI thread by using an HandlerThread.

    Naturally, the preview callback itself should be optimized as thoroughly as possible. In your sample, the calls to camera.getParameters() is slow and can be avoided. No allocations (new) should be made.

    0 讨论(0)
提交回复
热议问题