Пример #1
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);
        }
Пример #2
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;
        }
Пример #3
0
        /// <summary>
        /// Calibration is finished, starting PenTracker
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StartTracking(object sender, EventArgs e)
        {
            Console.WriteLine("Calibration completed");

            _qtc = new QuadrilateralTransformationCamera(CalibratorGrid.TopLeft, CalibratorGrid.TopRight,
                                                         CalibratorGrid.BottomLeft, CalibratorGrid.BottomRight, 4.0 / 3.0);
            _qtc.Height           = TransformHeight;
            _qtc.Width            = TransformWidth;
            _provider.FrameReady += ForwardImages;
#if DEBUG
            _qtc.FrameReady += StoreTransformedImage;
#endif
            // Initialize Pen Tracking Tools
            _penTracker           = new AForgePenTracker(new WhiteLedStrategy(), _qtc);
            _penTracker.PenFound += PenFound;
            _penTracker.Start();
            //_calibrator.Grid.PredictFromCorners();
        }