示例#1
0
        public DeviceCalibrationVM(ICalibrator calibrator, IDeviceInitializationVM deviceInitialization, BusyObject busy)
        {
            Calibrator            = calibrator;
            _deviceInitialization = deviceInitialization;
            _busy = busy;

            Begin = new ActionCommand(beginAsync,
                                      () => _busy.IsNotBusy && Calibrator.Model.Begin.IsCanExecute,
                                      _busy, Calibrator.Model.Begin);
            Discard = Calibrator.Model.Discard;

            async Task beginAsync()
            {
                var isExecuted = await _deviceInitialization.Initialize.ExecuteIfCanBeExecutedAsync();

                if (!isExecuted)
                {
                    Logger.LogErrorEverywhere("Не удалось произвести инициализацию");
                }
                else
                {
                    if (_deviceInitialization.IsInitialized)
                    {
                        await Calibrator.Model.Begin.ExecuteIfCanBeExecutedAsync();
                    }
                    else
                    {
                        Logger.LogErrorEverywhere("Устройство не инициализировано, калибровка запрещена");
                    }
                }
            }
        }
 public void Initialise_capture(Device device)
 {
     this.device = device;
     var capturers = this.GetComponents<Capturer>();
     if(capturers.Any())
     {
         foreach(var capturer in capturers)
         {
             Destroy (capturer);
         }
     }
     switch(this.device)
     {
         case Device.MULTI_KINECT_WIMUS:
             this.capturer = this.gameObject.AddComponent<Kinect2Managing>();
             this.calibrator = this.capturer is ICalibrator ? this.capturer as ICalibrator : null;
             this.syncer = this.capturer is ISyncer ? this.capturer as ISyncer : null;
             this.reconstructor = this.capturer is IReconstructor ? this.capturer as IReconstructor : null;
             this.recorder = CompositeRecorder.FromRecorders(this.capturer);//TODO: fusion capturer to be added here
             this.skeletonCapturer = new NoneSkeletonCapturer();//TODO: add fusion here
             break;
         case Device.SINGLE_KINECT_2:
             var k2controller = this.gameObject.AddComponent<Kinect2Controlling>();
             k2controller.Streams = KinectStreams.Skeleton;
             k2controller.enabled = false;// re-enable
             k2controller.enabled = true;
             this.capturer = k2controller;
             this.exporter = GetComponent<SkeletonExporting>();
             this.recorder = CompositeRecorder.FromRecorders(this.capturer);
             this.skeletonCapturer = FindObjectsOfType<Capturer>().First((cap) => cap is ISkeletonGenerator<SkeletonFrame>) as ISkeletonGenerator<SkeletonFrame>;
             break;
     }
 }
示例#3
0
        /// <summary>
        /// Get the calibration summary in INI format
        /// </summary>
        private static string AddCalibrationToIni(IHost host, string ini, ICalibrator calibrator)
        {
            host.AssertValue(ini);
            host.AssertValueOrNull(calibrator);

            if (calibrator == null)
            {
                return(ini);
            }

            if (calibrator is PlattCalibrator)
            {
                string calibratorEvaluatorIni = IniFileUtils.GetCalibratorEvaluatorIni(ini, calibrator as PlattCalibrator);
                return(IniFileUtils.AddEvaluator(ini, calibratorEvaluatorIni));
            }
            else
            {
                StringBuilder newSection = new StringBuilder();
                newSection.AppendLine();
                newSection.AppendLine();
                newSection.AppendLine("[TLCCalibration]");
                newSection.AppendLine("Type=" + calibrator.GetType().Name);
                return(ini + newSection);
            }
        }
        public void SetCalibrator(ICalibrator aCalibrator)
        {
            if (aCalibrator == null) {
                throw new ArgumentNullException("aCalibrator");
            }

            calibrator = aCalibrator;
        }
示例#5
0
        /// <summary>
        /// Set up a parser gor th images
        /// Parsing all the data
        /// </summary>
        /// <param name="provider">Provider of the Camera images</param>
        /// <param name="visualizer">The Output to write on</param>
        public QuadrilateralDataParser(IPictureProvider provider, IVisualizerControl visualizer)
        {
            // Initialize Calibration Tools
            _calibrator = new SimpleAForgeCalibrator(provider, visualizer);
            _calibrator.CalibrationCompleted += StartTracking; // begin pen tracking after calibration immediately

            _provider = provider;
        }
