2

我在 C++ 中找到了一些关于如何使用 OpenCV 检测眨眼的示例。

不幸的是,很难为Android找到相同的东西。

我发现了这个:

case Sample2NativeCamera.VIEW_MODE_HOUGH_CIRCLES:
        capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);

         Imgproc.cvtColor(mRgba, mGray, Imgproc.COLOR_RGBA2GRAY, 4);

        // doing a gaussian blur prevents getting a lot of small false circles
        Imgproc.GaussianBlur(mGray, mGray, new Size(5, 5), 2, 2);

        // the lower this figure the more spurious circles you get
        // 50 looks good in CANNY, but 100 is better when converting that into Hough circles
        iCannyUpperThreshold = 100;
        Imgproc.HoughCircles(mGray, mIntermediateMat, Imgproc.CV_HOUGH_GRADIENT, 2.0, mGray.rows() / 8, 
        iCannyUpperThreshold, iAccumulator, iMinRadius, iMaxRadius);

         if (mIntermediateMat.cols() > 0)
            for (int x = 0; x < Math.min(mIntermediateMat.cols(), 10); x++) 
                {
                double vCircle[] = mIntermediateMat.get(0,x);

                if (vCircle == null)
                    break;

                pt = new Point(Math.round(vCircle[0]), Math.round(vCircle[1]));
                radius = (int)Math.round(vCircle[2]);
                // draw the found circle
                Core.circle(mRgba, pt, radius, colorRed, iLineThickness);

                // draw a cross on the centre of the circle
                DrawCross (mRgba, pt);
                }

            if (bDisplayTitle)
                ShowTitle ("Hough Circles", 1);

        break;

但我不知道如何在我的 OpenCV 示例代码中使用它。我有所有 OpenCV 示例代码。我正在玩 OpenCV - 人脸检测。

我只是将级联从正面更改为眼睛。所以,它起作用了……它检测到眼睛。

但是,我需要检测的不仅仅是眼睛的位置。我需要检测用户何时眨眼。我看到了上面的代码,但我不知道如何在我的 OpenCV 人脸检测代码中使用它,因为它使用级联来检测眼睛。上面的方法没有使用级联。那么,我该如何使用它呢?

关于如何使用 OpenCV 检查眨眼的任何想法?

我花了将近一周的时间在谷歌和这里寻找这些信息,但我找不到适用于 Android 的信息。=(

欢迎任何帮助!

4

4 回答 4

1

如果您可以检测到眼睛,那么您可以寻找消失然后很快重新出现的眼睛。这看起来像是眨眼。如果您可以检测到嘴,那么您可以确保它也保持在大致相同的位置。

于 2012-11-13T11:11:33.810 回答
1

我不确切知道您的实现如何,但这段代码将有助于识别圆圈,在这种情况下是针对学生。您可以使用 Viola Jones 获得眼睛 roi(感兴趣区域),应用 Canny 检测器,然后使用 Hough 变换寻找圆圈(睁眼)或线条(闭眼)。

一些有用的链接:

中提琴琼斯:http ://docs.opencv.org/modules/objdetect/doc/cascade_classification.html

霍夫变换:http ://docs.opencv.org/doc/tutorials/imgproc/imgtrans/hough_lines/hough_lines.html

Canny 检测器: http: //docs.opencv.org/doc/tutorials/imgproc/imgtrans/canny_detector/canny_detector.html

另一种方法是使用匹配模板,例如http://www.technolabsz.com/2013/05/eye-blink-detection-using-opencv-in.html

于 2015-05-26T17:09:03.953 回答
1

谷歌已经发布了Android 的FaceDetectorApi(),它给了我们双眼睁开眼睛的概率,使用它我们可以检测眨眼,这是我所做的项目实现,它可以实时运行https://github。 com/murali129/眨眼检测器

于 2018-01-23T00:53:40.803 回答
0

如果您在 c++ 中有眨眼检测功能,您可以使用原生函数 (JNI) 从 android 调用该函数,而不是返回布尔值 True 或 false,具体取决于对您的 java 代码的检测。

于 2012-11-13T10:59:44.977 回答