Example #1
0
        public IVideoFormat[] GetAvailableVideoFormats(ICamera target)
        {
            if (target is not WindowsCamera camera)
            {
                throw new ArgumentException("Provided ICamera object is not for this platform.",
                                            target.ToString());
            }

            var camera_list = WindowsCapture.FindDevices();

            if (camera.CameraIndex >= 0 && camera.CameraIndex < camera_list.Length)
            {
                var videoFormats = WindowsCapture.GetVideoFormat(camera.CameraIndex);

                var genericVF = new IVideoFormat[videoFormats.Length];

                for (var i = 0; i < genericVF.Length; i++)
                {
                    var vf = videoFormats[i];
                    genericVF[i] = new WindowsVideoFormats(vf.SubType,
                                                           new PixelSize((int)vf.Size.Width, (int)vf.Size.Height), vf);
                }

                return(genericVF);
            }

            throw new ArgumentException("Specified camera is not available.", target.CameraName);
        }
Example #2
0
        public ICamera[] GetAvailableCameras()
        {
            var devices_name = WindowsCapture.FindDevices();
            var cameraArray  = new ICamera[devices_name.Length];

            for (var i = 0; i < devices_name.Length; i++)
            {
                cameraArray[i] = new WindowsCamera(devices_name[i], i);
            }

            return(cameraArray);
        }