using System;
using BallotTemplates;
using InterpreterLibrary.Models;
using InterpreterLibrary.Models.Transform;
using OpenCvSharp;

namespace InterpreterLibrary.Processing
{
    public class BallotPreprocessorOutput : IDisposable
    {
        private Func<bool> _dirtLineChecker = () => false;
        public Mat FrontImage { get; internal set; }
        public Mat BackImage { get; internal set; }
        public BallotTemplate Template { get; internal set; }
        public BallotType Type => Template == null ? BallotType.Ukjent : (BallotType)int.Parse(Template.TypeId);
        public float TypeConfidence { get; internal set; }

        internal Func<bool> GetDirtLineChecker()
        {
            return _dirtLineChecker;
        }
        internal void SetDirtLineChecker(Func<bool> function)
        {
            _dirtLineChecker = function;
        }
        public bool HasDirtLines => _dirtLineChecker();

        public IPointTransformer FrontTransform { get; internal set; }
        public IPointTransformer BackTransform { get; internal set; }

        public bool IsReverseOrder  { get; internal set; }
        public int FrontRotationDegrees { get; internal set; }
        public int BackRotationDegrees { get; internal set; }

        public void Dispose()
        {
            FrontImage?.Dispose();
            BackImage?.Dispose();
        }
    }
}
