示例#1
0
        internal void DiscoverDevices()
        {
            DeviceList.Clear();
            CameraList.Clear();

            foreach (var userCamera in SavedCameras)
            {
                if (userCamera.DeviceInfo != null)
                {
                    try
                    {
                        DeviceList.Add(userCamera.DeviceInfo);
                    }
                    catch (Exception ex)
                    {
                    }
                }

                if (userCamera.Camera != null)
                {
                    try
                    {
                        CameraList.Add(userCamera.Camera);
                    }
                    catch (Exception ex)
                    {
                    }
                }
            }

            DiscoverUsbDevices();
            IPCameraFactory.DiscoverDevices();
        }
 public void Init()
 {
     if (CameraList.Count == 0)
     {
         foreach (Module module in Enum.GetValues(typeof(Module)))
         {
             CameraList.Add(module, new Dictionary <Camera, CameraConfig>());
             foreach (Camera camera in Enum.GetValues(typeof(Camera)))
             {
                 CameraList[module].Add(camera, new CameraConfig());
                 if (CameraList[module][camera].Mat2D.Count == 0)
                 {
                     if (camera == Config.Camera.Top || camera == Config.Camera.Label)
                     {
                         CameraList[module][camera].Mat2D.Add(new Vision.HalCali());
                     }
                     else
                     {
                         CameraList[module][camera].Mat2D.Add(new Vision.HalCali());
                         CameraList[module][camera].Mat2D.Add(new Vision.HalCali());
                     }
                 }
             }
         }
     }
 }
 public CustomerViewModel(Customer customer, IList <Camera> cameraList)
 {
     this._customer = customer;
     this._name     = _customer.Name;
     foreach (var camera in cameraList)
     {
         CameraList.Add(new CameraViewModel(camera));
     }
 }
示例#4
0
 public CustomerViewModel(IVideoService videoService, Customer customer, IList <Camera> cameraList)
 {
     _videoService  = videoService;
     this._customer = customer;
     this._name     = _customer.Name;
     foreach (var camera in cameraList)
     {
         CameraList.Add(new CameraViewModel(_videoService, camera));
     }
 }
示例#5
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel()
        {
            ////if (IsInDesignMode)
            ////{
            ////    // Code runs in Blend --> create design time data.
            ////}
            ////else
            ////{
            ////    // Code runs "for real"
            ////}
            ///

            Title = $"USBÉãÏñÍ·²âÊÔ¹¤¾ß V{Assembly.GetExecutingAssembly().GetName().Version.ToString()}";

            foreach (var item in MultimediaUtil.VideoInputDevices)
            {
                CameraList.Add(item);
            }


            SelectionChangedCmd = new RelayCommand <SelectionChangedEventArgs>(args =>
            {
                VideoSource = CurrentDevice?.Name;
            });


            ScreenShotCmd = new RelayCommand <FrameworkElement>(element =>
            {
                string fileName         = $"½Øͼ {DateTime.Now:yyyy-MM-dd HHmmss}.jpg";
                System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create);
                RenderTargetBitmap bmp  = new RenderTargetBitmap((int)element.ActualWidth, (int)element.ActualHeight, 0, 0, PixelFormats.Pbgra32);
                bmp.Render(element);
                BitmapEncoder encoder = new PngBitmapEncoder();
                encoder.Frames.Add(BitmapFrame.Create(bmp));
                encoder.Save(fs);
                fs.Close();
            });



            if (!IsInDesignMode)
            {
                if (CameraList.Count > 0)
                {
                    CurrentDevice = CameraList[0];
                    VideoSource   = CurrentDevice.Name;
                }
            }
        }
