mobile vision API takes too long to detect face

别说谁变了你拦得住时间么 提交于 2019-12-02 07:20:47

I am currently going through this sample app and I came across the same issue where the app keeps returning that the face is not detected.

After reading through the documentation found here I saw that I should be using detector.isOperational() to test if the required files have been downloaded in order for the detection to work. I used this method to advise that the files are being downloaded like this:

public static void detectFaces(Context context, Bitmap image){
        // Create the face detector, disable tracking and enable classifications

        FaceDetector detector = new FaceDetector.Builder(context)
                .setTrackingEnabled(false)
                .setClassificationType(FaceDetector.ALL_CLASSIFICATIONS)
                .build();

        if(detector.isOperational()){
            // Build the frame
            Frame frame = new Frame.Builder().setBitmap(image).build();
            ...
        }else{
            Toast.makeText(context, R.string.not_operational, Toast.LENGTH_LONG).show();
        }


    }

Next I realized that the detector was never operational. After more research I found the problem to be that my device did not have enough storage space to save the additional files needed. I switched to another device got the 'Not Operational' error on the first try and it has been working ever since then.

Also, freeing up some space and moving the app to external storage allowed it to work on my first device.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!