示例#6
0
        private async Task CalibrateAsync(ICalibrator calibrator)
        {
            var execution = calibrator as IEyeTrackerCalibrationExecution;

            var result = SessionStepResult.Failed;

            using (var cancellation = new CancellationDisposable())
            {
                _cancellation = cancellation;

                try
                {
                    execution.CalibrationFinished += Execution_CalibrationFinished;

                    await AsyncHelper.InvokeAsync <CalibratorStateChangedEventHandler, bool>
                    (
                        () => { },
                        h => calibrator.StateChanged += h,
                        h => calibrator.StateChanged -= h,
                        tcs => (c, state) =>
                    {
                        switch (state)
                        {
                        case CalibratorState.Canceled:
                            tcs.TrySetResult(false);
                            break;

                        case CalibratorState.Completed:
                            tcs.TrySetResult(true);
                            break;
                        }
                    },
                        cancellation.Token
                    );

                    // create result with calibrations
                    result = new EyeTrackerCalibrationSessionStepResult(_calibrations);
                }
                catch (OperationCanceledException)
                {
                    await calibrator.CancelAsync();
                }
                finally
                {
                    //remove handler from execution
                    if (execution != null)
                    {
                        execution.CalibrationFinished -= Execution_CalibrationFinished;
                    }
                }

                Navigation.Clear();

                _cancellation = null;
            }

            OnCompleted(result);
        }
 public bool IsCalibratorValid(ICalibrator calibrator)
 {
     if (calibrator is EyeTrackerCalibrator)
     {
         // TODO check if the calibrator uses the same tracker.
         return(calibrator.State == CalibratorState.None);
     }
     return(false);
 }
示例#8
0
 public CalibrationHelper()
 {
     speedUnit               = PreferencesManager.PlayerPreferences.SpeedUnit;
     accelerationUnit        = PreferencesManager.PlayerPreferences.AccelerationUnit;
     angleUnit               = PreferencesManager.PlayerPreferences.AngleUnit;
     angularVelocityUnit     = PreferencesManager.PlayerPreferences.AngularVelocityUnit;
     angularAccelerationUnit = PreferencesManager.PlayerPreferences.AngularAccelerationUnit;
     calibrator              = calibrationLine;
 }
示例#9
0
        public override void SaveAsIni(TextWriter writer, RoleMappedSchema schema, ICalibrator calibrator = null)
        {
            Host.CheckValue(writer, nameof(writer));
            Host.CheckValue(schema, nameof(schema));
            Host.CheckValueOrNull(calibrator);

            var weights = Weight;

            writer.Write(LinearPredictorUtils.LinearModelAsIni(ref weights, Bias, this,
                                                               schema, calibrator as PlattCalibrator));
        }
        public void ReadXml(XmlReader r, PointF scale, Size imageSize)
        {
            r.ReadStartElement();

            while (r.NodeType == XmlNodeType.Element)
            {
                switch (r.Name)
                {
                case "CalibrationPlane":
                    calibratorType = CalibratorType.Plane;
                    calibrator     = calibrationPlane;
                    calibrationPlane.ReadPlaneXml(r, scale);
                    ComputeCoordinateSystemGrid();
                    break;

                case "CalibrationLine":
                    calibratorType = CalibratorType.Line;
                    //calibrator = calibrationLine;
                    calibrator = calibrationPlane;
                    calibrationPlane.ReadLineXml(r, scale);
                    //calibrationLine.ReadXml(r, scale);
                    break;

                case "CalibrationDrawingId":
                    Guid result;
                    bool parsed = Guid.TryParse(r.ReadElementContentAsString(), out result);
                    if (parsed)
                    {
                        calibrationDrawingId = result;
                    }
                    break;

                case "Unit":
                    lengthUnit = (LengthUnit)Enum.Parse(typeof(LengthUnit), r.ReadElementContentAsString());
                    break;

                case "CameraCalibration":
                    DistortionParameters parameters = DistortionSerializer.Deserialize(r, imageSize);
                    distortionHelper.Initialize(parameters, imageSize);
                    break;

                default:
                    string unparsed = r.ReadOuterXml();
                    log.DebugFormat("Unparsed content in KVA XML: {0}", unparsed);
                    break;
                }
            }

            r.ReadEndElement();

            AfterCalibrationChanged();
        }
示例#11
0
        /// <summary>
        /// Set up a parser gor th images
        /// Parsing all the data
        /// </summary>
        /// <param name="provider">Provider of the Camera images</param>
        /// <param name="visualizer">The Output to write on</param>
        public DataParser(IPictureProvider provider, IVisualizerControl visualizer)
        {
            // Initialize Calibration Tools
            _calibrator = new SimpleAForgeCalibrator(provider, visualizer);
            _calibrator.CalibrationCompleted += StartTracking; // begin pen tracking after calibration immediately

            // Initialize Pen Tracking Tools
            _penTracker             = new AForgePenTracker(new WhiteLedStrategy(), provider);
            _penTracker.PenFound   += PenFound;
            _penTracker.NoPenFound += NoPenFound;

            _mapperType = typeof(BarycentricIntegralPointMapper);
        }