示例#6
0
        public override void Initialize()
        {
            base.Initialize();
            if (App.CurrentAccount == null)
            {
                return;
            }

/*            List<VATRPDevice> cameraList = ServiceManager.Instance.GetAvailableCameras();
 *          string storedCameraId = App.CurrentAccount.SelectedCameraId;
 *          if (cameraList != null)
 *          {
 *              List<string> cameraNames = new List<string>();
 *              foreach (VATRPDevice device in cameraList)
 *              {
 *                  cameraNames.Add(device.displayName);
 *                  if (!string.IsNullOrEmpty(storedCameraId) && storedCameraId.Equals(device.deviceId))
 *                  {
 *                      _selectedCamera = device.displayName;
 *                  }
 *              }
 *              Cameras = cameraNames.ToArray();
 *          }
 */
            foreach (var item in PreferredVideoSizeComboBox.Items)
            {
                var tb = item as TextBlock;
                if (GetPreferredVideoSizeId(tb).Equals(App.CurrentAccount.PreferredVideoId))
                {
                    PreferredVideoSizeComboBox.SelectedItem = item;
                    break;
                }
            }

            List <VATRPDevice> availableCameras = ServiceManager.Instance.GetAvailableCameras();
            VATRPDevice        selectedCamera   = ServiceManager.Instance.GetSelectedCamera();

            CameraList.Clear();
            if (availableCameras == null)
            {
                return;
            }
            foreach (VATRPDevice camera in availableCameras)
            {
                CameraList.Add(camera);
                if ((selectedCamera != null) && selectedCamera.deviceId.Trim().Equals(camera.deviceId.Trim()))
                {
                    SelectCameraComboBox.SelectedItem = camera;
                }
            }

            List <VATRPDevice> availableMicrophones = ServiceManager.Instance.GetAvailableMicrophones();
            VATRPDevice        selectedMicrophone   = ServiceManager.Instance.GetSelectedMicrophone();

            MicrophoneList.Clear();
            foreach (VATRPDevice microphone in availableMicrophones)
            {
                MicrophoneList.Add(microphone);
                if ((selectedMicrophone != null) && selectedMicrophone.deviceId.Trim().Equals(microphone.deviceId.Trim()))
                {
                    SelectMicrophoneComboBox.SelectedItem = microphone;
                }
            }
            List <VATRPDevice> availableSpeakers = ServiceManager.Instance.GetAvailableSpeakers();
            VATRPDevice        selectedSpeaker   = ServiceManager.Instance.GetSelectedSpeakers();

            SpeakerList.Clear();
            foreach (VATRPDevice speaker in availableSpeakers)
            {
                SpeakerList.Add(speaker);
                if ((selectedSpeaker != null) && selectedSpeaker.deviceId.Trim().Equals(speaker.deviceId.Trim()))
                {
                    SelectSpeakerComboBox.SelectedItem = speaker;
                }
            }

            /*            string selectedCameraId = App.CurrentAccount.SelectedCameraId;
             * if (string.IsNullOrEmpty(selectedCameraId))
             * {
             *  VATRPDevice selectedCamera = ServiceManager.Instance.GetSelectedCamera();
             * //                SelectedCameraLabel.Content = selectedCamera.displayName;
             * //                SelectedCameraLabel.ToolTip = selectedCamera.displayName;
             * }
             * else
             * {
             *  foreach (VATRPDevice camera in availableCameras)
             *  {
             *      if (!string.IsNullOrEmpty(selectedCameraId) && selectedCameraId.Equals(camera.deviceId))
             *      {
             *          SelectCameraComboBox.SelectedItem = camera;
             * //                        SelectedCameraLabel.Content = camera.displayName;
             * //                        SelectedCameraLabel.ToolTip = camera.displayName;
             *      }
             *  }
             * }
             *
             * List<VATRPDevice> availableMicrophones = ServiceManager.Instance.GetAvailableMicrophones();
             * string selectedMicrophoneId = App.CurrentAccount.SelectedMicrophoneId;
             * if (string.IsNullOrEmpty(selectedMicrophoneId))
             * {
             *  VATRPDevice selectedMicrophone = ServiceManager.Instance.GetSelectedMicrophone();
             *  SelectedMicrophoneLabel.Content = selectedMicrophone.displayName;
             *  SelectedMicrophoneLabel.ToolTip = selectedMicrophone.displayName;
             * }
             * else
             * {
             *  foreach (VATRPDevice microphone in availableMicrophones)
             *  {
             *      if (!string.IsNullOrEmpty(selectedMicrophoneId) && selectedMicrophoneId.Equals(microphone.deviceId))
             *      {
             *          SelectedMicrophoneLabel.Content = microphone.displayName;
             *          SelectedMicrophoneLabel.ToolTip = microphone.displayName;
             *      }
             *  }
             * }
             *
             * List<VATRPDevice> availableSpeakers = ServiceManager.Instance.GetAvailableSpeakers();
             * string selectedSpeakerId = App.CurrentAccount.SelectedSpeakerId;
             * if (string.IsNullOrEmpty(selectedSpeakerId))
             * {
             *  VATRPDevice selectedSpeaker = ServiceManager.Instance.GetSelectedSpeakers();
             *  SelectedSpeakerLabel.Content = selectedSpeaker.displayName;
             *  SelectedSpeakerLabel.ToolTip = selectedSpeaker.displayName;
             * }
             * else
             * {
             *  foreach (VATRPDevice speaker in availableSpeakers)
             *  {
             *      if (!string.IsNullOrEmpty(selectedSpeakerId) && selectedSpeakerId.Equals(speaker.deviceId))
             *      {
             *          SelectedSpeakerLabel.Content = speaker.displayName;
             *          SelectedSpeakerLabel.ToolTip = speaker.displayName;
             *      }
             *  }
             * }
             * */
        }