本文介绍了拍照的相机而无需preVIEW的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写一个Android 1.5的应用程序,只是后开机启动。这是一个服务,并应采取无preVIEW图片。这个程序将记录光密度在一些地区等等。我能拍张照片,但照片是黑色的。

I am writing an Android 1.5 application which starts just after boot-up. This is a Service and should take a picture without preview. This app will log the light density in some areas whatever. I was able to take a picture but the picture was black.

很长一段时间研究后,我碰到一个关于它的错误线程。如果不生成preVIEW,图像将是黑色的,因为Android摄像头需要preVIEW设置曝光和对焦。我创建了一个 SurfaceView 和听众,但 onSurfaceCreated()事件永远不会被解雇。

After researching for a long time, I came across a bug thread about it. If you don't generate a preview, the image will be black since Android camera needs preview to setup exposure and focus. I've created a SurfaceView and the listener, but the onSurfaceCreated() event never gets fired.

我猜的原因是,表面不被直观地创建。我也看到了与 MediaStore.CAPTURE_OR_SOMETHING 调用摄像头静态它拍照并保存在目标文件夹两行code的一些例子,但它不拍照了。

I guess the reason is, the surface is not being created visually. I've also seen some examples of calling the camera statically with MediaStore.CAPTURE_OR_SOMETHING which takes a picture and saves in the desired folder with two lines of code, but it doesn't take a picture too.

我是否需要使用IPC和 bindService()来调用这个函数?还是有实现这个另一种方法?

Do I need to use IPC and bindService() to call this function? Or is there an alternative method to achieve this?

推荐答案

这是非常奇怪的摄像头在Android平台上不能流视频,直到它给出有效的preVIEW表面。看来,平台的设计者并没有考虑过第三方视频流应用的。即使是增强现实情况下的图片可以是psented为某种视觉替代$ P $,而不是实时的摄像头流。

it is really weird that camera on android platform can't stream video until it given valid preview surface. it seems that the architects of the platform was not thinking about 3rd party video streaming applications at all. even for augmented reality case the picture can be presented as some kind of visual substitution, not real time camera stream.

反正,你可以简单地调整preVIEW表面的1x1像素,并把它放在某处的小部件(可视元素)的拐角处。请关注 - 调整preVIEW表面,没有摄像头帧大小

anyway, you can simply resize preview surface to 1x1 pixels and put it somewhere in the corner of the widget (visual element). please pay attention - resize preview surface, not camera frame size.

这种伎俩并不能消除不需要的数据流(为preVIEW),这会消耗一定的系统资源和电池。

of course such trick does not eliminate unwanted data streaming (for preview) which consumes some system resources and battery.

这篇关于拍照的相机而无需preVIEW的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 01:00