-3

OpenCV を使用して顔検出のコードを作成しました。ビデオファイルがあり、特定の間隔に基づいてビデオから画像を抽出し、各画像で顔検出を実行しています。そのため、人物がカメラの前に 5 分間立っていて、画像抽出間隔が 1 分の場合があるため、次の 5 つの画像では人物が同じになります。では、各画像の人物が同じか異なるかをどのように確認できますか? 以下は、顔検出のコードです。

private static Rectangle[] DetectFace(Image<Bgr, Byte> image, string faceFileName)
        {           
            if (GpuInvoke.HasCuda)
            {
                using (GpuCascadeClassifier face = new GpuCascadeClassifier(faceFileName))
                {
                    using (GpuImage<Bgr, Byte> gpuImage = new GpuImage<Bgr, byte>(image))
                    using (GpuImage<Gray, Byte> gpuGray = gpuImage.Convert<Gray, Byte>())
                    {
                        Rectangle[] faceRegion = face.DetectMultiScale(gpuGray, 1.1, 10, Size.Empty);

                        return faceRegion;
                    }
                }
            }
            else
            {
                //Read the HaarCascade objects
                using (CascadeClassifier face = new CascadeClassifier(faceFileName))
                {

                    using (Image<Gray, Byte> gray = image.Convert<Gray, Byte>()) //Convert it to Grayscale
                    {
                        //normalizes brightness and increases contrast of the image
                        gray._EqualizeHist();                       

                        //Detect the faces  from the gray scale image and store the locations as rectangle
                        //The first dimensional is the channel
                        //The second dimension is the index of the rectangle in the specific channel
                        Rectangle[] facesDetected = face.DetectMultiScale(
                           gray,
                           1.1,
                           10,
                           new Size(filterWidth, filterHeight),
                           Size.Empty);

                        return facesDetected;
                    }
                }
            }
        }
4

1 に答える 1

2

最後の N フレームの中央値を計算することで、背景画像を作成できます。新しい各フレームから背景を差し引くことができるため、変更のみが表示されます。大まかに人を認識してみてください (たとえば、ブロブのサイズや形状によって)。カメラのフレームレートに基づいて、誰かがカメラの前で過ごした平均時間を計算できます。

もっと正確に言いたいのですが、あなたがすでに試したことのコードが必要です...

于 2013-06-07T10:04:37.750 に答える