Android:使用“连续”录制视频自动对焦
我从事视频录制工作;除了要求持续专注之外,一切正常。这就是我所做的(在surfaceCreated和surfaceChanged中都尝试过但没有成功):
camera = Camera.open();
camera.setPreviewDisplay(holder);
Parameters parameters = camera.getParameters();
然后我做其中一个
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
或
parameters.set("focus-mode", "continuous-video");
两个应该做同样的事情;然后我设置参数
camera.setParameters(parameters);
最后一行总是崩溃!那么我错过了什么吗?
顺便说一句,我在 Desire HD、Galaxy S、Galaxy Tab 7 和 10.1 等相当新的设备上进行了测试,这些设备必须支持连续自动对焦;至少他们的内置相机应用程序支持它。
I work on video recording; everything works except for requesting continuous focus. This is what I do (tried both in surfaceCreated and surfaceChanged with no success):
camera = Camera.open();
camera.setPreviewDisplay(holder);
Parameters parameters = camera.getParameters();
then I do either
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
or
parameters.set("focus-mode", "continuous-video");
both should do the same thing; then I set parameters with
camera.setParameters(parameters);
This last line always crashes! So do I miss something?
By the way, I test on rather new devices like Desire HD, Galaxy S, Galaxy Tab 7 and 10.1, which must have support for continuous auto-focus; at least their built-in camera apps support it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该检查设备是否支持连续自动对焦。这对我有用,请尝试一下。
You should check if Continuous Auto Focus is supported by the device. This is something that works for me, please give it a try.
好的,我对这个问题有某种解决方案:我可以调用 Camera#autoFocus(...) 手动对焦相机。
这仍然存在严重的问题。首先,在某些三星设备上无法在拍摄视频时调用自动对焦。此外,强迫用户在视频录制期间手动对焦相机也不是一个好主意。
因此,如果您在录制时能够正常聚焦视频 - 您的建议将会非常有帮助。
Ok, I have sort of solution to this problem: I was able to manually focus camera calling Camera#autoFocus(...).
This still has serious issues. First, calling autofocus while shooting video is not working on some Samsung devices. Also it's not a good idea to force your users to manually focus the camera during video recording.
So if you were able to normally focus your videos while recording - your advice would be very helpful.