示例#12
0
        public static string TreeEnsembleToIni(
            IHost host, TreeEnsemble ensemble, RoleMappedSchema schema, ICalibrator calibrator,
            string trainingParams, bool appendFeatureGain, bool includeZeroGainFeatures)
        {
            host.CheckValue(ensemble, nameof(ensemble));
            host.CheckValue(schema, nameof(schema));

            string ensembleIni = ensemble.ToTreeEnsembleIni(new FeaturesToContentMap(schema),
                                                            trainingParams, appendFeatureGain, includeZeroGainFeatures);

            ensembleIni = AddCalibrationToIni(host, ensembleIni, calibrator);
            return(ensembleIni);
        }
示例#13
0
        /// <summary>
        /// Output the INI model to a given writer
        /// </summary>
        public override void SaveAsIni(TextWriter writer, RoleMappedSchema schema, ICalibrator calibrator)
        {
            if (calibrator != null)
            {
                throw Host.ExceptNotImpl("Saving calibrators is not implemented yet.");
            }

            Host.CheckValue(writer, nameof(writer));
            Host.CheckValue(schema, nameof(schema));

            // REVIEW: For Poisson should encode the exp operation in the ini as well, bug 2433.
            var weights = Weight;

            writer.Write(LinearPredictorUtils.LinearModelAsIni(ref weights, Bias, this, schema, null));
        }
示例#14
0
        public void Reset()
        {
            SetOrigin(imageSize.Center());
            calibratorType  = CalibratorType.Line;
            calibrationLine = new CalibrationLine();
            calibrator      = calibrationLine;

            distortionHelper = new DistortionHelper();

            lengthUnit       = LengthUnit.Pixels;
            speedUnit        = SpeedUnit.PixelsPerSecond;
            accelerationUnit = AccelerationUnit.PixelsPerSecondSquared;

            ComputeCoordinateSystemGrid();
        }
示例#15
0
        /// <summary>
        /// Initialize the Parser with a non-standart calibrator or tracker
        /// </summary>
        /// <param name="calibrator">Custom calibrator</param>
        /// <param name="tracker">Custom PenTracker</param>
        public DataParser(ICalibrator calibrator, IPenTracker tracker, Type mapperType)
        {
            if (!(typeof(AbstractPointMapper).IsAssignableFrom(mapperType)))
            {
                throw new ArgumentException(mapperType.FullName + " doesn't inherit form AbstractPointMapper");
            }
            // Initialize Calibration Tools
            _calibrator = calibrator;
            _calibrator.CalibrationCompleted += StartTracking; // begin pen tracking after calibration immediately

            // Initialize Pen Tracking Tools
            _penTracker             = tracker;
            _penTracker.PenFound   += PenFound;
            _penTracker.NoPenFound += NoPenFound;

            _mapperType = mapperType;
        }
示例#16
0
        public void Reset()
        {
            calibratorType   = CalibratorType.Line;
            calibrationPlane = new CalibrationPlane();

            PointF center = imageSize.Center();

            calibrationPlane.Initialize(100, center, new PointF(center.X + 100, center.Y), CalibrationAxis.LineHorizontal);

            calibrator = calibrationPlane;

            distortionHelper = new DistortionHelper();

            lengthUnit = LengthUnit.Pixels;

            ComputeCoordinateSystemGrid();
        }
示例#17
0
        public void SetCalibratorFromType(CalibratorType type)
        {
            // Used by calibration dialogs to force a calibration method for further computations.
            // Each time the user calibrates, we switch to the method he just used.
            calibratorType = type;

            switch (type)
            {
            case CalibratorType.Line:
                calibrator = calibrationLine;
                break;

            case CalibratorType.Plane:
                calibrator = calibrationPlane;
                break;
            }
        }
        public void Reset()
        {
            calibratorType   = CalibratorType.Line;
            calibrationPlane = new CalibrationPlane();

            PointF center = imageSize.Center();

            calibrationPlane.Initialize(100, center, new PointF(center.X + 100, center.Y));

            //SetOrigin(imageSize.Center());
            calibrator = calibrationPlane;

            distortionHelper = new DistortionHelper();

            lengthUnit       = LengthUnit.Pixels;
            speedUnit        = SpeedUnit.PixelsPerSecond;
            accelerationUnit = AccelerationUnit.PixelsPerSecondSquared;

            ComputeCoordinateSystemGrid();
        }
示例#19
0
        /// <summary>
        /// Inspired by coroutines from Unity3D
        /// </summary>
        /// <param name="calibrator"></param>
        /// <param name="container"></param>
        /// <returns></returns>
        public static IEnumerator <ResolutionStepResult> InstantiationCoroutine(ICalibrator calibrator, object activationScope, IDIContainer container)
        {
            return(Helpers.Coroutine(instantiate));

            void instantiate()
            {
                var widget = new DeviceCalibration()
                {
                    Model = new DeviceCalibrationVM(calibrator,
                                                    container.ResolveSingle <IDeviceInitializationVM>(),
                                                    container.ResolveSingle <BusyObject>()),
                    FunctionId = new WidgetIdentity(calibrator.Model.CalibrationName,
                                                    container.ResolveSingle <string>(),
                                                    activationScope)
                };

                widget.View.Visibility = Visibility.Collapsed;

                container.Register <IWidget>(widget);
                container.Register <IDataProvider>(calibrator.Model.DataProvider);
            }
        }
