OpenCv Face检测样本有时会返回零面

时间:2016-02-11 06:08:57

标签: android opencv4android

我正在opencv使用face detection。我正在运行Open Cv FaceDetection样本。问题是

  

有时,即使面孔中有面孔,面部检测计数也会返回零   相机

Sample在每个相机框架上使用以下功能:

public Mat onCameraFrame(CvCameraViewFrame inputFrame) {

        mRgba = inputFrame.rgba();
        mGray = inputFrame.gray();

        if (mAbsoluteFaceSize == 0) {
            int height = mGray.rows();
            if (Math.round(height * mRelativeFaceSize) > 0) {
                mAbsoluteFaceSize = Math.round(height * mRelativeFaceSize);
            }
            mNativeDetector.setMinFaceSize(mAbsoluteFaceSize);
        }

        MatOfRect faces = new MatOfRect();

        if (mDetectorType == JAVA_DETECTOR) {
            if (mJavaDetector != null)
                mJavaDetector.detectMultiScale(mGray, faces, 1.1, 2, 2, // TODO: objdetect.CV_HAAR_SCALE_IMAGE
                        new Size(mAbsoluteFaceSize, mAbsoluteFaceSize), new Size());
        }
        else if (mDetectorType == NATIVE_DETECTOR) {
            if (mNativeDetector != null)
                mNativeDetector.detect(mGray, faces);
        }
        else {
            Log.e(TAG, "Detection method is not selected!");
        }

        Rect[] facesArray = faces.toArray();
        if(facesArray.length == 0) {
            Log.i(TAG, "No face detected");

        } else {
            Log.i(TAG, "Faces detected -> length : " + facesArray.length);
        }
        return mRgba;
    }
  

任何人都可以告诉我如何修复面部检测计数   问题

此致

0 个答案:

没有答案