如何通过Android上的OPENCV提高面部检测性能

How to improve face detection performance with OpenCV on Android?

本文关键字:高面部 检测 性能 OPENCV 何通过 Android 上的      更新时间:2023-10-16

我正在从事一个Android项目,我正在使用OpenCV通过相机检测面。应用程序可以正确检测到面部,但性能非常慢。我已经多次检查了这个问题,但是找不到任何解决方案。有什么方法可以改善性能?

我的代码是:

      QVideoFrame FilterRunnable::run( QVideoFrame *input,
                             const QVideoSurfaceFormat &surfaceFormat,
                             QVideoFilterRunnable::RunFlags flags )
      {
          input->map(QAbstractVideoBuffer::ReadOnly);
          QImage image = imageWrapper(*input);
          image = image.scaled(640,480);
          cv::Mat mat(image.width(),image.height(),CV_8UC3,image.bits(),                image.bytesPerLine());
          vector< Rect > detectedFaces;
          detectedFaces.clear();
          frontalFaceClassifier.detectMultiScale( mat, detectedFaces,
                                   1.6, 3, 2 | CV_HAAR_SCALE_IMAGE ,  Size(60,60) );
          qDebug()<<"Cantidad de caras en el vector : " << detectedFaces.size();
          if( detectedFaces.size() > 0 ){
              actualFace = detectedFaces.at( 0 );
          countDetectedFaces++;
          qDebug()<<"**********qwerty**********"<<detectedFaces.size();
          }
          for(int i=0;i<detectedFaces.size();i++)
          {
            Rect dibujarCuadrado = detectedFaces.at(i);
            cv::rectangle (mat, dibujarCuadrado, 20, 1, LINE_8, 0);
          }
      }

我看到您仅实现了一个HAAR分类器。我以为您使用前面一个。您可以将配置文件面部分类器(在OpenCV HAAR软件包中可用)中添加到其他语句中,以提高准确性。通常,您可以培训所需的任何分类器并将其合并。对于培训分类器,这是一个很棒的视频