2
我嘗試使用谷歌願景API來開發面部跟蹤應用程序(API doc)Android相機:無法連接到服務
這是我的清單:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-feature android:name="android.hardware.camera.front" android:required="true"/>
<meta-data android:name="com.google.android.gms.vision.DEPENDENCIES" android:value="face"></meta-data>
*activities*
這是我的代碼:
private void startCameraSource() {
try {
mCameraSource.start(mPreviewHolder);
} catch (IOException e) {
//Error handling
Toast.makeText(this, "Could not start camera!", Toast.LENGTH_LONG).show();
}
}
這是logcat的錯誤:
Caused by: java.lang.RuntimeException: Fail to connect to camera service
E/AndroidRuntime: at android.hardware.Camera.<init>(Camera.java:520)
E/AndroidRuntime: at android.hardware.Camera.open(Camera.java:361)
E/AndroidRuntime: at com.google.android.gms.vision.CameraSource.zzEu(Unknown Source)
E/AndroidRuntime: at com.google.android.gms.vision.CameraSource.start(Unknown Source)
爲什麼會發生這種情況(...在Xperia Z3 compact 5.1上)?
UPDATE:
我發現了一個新的錯誤。我認爲這可能是我的代碼無法工作的原因。
我該如何解決這個問題?
W/ServiceManager: Permission failure: android.permission.CAMERA from uid=10241 pid=26845
E/CameraService: Permission Denial: can't use the camera pid=26845, uid=10241
哪裏是SurfaceView及其SurfaceHolder和相關函數?例如onSurfaceCreated() –
我在佈局文件中創建了表面視圖,並使用'getHolder()'獲取SurfaceHolder對象。我沒有任何方法,但這不應該是一個問題,對吧? – 000000000000000000000