2

I am trying to develop a face tracking app using the Google Vision API (API doc)


This is my manifest:

<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*


This is my code:

private void startCameraSource() {
    try {
        mCameraSource.start(mPreviewHolder);
    } catch (IOException e) {
        //Error handling
        Toast.makeText(this, "Could not start camera!", Toast.LENGTH_LONG).show();
    }
}


This is the error in 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)


Why does this happen (...on an Xperia Z3 compact 5.1)?


UPDATE:

I spotted a new error. I think it might be the reason why my code is not working.
How can I resolve this problem?

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
000000000000000000000
  • 1,467
  • 1
  • 19
  • 38
  • where's the SurfaceView and it's SurfaceHolder and associated functions? e.g. onSurfaceCreated() – David M Nov 02 '15 at 16:47
  • I created the surface view in my layout file and I use `getHolder()` to get the SurfaceHolder object. I did not overright any methods, but that shouldn't be a problem, right? – 000000000000000000000 Nov 03 '15 at 06:05

1 Answers1

1

I found a solution to my problem in the answer to this question.
I had to move

<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>

int the <manifest>-tag.

Community
  • 1
  • 1
000000000000000000000
  • 1,467
  • 1
  • 19
  • 38