关于面部识别和检测的慢速视频

问题描述 投票:0回答:1

我正在使用EMGUCV进行面部检测和识别,使用的版本是'3.3.0',使用的IP摄像机是CP Plus子弹型摄像机。

我能够进行检测和识别,但是识别后的实时视频非常慢,比实际流慢了10-15秒。不确定代码中是否包含任何内容。

下面是我到目前为止完成的代码。不确定如何加快速度。

Form_Load()
{
    _videoCapture = new VideoCapture("rtsp://uname:[email protected]:554");
    Application.Idle += new EventHandler(FrameGrabber_Standard);
} 
private void FrameGrabber_Standard(object sender, EventArgs e)
        {
            try
            {
                Image<Bgr, Byte> currentFrame = _videoCapture.QueryFrame().ToImage<Bgr, Byte>().Resize(640, 480, Inter.Cubic);
                if (currentFrame != null)
                {
                    Image<Gray, byte> gray_frame = currentFrame.Convert<Gray, Byte>();
                    List<Rectangle> listFaces = new List<Rectangle>();
                    detectfacensobj.DetectFaces(currentFrame, listFaces); //the actual face detection happens here
                    foreach (Rectangle face in listFaces)
                    {
                        faceResult = currentFrame.Convert<Bgr, byte>();
                        if (Eigenfaces.IsTrained)
                        {
                            Image<Gray, byte> grayFaceResult = faceResult.Convert<Gray, byte>();
                            var result = Eigenfaces.eigenFaceRecognizer.Predict(grayFaceResult.Resize(200, 200, Inter.Cubic));
                            if (result.Label != -1)
                            {
                                CvInvoke.PutText(currentFrame, Eigenfaces.eigenlabels[result.Label], new System.Drawing.Point(face.X - 2, face.Y - 2), FontFace.HersheyComplex, 1.0, new Bgr(Color.Orange).MCvScalar);
                            }

                        }

                        currentFrame.Draw(face, new Bgr(Color.Red), 2);
                    }
                    captureImageBox.Image = currentFrame.Bitmap;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }
public bool DetectFaces(IInputArray image, List<Rectangle> listfaces)
        {
            bool isDetect = false;

            try
            {
                using (UMat grayImage = new UMat())
                {
                    CvInvoke.CvtColor(image, grayImage, ColorConversion.Bgr2Gray);
                    CvInvoke.EqualizeHist(grayImage, grayImage);

                    Rectangle[] facesDetected = faceCascadeClass.DetectMultiScale(grayImage, 1.1, 3, new Size(20, 20));
                    if (facesDetected.Length == 0)
                    {
                        isDetect = false;
                    }
                    else
                    {
                        isDetect = true;
                        listfaces.AddRange(facesDetected);
                    }
                }

            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show("Erro" + ex.Message);
            }
            return isDetect;
        }
```````````````````
emgucv
1个回答
0
投票

[如果您想更快地进行人脸检测,请查看此视频https://www.youtube.com/watch?v=tnhemcKciNY

使用Xailient人脸检测器,他们可以使用单核在Raspberry Pi 3b +上获得24fps。

© www.soinside.com 2019 - 2024. All rights reserved.