示例#1
0
        //IntPtr pd = IntPtr.Zero;

        private void ProcessFrame(VideoFrame frame)
        {
            //if (pd == IntPtr.Zero)
            //{
            //    pd = CV.PedestrianDetectorInit();
            //    CV.PedestrianDetectorSetEngineSettings(pd, 0.5, 5, true, Color.YellowGreen);
            //}

            //long time;
            //CVPedestrians items = new CVPedestrians();
            //int count = CV.PedestrianDetectorProcess(pd, frame, ref items, out time);
            //Trace.WriteLine($"Count: {count}, time: {time}");

            var image = frame.ToRAWImage();
            var faces = faceDetector?.Process(image);

            carCounter?.Process(image);
            pedestrianDetector?.Process(image);

            if (cbFDMosaic.Checked)
            {
                if (faces != null)
                {
                    foreach (var face in faces)
                    {
                        var rect = face.Position;
                        rect.Top -= 10;
                        if (rect.Top < 0)
                        {
                            rect.Top = 0;
                        }

                        rect.Left -= 10;
                        if (rect.Left < 0)
                        {
                            rect.Left = 0;
                        }

                        rect.Bottom += 10;
                        if (rect.Bottom > image.Height)
                        {
                            rect.Bottom = image.Height;
                        }

                        rect.Right += 10;
                        if (rect.Right > image.Width)
                        {
                            rect.Right = image.Width;
                        }

                        MFP.EffectMosaicROI(frame.Data, image.Width, image.Height, 45, rect);
                    }
                }
            }
        }
示例#2
0
        //IntPtr pd = IntPtr.Zero;


        private void ProcessFrame(RAWImage frame)
        {
            //if (pd == IntPtr.Zero)
            //{
            //    pd = CV.PedestrianDetectorInit();
            //    CV.PedestrianDetectorSetEngineSettings(pd, 0.5, 5, true, Color.YellowGreen);
            //}

            //long time;
            //CVPedestrians items = new CVPedestrians();
            //int count = CV.PedestrianDetectorProcess(pd, frame, ref items, out time);
            //Trace.WriteLine($"Count: {count}, time: {time}");

            faceDetector?.Process(frame);
            carCounter?.Process(frame);
            pedestrianDetector?.Process(frame);
        }