Example #1
0
        protected override void OnSubscribe()
        {
            base.OnSubscribe();

            _captureConfig = CameraCapture.GetCaptureProperties();
            _centre = _captureConfig.Resolution.GetCenter();

            txtReticleX.Text = _centre.X.ToString();
            txtReticleY.Text = _centre.Y.ToString();

            var screen = new TextboxScreen(txtScreen);

            //var imageTransmitter = new BsonPostImageTransmitter();
            var imageTransmitter = new BsonPostJpegTransmitter();
            var colorSettings = _colourSettingsRepo.Read();
            var motionSettings = _motionSettingsRepo.Read();

            // these should be disposed if not null

            _faceTrackingController = new FaceTrackingPanTiltController(PanTiltMechanism, _captureConfig);
            _colourTrackingController = new ColourTrackingPanTiltController(PanTiltMechanism, _captureConfig);
            _motionTrackingController = new MotionTrackingPanTiltController(PanTiltMechanism, _captureConfig, screen);

            // if haven't subscribed first time yet
            if (_multimodePanTiltController == null)
            {
                _remoteScreen = new RemoteTextboxScreen(CameraHubProxy, txtScreen);
                _remoteImageSender = new RemoteImageSender(imageTransmitter, CameraHubProxy);

                CameraHubProxy.SettingsChanged += (o, s) =>
                {
                    _remoteScreen.WriteLine($"Camera received new settings: {s}");
                    _remoteImageSender.SendEveryPeriod = s.TransmitImagePeriod;
                    _remoteImageSender.Enabled = s.EnableImageTransmit;
                    _remoteScreen.Enabled = s.EnableConsoleTransmit;
                };
            }
            else
            {
                // don't resubscribe and get duplicate events on cameraHubProxy
                _multimodePanTiltController.Unsubscribe();
            }

            _multimodePanTiltController = new MultimodePanTiltController(
                PanTiltMechanism
                , _captureConfig
                , _remoteScreen
                , CameraHubProxy
                , _remoteImageSender);

            _calibratingPanTiltController = new CalibratingPanTiltController(PanTiltMechanism, new CalibrationReadingsRepository(), screen);
            _colourTrackingController.Settings = colorSettings;
            _calibratingPanTiltController.Settings = colorSettings;
            _motionTrackingController.Settings = motionSettings;

            _calibratingPanTiltController.GetCameraCapture = PullImage;
            _calibratingPanTiltController.WaitStep = CalibrationWaitStep;
            _calibratingPanTiltController.ColourCaptured += _calibratingPanTiltController_ColourCaptured;

            // default check states
            chkBoxColourTracking.Checked = false;
            chkBoxFaceTracker.Checked = false;
            chkBoxMotionTracking.Checked = false;
            chkMultimode.Checked = false;

            Log.InfoFormat("MotionSettings: {0}", motionSettings);
        }
Example #2
0
        protected override void OnSubscribe()
        {
            base.OnSubscribe();

            _captureConfig = CameraCapture.GetCaptureProperties();
            _centre        = _captureConfig.Resolution.GetCenter();

            txtReticleX.Text = _centre.X.ToString();
            txtReticleY.Text = _centre.Y.ToString();

            var screen = new TextboxScreen(txtScreen);

            //var imageTransmitter = new BsonPostImageTransmitter();
            var imageTransmitter = new BsonPostJpegTransmitter();
            var colorSettings    = _colourSettingsRepo.Read();
            var motionSettings   = _motionSettingsRepo.Read();

            // these should be disposed if not null

            _faceTrackingController   = new FaceTrackingPanTiltController(PanTiltMechanism, _captureConfig);
            _colourTrackingController = new ColourTrackingPanTiltController(PanTiltMechanism, _captureConfig);
            _motionTrackingController = new MotionTrackingPanTiltController(PanTiltMechanism, _captureConfig, screen);

            // if haven't subscribed first time yet
            if (_multimodePanTiltController == null)
            {
                _remoteScreen      = new RemoteTextboxScreen(CameraHubProxy, txtScreen);
                _remoteImageSender = new RemoteImageSender(imageTransmitter, CameraHubProxy);

                CameraHubProxy.SettingsChanged += (o, s) =>
                {
                    _remoteScreen.WriteLine($"Camera received new settings: {s}");
                    _remoteImageSender.SendEveryPeriod = s.TransmitImagePeriod;
                    _remoteImageSender.Enabled         = s.EnableImageTransmit;
                    _remoteScreen.Enabled = s.EnableConsoleTransmit;
                };
            }
            else
            {
                // don't resubscribe and get duplicate events on cameraHubProxy
                _multimodePanTiltController.Unsubscribe();
            }

            _multimodePanTiltController = new MultimodePanTiltController(
                PanTiltMechanism
                , _captureConfig
                , _remoteScreen
                , CameraHubProxy
                , _remoteImageSender);


            _calibratingPanTiltController          = new CalibratingPanTiltController(PanTiltMechanism, new CalibrationReadingsRepository(), screen);
            _colourTrackingController.Settings     = colorSettings;
            _calibratingPanTiltController.Settings = colorSettings;
            _motionTrackingController.Settings     = motionSettings;

            _calibratingPanTiltController.GetCameraCapture = PullImage;
            _calibratingPanTiltController.WaitStep         = CalibrationWaitStep;
            _calibratingPanTiltController.ColourCaptured  += _calibratingPanTiltController_ColourCaptured;

            // default check states
            chkBoxColourTracking.Checked = false;
            chkBoxFaceTracker.Checked    = false;
            chkBoxMotionTracking.Checked = false;
            chkMultimode.Checked         = false;

            Log.InfoFormat("MotionSettings: {0}", motionSettings);
        }