0

我正在创建一个人脸检测应用程序。当我尝试启动人脸检测时,出现以下错误:

E/NativeFaceDetectorImpl: Native face detection failed
E/NativeFaceDetectorImpl: java.lang.RuntimeException: Error accessing ByteBuffer.

这是我的代码的一部分:

 Context context = getApplicationContext();
    FaceDetector detector = new FaceDetector.Builder(context)
            .setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
            .setMode(FaceDetector.ACCURATE_MODE)
            .build();

    detector.setProcessor(
            new MultiProcessor.Builder<>(new FaceTrackerFactory())
                    .build());

    if (!detector.isOperational()) {
        Log.w(TAG, "Face detector dependencies are not yet available.");
    }

    mCameraSource = new CameraSource.Builder(context, detector)
            .setFacing(CameraSource.CAMERA_FACING_BACK)
            .setRequestedFps(30.0f)
            .build();

当我执行 mCameraSource.start() 时会显示错误,即使这样做时没有检测到错误并且应用程序不会崩溃,它只是在控制台上重复显示该错误。

4

1 回答 1

0

所以我能够找出问题所在。我试图使用 Google Play Services 8.1.0 版中的 Mobile Vision API 为 Android API 19 进行编译。这是在我的 build.gradle 中,但它不起作用

dependencies {
    compile 'com.google.android.gms:play-services-vision:8.1.0'
}

android {
    compileSdkVersion 19
}

我切换到 7.8 版的 Google Play 服务,现在它工作正常

dependencies {
    compile 'com.google.android.gms:play-services-vision:7.8.+'
}

android {
    compileSdkVersion 19
}

另请注意,我为 Android API 23 编译了另一个类似的项目,对于该版本,Google Play Services 8.1正在运行

dependencies {
    compile 'com.google.android.gms:play-services-vision:8.1.0'
}

android {
    compileSdkVersion 23
}
于 2015-10-09T13:44:47.560 回答