使用这两款相机在Android上:"无法连接到相机服务"相机、两款、连接到、Android

2023-09-05 10:36:58 作者:他是我的島嶼

林具有(在同一时间前部和后部摄像机)访问既麻烦。 当打开一台摄像机它的工作原理。 当我关掉首先,打开第二个它的工作原理。 它给当我试图打开第二个摄像头,而第一个仍呈现图像以下异常。

  E / AndroidRuntime(32325):致命异常:主要
E / AndroidRuntime(32325):java.lang.RuntimeException的:无法连接到摄像机服务
E / AndroidRuntime(32325):在android.hardware.Camera.native_setup(本机方法)
E / AndroidRuntime(32325):在android.hardware.Camera< INIT>(Camera.java:265)。
E / AndroidRuntime(32325):在android.hardware.Camera.open(Camera.java:226)
E / AndroidRuntime(32325):在com.example.videostreamer.MainActivity $ CameraHandler.start(MainActivity.java:116)
E / AndroidRuntime(32325):在com.example.videostreamer.MainActivity $ 2.onClick(MainActivity.java:74)
E / AndroidRuntime(32325):在android.view.View.performClick(View.java:2532)
E / AndroidRuntime(32325):在android.widget.CompoundButton.performClick(CompoundButton.java:99)
 

在文件建立,我发现一个短语,说:

  

公共静态照相机打开(INT cameraId)

     

自:API级别9   创建一个新的照相机对象来访问一个特定的硬件照相机。   你必须调用release()当您使用相机完成,否则将继续   锁定,并无法使用于其它应用。   您的应用程序应该只在时间的特定一个Camera对象主动   硬件摄像头。

..但我有一个硬件相机只有一个摄像头的对象,我想创造第二个设备第二个对象。

有谁知道这是可能的(我使用的是Android 2.3.3)? 地点:android.hardware.Camera.native_setup(本机方法)可以认为,可能是硬件/驱动程序限制 - 我使用的HTC感觉。 解决方案

This问题基本上说,它不能这样做,但有可能会出现一些黑客。 This缺乏来自谷歌群体反应告诉我,最有可能不是。 Here是对谷歌组另一无应答后。 这里是另一篇文章讨论的同时使用两个摄像头。

所以,我最初的答案是否定的,这是不可能的。但可能有一些解决方法,你只可能必须自己找到它,因为它尚未发现。)

编辑11年11月21日:不幸的是,我发现进一步证明,它不能做的,正式来自Sprint /宏达电here.我知道你使用的是感觉,而这是EVO 4G的,但我敢肯定它仍然适用。

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)
Android 4.4 尼康发布智能相机COOLPIX S810c

In the documentaion i found a phrase that says:

public static Camera open (int cameraId)

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.

Does anybody know if this is possible (I'm using Android 2.3.3)? The place: android.hardware.Camera.native_setup(Native Method) can suggest that probably it is hardware/driver limitation - I'm using HTC Sensation.

解决方案

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 :).

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.