在 android 上使用两个摄像头:“无法连接到摄像头服务"; [英] Using both cameras on android: "Fail to connect to camera service"

查看:35
本文介绍了在 android 上使用两个摄像头:“无法连接到摄像头服务";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法同时访问这两个摄像头(前置和后置摄像头).当打开一台相机时,它可以工作.当我先关闭然后再打开时,它会起作用.当我尝试打开第二个摄像头而第一个摄像头仍在显示图像时,它会出现以下异常.

I'm having troubles in accessing both (front and rear cameras at the same time). When turn on one camera it works. When i turn off first and turn on second it works. It gives following exception when i'm trying to turn on second camera while the first one is still showing the image.

E/AndroidRuntime(32325): FATAL EXCEPTION: main
E/AndroidRuntime(32325): java.lang.RuntimeException: Fail to connect to camera service
E/AndroidRuntime(32325):    at android.hardware.Camera.native_setup(Native Method)
E/AndroidRuntime(32325):    at android.hardware.Camera.<init>(Camera.java:265)
E/AndroidRuntime(32325):    at android.hardware.Camera.open(Camera.java:226)
E/AndroidRuntime(32325):    at com.example.videostreamer.MainActivity$CameraHandler.start(MainActivity.java:116)
E/AndroidRuntime(32325):    at com.example.videostreamer.MainActivity$2.onClick(MainActivity.java:74)
E/AndroidRuntime(32325):    at android.view.View.performClick(View.java:2532)
E/AndroidRuntime(32325):    at android.widget.CompoundButton.performClick(CompoundButton.java:99)

在文档中,我发现了这样一句话:

In the documentaion i found a phrase that says:

public static Camera open (int cameraId)

public static Camera open (int cameraId)

自:API 级别 9创建一个新的 Camera 对象以访问特定的硬件相机.使用完相机后必须调用 release() ,否则它会保留锁定,其他应用程序无法使用.您的应用程序一次应该只有一个 Camera 对象处于活动状态硬件摄像头.

Since: API Level 9 Creates a new Camera object to access a particular hardware camera. You must call release() when you are done using the camera, otherwise it will remain locked and be unavailable to other applications. Your application should only have one Camera object active at a time for a particular hardware camera.

.. 但我只有一个相机对象用于一台硬件相机,我想为第二台设备创建第二个对象.

.. but i'm having only one Camera object for one hardware camera and I wanted to create second object for second device.

  1. 有人知道这是否可行(我使用的是 Android 2.3.3)?
  2. 位置:android.hardware.Camera.native_setup(Native Method) 可以表明可能是硬件/驱动程序限制 - 我正在使用 HTC Sensation.

推荐答案

这个 问题基本上说它不能完成,但可能有一些黑客. 谷歌群组缺乏回应告诉我很可能没有.这里在 google 群组上发帖.这里是另一篇讨论在同时.

This question basically says it cannot be done, but there may be some hack. This lack of response from google groups tells me most likely not. Here is another no-response post on google groups. Here is another post discussing the use of two cameras at the same time.

所以我最初的回答是否定的,这是不可能的.但是可能有一些解决方法,您可能需要自己找到它,因为它还没有被发现:)

So my initial answer is no, it is not possible. BUT there may be some workaround, you just may have to find it yourself because it isn't discovered yet :).

编辑 2011 年 11 月 21 日:不幸的是,我从 Sprint/HTC 官方 此处.我知道您使用的是 Sensation,这是 EVO 4g,但我确定它仍然适用.

EDIT 11/21/11: Unfortunately I found even further proof that it cannot be done, official from Sprint/HTC here. I realize you are using a Sensation, and this is an EVO 4g, but I'm sure it still applies.

这篇关于在 android 上使用两个摄像头:“无法连接到摄像头服务";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