using System.Collections.Generic;
using InterpreterLibrary.Processing;
using OpenCvSharp;

namespace InterpreterLibrary.Models
{
    public class ImagePairPermutations
    {
        private readonly Dictionary<int, (Mat First, Mat Second)> _dictionary = new Dictionary<int, (Mat First, Mat Second)>();
        private readonly Mat _image1, _image2;
        public readonly (Mat First, Mat Second) Original;

        public ImagePairPermutations(Mat image1, Mat image2)
        {
            _image1 = image1;
            _image2 = image2;
            Original = (image1, image2);
            _dictionary.Add(0, Original);
        }

        internal (Mat First, Mat Second) Get(int rotations)
        {
            var actualRotations = rotations % 4;
            if (!_dictionary.ContainsKey(actualRotations))
            {
                _dictionary.Add(actualRotations, (_image1.Rotate(actualRotations), _image2.Rotate(actualRotations)));
            }
            return _dictionary[actualRotations];
        }
    }
}

