mobile vision API takes too long to detect face

后端 未结 1 912
清酒与你
清酒与你 2021-01-21 23:46

I am using mobile vision API to detect face in android app.

I have used SparseArray of Face to store the references to faces, but the detector.detect(frame) method takes

相关标签:
1条回答
  • 2021-01-22 00:20

    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.

    0 讨论(0)
提交回复
热议问题