AForge Camera in nor launching

Viewed 38

I have a C# project, the project initiate the camera when needs to capture a picture, and then calls the save function to capture the image.

the code was working normally but now I don't know what happened, although nothing changed in the code, all that happened was that my colleague messed up the packages of the project and I reintroduced the required AForge references to the project.

Any ideas ?

EDIT: I tried to check the old version on the git, and it didn't work as well.

the handler class is this one:

    {
        public static Bitmap img;
        public static void Initation()
        {
            VideoCaptureDevice video;
            FilterInfoCollection filter;
            try
            {
                filter = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                video = new VideoCaptureDevice(filter[0].MonikerString);
                video.NewFrame += new NewFrameEventHandler(Camera_On);
                video.Start();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }

        private static void Camera_On(object sender, NewFrameEventArgs eventArgs)
        {
            img = (Bitmap)eventArgs.Frame.Clone();
        }
        public static string Save()
        {
            System.Drawing.Imaging.ImageFormat format = null;
            format = System.Drawing.Imaging.ImageFormat.Jpeg;
            string name = InitialSetup.currentLkr.Name + @"\" + InitialSetup.currentLkr.Name + "_" + DateTime.Now.ToString() + ".jpg";
            name = name.Replace(@"/", "_");
            name = name.Replace(" ", "_");
            name = name.Replace(":", "-");
            name = @"D:\" + name;
            img.Save(name);
            return name;
        }
    }
0 Answers
Related