示例#20
0
        protected override void DoInitialize()
        {
            logger.Info("Инициализация...");
            var appPath = Application.StartupPath + "/";
            dimentionConfiguration = new NHibernateDimentionConfigurationImpl();
            dataProviderConfiguration = new XmlDataProviderConfigurationImpl(appPath + "Settings/OpcConfiguration.xml");
            sensorConfiguration = new XmlSensorConfigurationImpl(appPath + "Settings/SensorConfiguration.xml");

            dataProvider = new OpcDataProviderImpl();
            calibrator = new CalibratorImpl();
            //dataProvider = new EmulatorDataProvider();
            //calibrator = dataProvider as ICalibrator;

            slabBuilder = new SlabBuilderImpl();
            dimentionCalculator = new DimentionCalculatorImpl();
            sensorValueContainer = new SensorValueContainerImpl();
            dimentionValueContainer = new DimentionValueContainerImpl();
            standartSizeReaderWriter = new NHibernateStandartSizeReaderWriter();
            regulationsReaderWriter = new NHibernateRegulationReaderWriter();

            sensorValueReaderWriter = new NHibernateSensorValueWriter();
            dimentionValueWriter = new NHibernateDimentionValueWriter();
            slabWriter = new NHibernateSlabInfoWriter();
            slabReader = slabWriter as ISlabInfoReader;

            //dataCleaner = new NHibernateDataCleanerImpl();
            //dataCleaner.SetSlabInfoWriter(slabWriter);

            sensorValueContainer.SunbscribeContainerListener(this);

            dataProvider.SetSensorConfiguration(sensorConfiguration);
            dataProvider.SetSensorValueContainer(sensorValueContainer);
            dataProvider.SetDataProviderConfiguration(dataProviderConfiguration);
            dataProvider.SubscribeDataProviderListener(this);

            slabBuilder.SetCalibrator(calibrator);
            slabBuilder.SetSensorConfiguration(sensorConfiguration);
            slabBuilder.SetSensorValueContainer(sensorValueContainer);

            dimentionCalculator.SetDimentionConfiguration(dimentionConfiguration);
            dimentionCalculator.SetDimentionValueContainer(dimentionValueContainer);

            // Для построения точек при запросе пользователя.
            userSensorValueContainer = new SensorValueContainerImpl();
            userSlabBuilder = new SlabBuilderImpl();
            userSlabBuilder.SetSensorValueContainer(userSensorValueContainer);
            userSlabBuilder.SetSensorConfiguration(sensorConfiguration);
            userSlabBuilder.SetCalibrator(calibrator);

            dimentionConfiguration.Initialize();
            standartSizeReaderWriter.Initialize();
            regulationsReaderWriter.Initialize();
            dataProviderConfiguration.Initialize();
            sensorConfiguration.Initialize();
            sensorValueReaderWriter.Initialize();
            slabWriter.Initialize();
            dimentionValueWriter.Initialize();
            dimentionCalculator.Initialize();
            calibrator.Initialize();
            slabBuilder.Initialize();
            userSlabBuilder.Initialize();
            //dataCleaner.Initialize();
            dataProvider.Initialize();

            logger.Info("Инициализация завершена.");
        }
示例#21
0
 public CalibrationHelper()
 {
     RefreshUnits();
     calibrator = calibrationPlane;
 }
示例#22
0
 public bool IsCalibratorValid(ICalibrator calibrator) => false;
示例#23
0
        static IEnumerator <ResolutionStepResult> injectCalibrationWidgets(IDIContainer container, ICalibrator calibrator)
        {
            //Skip(1) because the first item is calibration widget itself
            foreach (var calibrationDataWidget in calibrator.Widgets.Skip(1))
            {
                container.Register <IWidget>(calibrationDataWidget);
            }

            yield return(ResolutionStepResult.RESOLVED);
        }
示例#24
0
 public abstract void SaveAsIni(TextWriter writer, RoleMappedSchema schema, ICalibrator calibrator = null);
示例#25
0
 internal static HandleRef getCPtr(ICalibrator obj)
 {
     return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
示例#26
0
 public CalibratedPredictor(IPredictorWithFeatureWeights <double> predictor, ICalibrator calibrator)
 {
     SubPredictor = predictor;
     Calibrator   = calibrator;
 }
示例#27
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ICalibrator obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }