Google Vision API:如何检测检测到的人脸是图像人脸还是真实的人脸?

时间:2018-09-28 06:40:41

标签: android image-processing face-detection google-vision

我正在使用谷歌视觉api在我的应用中进行人脸检测。它的工作正常,但就我而言,我只需要处理真实的人脸。但我的应用正在考虑将照片中的面孔作为面孔。但是我想检测哪个是照片,哪个是实时图像。

下面是面部图形的类别

 private class GraphicFaceTracker extends Tracker<Face> {
    private GraphicOverlay mOverlay;
    private FaceGraphic mFaceGraphic;

    GraphicFaceTracker(GraphicOverlay overlay) {
        mOverlay = overlay;
        mFaceGraphic = new FaceGraphic(overlay);
    }

    /**
     * Start tracking the detected face instance within the face overlay.
     */
    @Override
    public void onNewItem(int faceId, Face item) {
        FaceTrackerActivity.faceId = faceId;
        mFaceGraphic.setId(faceId);
    }

    /**
     * Update the position/characteristics of the face within the overlay.
     */
    @Override
    public void onUpdate(FaceDetector.Detections<Face> detectionResults, Face face) {
        mOverlay.add(mFaceGraphic);
        mFaceGraphic.updateFace(face);
       //here face detected live or image

    }

    /**
     * Hide the graphic when the corresponding face was not detected.  This can happen for
     * intermediate frames temporarily (e.g., if the face was momentarily blocked from
     * view).
     */
    @Override
    public void onMissing(FaceDetector.Detections<Face> detectionResults) {
        mOverlay.remove(mFaceGraphic);
    }

    /**
     * Called when the face is assumed to be gone for good. Remove the graphic annotation from
     * the overlay.
     */
    @Override
    public void onDone() {
        mOverlay.remove(mFaceGraphic);
        Log.d("Gajanand", "onDone: ");
    }

}

有什么帮助吗?

0 个答案:

没有答案
相关问题