Exemple #1
0
        public void Initialize(SettingsBase settings) //throws Exception
        {
            //Get the Foscam camera type (MJPEG or HD)
            FoscamCameraType cameraType;
            string           _cameraType = (string)settings[PTZSettings.SETTING_CAMERA_TYPE];

            if (_cameraType == null || _cameraType == "")
            {
                cameraType = DEFAULT_CAMERA_TYPE;
            }
            else
            if (string.Equals(_cameraType, SETTING_CAMERA_FOSCAM_HD, StringComparison.OrdinalIgnoreCase))
            {
                cameraType = FoscamCameraType.FoscamHD;
            }
            else if (string.Equals(_cameraType, SETTING_CAMERA_FOSCAM_MJPEG, StringComparison.OrdinalIgnoreCase))
            {
                cameraType = FoscamCameraType.FoscamMJPEG;
            }
            else
            {
                throw new ArgumentNullException(PTZSettings.SETTING_CAMERA_TYPE);
            }

            //Get the camera URL
            string url = (string)settings[PTZSettings.SETTING_CAMERA_URL];

            if (url == null || url == "")
            {
                throw new ArgumentNullException(PTZSettings.SETTING_CAMERA_URL);
            }

            //Get the username
            string username = (string)settings[PTZSettings.SETTING_CAMERA_USERNAME] ?? DEFAULT_USERNAME;

            //Get the password
            string password = (string)settings[PTZSettings.SETTING_CAMERA_PASSWORD] ?? DEFAULT_PASSWORD;

            //Create motion and zoom controllers
            _motion = FoscamMotion.CreateFoscamMotionController(cameraType, url, username, password);
            _zoom   = FoscamZoom.CreateFoscamZoomController(cameraType, url, username, password);

            //Create PTZ control UI
            _ptz = new PTZControl()
            {
                MotionController = _motion, ZoomController = _zoom
            };

            _minPanAngle = (double?)settings[PTZSettings.SETTING_MIN_PAN_ANGLE] ?? DEFAULT_MIN_PAN_ANGLE;
            _maxPanAngle = (double?)settings[PTZSettings.SETTING_MAX_PAN_ANGLE] ?? DEFAULT_MAX_PAN_ANGLE;

            _presetCount  = (int?)settings[PTZSettings.SETTING_PRESET_COUNT] ?? DEFAULT_PRESET_COUNT;
            _presetPrefix = (string)settings[PTZSettings.SETTING_PRESET_PREFIX] ?? DEFAULT_PRESET_PREFIX;

            //Unzoom
            ZoomLevel = 0;
            _motion.MotionGotoCenter();
        }
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            FoscamCameraType cameraType =
        #if USE_FOSCAM_HD_CAMERA
                FoscamCameraType.FoscamHD;
        #else
                FoscamCameraType.FoscamMJPEG;
        #endif

            _video  = FoscamVideo.CreateFoscamVideoController(cameraType, CAMERA_URL, USERNAME, PASSWORD);
            _motion = FoscamMotion.CreateFoscamMotionController(cameraType, CAMERA_URL, USERNAME, PASSWORD);
            _zoom   = FoscamZoom.CreateFoscamZoomController(cameraType, CAMERA_URL, USERNAME, PASSWORD);

            if (_video != null)
            {
                UIElement player = _video.VideoDisplay;
                player.SetValue(Grid.RowProperty, 0);
                //player.SetValue(Canvas.ZIndexProperty, -1);
                LayoutRoot.Children.Add(player);
                _video.StartVideo();
            }
        }