Пример #1
0
        public static bool SetPropertyValueAuto(int cameraindex, CAMERA_PROPERTY prop)
        {
            int numberCameras = WebcamManager.NumberConnectedCameras();

            if (cameraindex > -1 && cameraindex < numberCameras)
            {
                return(DllImport.SetPropertyValueAuto(cameraindex, Convert.ToInt32(prop)));
            }
            return(false);
        }
Пример #2
0
        public static bool GetMaxPropertyValue(int cameraindex, CAMERA_PROPERTY prop, ref long val)
        {
            int numberCameras = WebcamManager.NumberConnectedCameras();

            if (cameraindex > -1 && cameraindex < numberCameras)
            {
                return(DllImport.GetMaxPropertyValue(cameraindex, Convert.ToInt32(prop), ref val));
            }
            return(false);
        }
Пример #3
0
 public bool ConfigureCamera()
 {
     if (_index > -1 && _index < DllImport.GetNumberOfConnectedWebCams() && _isavailable)
     {
         return(DllImport.ConfigureCameraProperties(_index));
     }
     else
     {
         return(false);
     }
 }
Пример #4
0
 void RunWorker()
 {
     while (!stopSignal.WaitOne(0, true))
     {
         //1. get the byte buffer from the webcam
         if (DllImport.GrabFrameWebcam(_index, rawBuffer, _width, _height))
         {
             // signal that the mapped video memory is ready with a new buffer, causing the 'Source' to refresh with the new buffer...
             OnBitmapReady(this, null);
             Thread.Sleep(30); //increasing this will reduce the CPU load... reducing this is not recommended, as buffers will overlap
         }
     }
 }
Пример #5
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);
                }
            }
        }
Пример #6
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);
            }
        }
Пример #7
0
        private static void UpdateCameraList()
        {
            DllImport.RefreshWebcams();
            _numdetectedCameras = DllImport.GetNumberOfConnectedWebCams();
            _detectedCameras    = new List <WebCam>();
            _availableFlags     = new List <bool>();
            for (int i = 0; i < _numdetectedCameras; i++)
            {
                string cameraName  = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(DllImport.GetWebCamName(i));
                string cameraPath  = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(DllImport.GetWebCamPath(i));
                bool   isAvailable = DllImport.IsWebCamAvailable(i);
                WebCam camera      = new WebCam(cameraName, cameraPath, i, isAvailable);

                _detectedCameras.Add(camera);
                _availableFlags.Add(isAvailable);
            }
        }
Пример #8
0
 public static bool IsServiceRestartRequired()
 {
     return(DllImport.IsAnyCameraConnectedOrDisconnected() || NumberConnectedCameras() == 0);
 }