Пример #1
0
        /// <summary>
        /// 根据摄像头名称获取该摄像头的第一个分辨率,若没有分辨 则返回为空字符串
        /// </summary>
        /// <param name="camereName"></param>
        /// <returns></returns>
        public static string GetCamereFirstResolution(string cameraName)
        {
            FilterInfoCollection videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            for (int i = 0; i < videoDevices.Count; i++)
            {
                var cam = videoDevices[i];
                if (cam.Name == cameraName)
                {
                    return(VideoHelper.GetCameraResolution(i)[0].Value.ToString());
                }
            }
            return("");
        }
Пример #2
0
        /// <summary>
        /// 设置默认的摄像头,如果没有 则设置为“无”
        /// </summary>
        public static void SetDefaultCamera()
        {
            var cameraList = VideoHelper.GetAllCameras();

            if (cameraList.Count != 0)
            {
                XmlHelper.SetValue("Camera", 0, cameraList[0].Value);
                List <SimpleModel> resolutionList = VideoHelper.GetCameraResolution(0);
                if (resolutionList != null && resolutionList.Count != 0)
                {
                    XmlHelper.SetValue("CameraResolution", 0, resolutionList[0].Value);
                    var listCameraSize = VideoHelper.GetCameraSize(resolutionList[0].Value);
                    if (listCameraSize != null && listCameraSize.Count != 0)
                    {
                        XmlHelper.SetValue("CameraSize", 0, listCameraSize[0].Value);
                    }
                }
            }
            else
            {
                XmlHelper.SetValue("Camera", "无");
            }
        }