Пример #1
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using (Mat image = new Mat("pedestrian.png"))
            {
                long        processingTime;
                Rectangle[] results;

                if (CudaInvoke.HasCuda)
                {
                    using (GpuMat gpuMat = new GpuMat(image))
                        results = FindPedestrian.Find(gpuMat, out processingTime);
                }
                else
                {
                    using (UMat uImage = image.GetUMat(AccessType.ReadWrite))
                        results = FindPedestrian.Find(uImage, out processingTime);
                }

                foreach (Rectangle rect in results)
                {
                    CvInvoke.Rectangle(image, rect, new Bgr(Color.Red).MCvScalar);
                }
                ImageViewer.Show(
                    image,
                    String.Format("Pedestrian detection using {0} in {1} milliseconds.",
                                  CudaInvoke.HasCuda ? "GPU" :
                                  CvInvoke.UseOpenCL ? "OpenCL":
                                  "CPU",
                                  processingTime));
            }
        }
Пример #2
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using (Image <Bgr, Byte> image = new Image <Bgr, byte>("pedestrian.png"))
            {
                long        processingTime;
                Rectangle[] results = FindPedestrian.Find(image, out processingTime);
                foreach (Rectangle rect in results)
                {
                    image.Draw(rect, new Bgr(Color.Red), 1);
                }
                ImageViewer.Show(
                    image,
                    String.Format("Pedestrain detection using {0} in {1} milliseconds.",
                                  GpuInvoke.HasCuda ? "GPU" : "CPU",
                                  processingTime));
            }
        }
Пример #3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using (Image <Bgr, byte> image = new Image <Bgr, byte>("pedestrian.png"))
            {
                long        processingTime;
                Rectangle[] results = FindPedestrian.Find(image.Mat, out processingTime);
                foreach (Rectangle rect in results)
                {
                    CvInvoke.Rectangle(image, rect, new MCvScalar(0, 0, 255, 255));
                }
                ImageViewer.Show(
                    image,
                    String.Format("Pedestrain detection using {0} in {1} milliseconds.",
                                  CudaInvoke.HasCuda ? "GPU" :
                                  (CvInvoke.HaveOpenCL ? "OpenCL":
                                   "CPU"),
                                  processingTime));
            }
        }
Пример #4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            using (Mat image = new Mat("pedestrian.png", LoadImageType.Color))
            {
                bool        tryUseCuda = true;
                long        processingTime;
                Rectangle[] results = FindPedestrian.Find(image, tryUseCuda, out processingTime);
                foreach (Rectangle rect in results)
                {
                    CvInvoke.Rectangle(image, rect, new Bgr(Color.Red).MCvScalar);
                }
                ImageViewer.Show(
                    image,
                    String.Format("Pedestrian detection using {0} in {1} milliseconds.",
                                  (tryUseCuda && CudaInvoke.HasCuda) ? "GPU" :
                                  CvInvoke.UseOpenCL ? "OpenCL":
                                  "CPU",
                                  processingTime));
            }
        }