Ejemplo n.º 1
0
        public async Task<WriteableBitmap> GetImage(MappedFrame frame)
        {
            var key = $"{frame.Camera}:{frame.Frame}";

            if (!_images.ContainsKey(key))
            {
                var camera = _camers[frame.Camera];
                _images[key] = await (await ImageLoader.Create(camera)).GetImage(frame);
            }

            return _images[key];
        }
Ejemplo n.º 2
0
        public bool AddPoint(Point currentPoint)
        {
            var result = false;

            if (PreviousFrame == null)
            {
                PreviousFrame = new MappedFrame
                {
                    Point = currentPoint
                };

                result = true;
            }
            else
            {
                var x1 = PreviousFrame.Point.X;
                var y1 = PreviousFrame.Point.Y;
                var x2 = currentPoint.X;
                var y2 = currentPoint.Y;

                var frame = (int) ((x2*frameCount)/width) + 2;
                var camera = (int) ((y2*cameraCount)/height);
                var distance = PreviousFrame.Point.GetDistance(currentPoint);

                if (frame != PreviousFrame.Frame || camera != PreviousFrame.Camera)
                {
                    var mappedFrame = new MappedFrame
                    {
                        Speed = distance/(DateTime.UtcNow - PreviousFrame.MappedTime).TotalSeconds,
                        ViewTime = (DateTime.UtcNow - PreviousFrame.MappedTime).TotalMilliseconds,
                        Point = currentPoint,
                        Camera = camera,
                        Frame = frame
                    };

                    PreviousFrame = mappedFrame;
                    frames.Add(mappedFrame);
                    result = true;
                }
            }

            return result;
        }