Пример #1
0
        public static void ReleaseInactiveCameras()
        {
            int numberCameras = WebcamManager.NumberConnectedCameras();

            for (int i = 0; i < numberCameras; i++)
            {
                WebCam camera = WebcamManager.GetCamera(i);
                if (camera.Subscribers.Count == 0)
                {
                    camera.Stop();
                    DllImport.StopWebCam(camera.WebCamID);
                }
            }
        }
Пример #2
0
        public static void StopCamera(int index)
        {
            int numberCameras = WebcamManager.NumberConnectedCameras();

            if (index > -1 && index < numberCameras)
            {
                WebCam camera = WebcamManager.GetCamera(index);
                for (int i = 0; i < camera.Subscribers.Count; i++)
                {
                    ImageListenerBase l = camera.Subscribers[i];
                    l.UnregisterForImages(camera);
                }
                camera.Subscribers.Clear();
                camera.Stop();
                DllImport.StopWebCam(camera.WebCamID);
            }
        }
Пример #3
0
        public static bool StartCamera(int index, int CaptureWidth, int CaptureHeight)
        {
            int numberCameras = WebcamManager.NumberConnectedCameras();

            if (index > -1 && index < numberCameras)
            {
                WebCam camera = WebcamManager.GetCamera(index);
                camera.Width  = CaptureWidth;
                camera.Height = CaptureHeight;
                try
                {
                    camera.Start();
                }
                catch (Exception e)
                {
                    //System.Windows.Forms.MessageBox.Show(e.ToString());
                    camera.Stop();
                    return(false);
                }
                return(true);
            }
            return(false);
        }