import os

import cv2

from danila.danila_v1 import Danila_v1
from danila.danila_v2 import Danila_v2
from danila.danila_v3 import Danila_v3
from danila.danila_v4 import Danila_v4

"""main module for user"""


class Danila:
    """main class for user"""
    def __init__(self, version, yolov5_dir):
        if (version == 1):
            self.danila = Danila_v1(yolov5_dir)
        elif (version == 2):
            self.danila = Danila_v2(yolov5_dir)
        elif (version == 3):
            self.danila = Danila_v3(yolov5_dir)
        else:
            self.danila = Danila_v4(yolov5_dir)
    # returns string - class of rama using CNN network
    # img - openCV frame

    def rama_classify(self, img, size = 256):
        """rama_classify(Img : openCv frame): String - returns class of rama using CNN network"""
        """rama_classify uses Rama_classify_class method - classify(Img)"""
        return self.danila.rama_classify(img, size)

    # returns openCV frame with rama from openCV frame\
    def rama_detect(self, img, size = 256):
        """rama_detect(img : openCV img) -> openCV image with drawn rama rectangle"""
        return self.danila.rama_detect(img, size)

    # returns openCV image with cut_rama
    def rama_cut(self, img, size = 256):
        """rama_cut(img : openCV img) -> openCV image of rama rectangle"""
        return self.danila.rama_cut(img, size)

    #
    # returns openCV cut rama with drawn text areas
    def text_detect_cut(self, img, size = 256):
        """returns openCV cut rama with drawn text areas"""
        return self.danila.text_detect_cut(img, size)

    # returns openCV img with drawn text areas
    def text_detect(self, img, size = 256):
        """returns openCV img with drawn text areas"""
        return self.danila.text_detect(img, size)
    # returns dict {'number', 'prod', 'year'} for openCV rama img or 'no_rama'
    def text_recognize(self, img, size = 256):
        """returns dict {'number', 'prod', 'year'} for openCV rama img or 'no_rama'"""
        return self.danila.text_recognize(img, size)
