Esempio n. 1
0
 internal static void DrawStats(
     TimeSpan elapsedTime,
     SKCanvas canvas,
     float height,
     DetectionMessage detectionMessage)
 {
     canvas.DrawText(
         $"{elapsedTime.TotalMilliseconds.ToString("#")} ms - {detectionMessage.Score} - " +
         $"{detectionMessage.Label}",
         elapsedTimeMargin,
         height - (elapsedTimeHeight / 2) - elapsedTimeMargin,
         elapsedTimePaint);
 }
Esempio n. 2
0
        private void UpdateBoundingBoxState(BoundingBoxState newState, DetectionMessage newBoundingBox = null)
        {
            switch (newState)
            {
            case BoundingBoxState.Initial:
                throw new InvalidOperationException(
                          $"{nameof(BoundingBoxState.Initial)} state can be set just at the beginning.");

            case BoundingBoxState.Missing:
                canvasView.InvalidateSurface();
                boundingBox = DetectionMessage.FullScreen;
                break;

            case BoundingBoxState.Framing:
                DisposeFadeOutTimer();

                elapsedTimeSinceLastDetection = DateTime.UtcNow - lastDetectionDate;
                lastDetectionDate             = DateTime.UtcNow;

                previousBoundingBox = boundingBox;
                boundingBox         = newBoundingBox;

                if (!this.AnimationIsRunning(nameof(framingAnimation)))
                {
                    framingAnimation.Commit(
                        this,
                        nameof(framingAnimation),
                        length: AnimationLengthMilliseconds,
                        finished: (_, __) => InitializeFadeOutTimer());
                }

                break;

            case BoundingBoxState.Disappearing:
                break;

            default:
                throw new InvalidOperationException();
            }

            currentBoundingBoxState = newState;
        }