简体   繁体   中英

Detecting contours of multiple faces via Firebase ML Kit face detection

I read somewhere for this https://developers.google.com/vision/android/detect-faces-tutorial lib that it can detect contours of only one face in picture. Than i updgraded for Firebase ML Kit in hope that they fixed that, but my code gets me only contours of one face in picture. Is there a way to detect all contours via ML Kit face detection? If there isn't, is there a workaround to do that? I don`t even think that i need all contours. I only need oval contours, so i know where the whole face is.

            FirebaseVisionFace face = myFaces.get(i);
            FirebaseVisionFaceContour contour;
            int k = 0;

            contour = face.getContour(FirebaseVisionFaceContour.FACE);
            List<FirebaseVisionPoint> points = contour.getPoints();
            for (int j = 0; j < points.size(); j++) {
                if (j < contour.getPoints().size() - 2) {
                    canvas.drawLine(contour.getPoints().get(j).getX(), contour.getPoints().get(j).getY(), contour.getPoints().get(j + 1).getX(), contour.getPoints().get(j + 1).getY(), mPaint);

                } else if (j == contour.getPoints().size()-1) {
                    canvas.drawLine(contour.getPoints().get(j).getX(), contour.getPoints().get(j).getY(), contour.getPoints().get(0).getX(), contour.getPoints().get(0).getY(), mPaint);
                }
            }
        }
        ((ImageView) findViewById(R.id.image_view)).setImageBitmap(finalProduct);```

Based on this documentation, if you setCountourMode to ALL_CONTOURS , you can only detect the most prominent face in an image. If you want to detect more than one face, you can setContourMode to NO_CONTOURS .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM