Android: setPreviewCallbackWithBuffer, buffer in the queue and no callbacks
来源:互联网 发布:mac 笔记本电脑 编辑:程序博客网 时间:2024/05/15 21:44
If you want to process Camera preview frames on Android, you need to acquire them withsetPreviewCallback
or setPreviewOneShotCallback
or setPreviewCallbackWithBuffer
on the Camera.
setPreviewCallback
works as advertised, but slows the camera to just few frames per second. For better camera FPS, usesetPreviewCallbackWithBuffer
(it can re-use the same buffer without allocating it every frame). Just add the same buffer to the queue after it is processed in Camera.PreviewCallback. If the queue is empty, the preview frames are skipped (and it may improve FPS too, so it is a good thing).
My problem was that even if I had the buffer in the queue, the callback didn't run. However, if I calledsetPreviewCallbackWithBuffer
some seconds later (not in onResume
of the activity), the entire thing worked as intended.
I suppose, it has something to do with the surface for the preview not being ready when I call thesetPreviewCallbackWithBuffer
. This bug may be related: http://code.google.com/p/android/issues/detail?id=13966
My workaround is:
onResume
of the activity, dosetPreviewOneShotCallback
; and the callback will happen when the camera is ready;- in the callback method, when it is called the first time, allocate the buffer and
setPreviewCallbackWithBuffer
; - after every callback
addCallbackBuffer
to the Camera.
- Android: setPreviewCallbackWithBuffer, buffer in the queue and no callbacks
- Function Pointers and Callbacks in C
- Thinking in Java(9)-closures and callbacks
- Using the Web Service Callbacks in the .NET Application
- gotoAndPlay and the queue
- 【Android】提示Note: This element has no attached source and the Javadoc could not be found in the attac
- buffer and cache in linux
- Resetting The Buffer in SAP
- Queue And ConcurrentQueue in .NET
- no plugin found for prefix 'tomcat 7' in the current project and in the plugin groups
- No plugin found for prefix 'jetty' in the current project and in the plugin groups
- no plugin found for prefix 'tomcat 7' in the current project and in the plugin groups
- No plugin found for prefix 'jetty' in the current project and in the plugin groups
- No plugin found for prefix 'war' in the current project and in the plugin groups
- No plugin found for prefix ‘war’ in the current project and in the plugin groups
- No plugin found for prefix 'jetty' in the current project and in the plugin groups
- No plugin found for prefix 'jetty' in the current project and in the plugin groups
- No plugin found for prefix 'war' in the current project and in the plugin groups
- HDU - 5015 -233 Matrix
- 重要的grep命令
- 正则表达式-问号的四种用法
- 开发者必须知道的九款快速开发工具
- Hadoop Map/Reduce 原理
- Android: setPreviewCallbackWithBuffer, buffer in the queue and no callbacks
- 收集的网络上大型的开源图像处理软件代码(提供下载链接)
- 【解决问题】加载驱动模块时Device or resource busy的解决方法
- thinkphp基础
- 多线程安全的滑动窗口设计实现
- 40_1 栈结构,满足min,push,pop
- Codeforces Round #266 (Div. 2)
- Android参数分析
- 40_2 取出首尾相连的珠子中一段,要求包含所有N颜色,并长度最短。 滑动窗口问题