Edmond Yoo
2018-08-28 f176d3da3d4dd7a337187739cf9446417b523156
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
 
 
class ImageGenerator:
    """
    A template for generating a training image.
    """
    def __init__(self, img_bg, cards):
        """
        :param img_bg: background (textile) image
        :param cards: list of Card objects
        """
        self._img_bg = img_bg
        self._cards = cards
        self._img_result = None
        pass
 
    def generate_horizontal_span(self):
        """
        Generating the first scenario where the cards are laid out in a straight horizontal line
        :return: none
        """
        pass
 
    def generate_vertical_span(self):
        """
        Generating the second scenario where the cards are laid out in a straight vertical line
        :return: none
        """
        pass
 
    def generate_fan_out(self):
        """
        Generating the third scenario where the cards are laid out in a fan shape
        :return: none
        """
        pass
 
    def export_training_data(self, out_dir):
        """
        Export the generated training image along with the txt file for all bounding boxes
        :return: none
        """
        pass
 
 
class Card:
    """
    A class for storing required information about a card in relation to the ImageGenerator
    """
    def __init__(self, img, card_info, objects, generator=None, x=None, y=None, theta=None):
        """
        :param img: image of the card
        :param card_info: details like name, mana cost, type, set, etc
        :param objects: list of ExtractedObjects like mana & set symbol, etc
        :param generator: ImageGenerator object that the card is bound to
        :param x: X-coordinate of the card's centre in relation to the generator
        :param y: Y-coordinate of the card's centre in relation to the generator
        :param theta: angle of rotation of the card in relation to the generator
        """
        self._img = img
        self._info = card_info
        self._objects = objects
        self._x = x
        self._y = y
        self._theta = theta
        pass
 
    def bind_to_generator(self, generator, x=0, y=0, theta=0):
        """
        Bind this card to an ImageGenerator object.
        :param generator: generator to be bound with
        :param x: new X-coordinate for the centre of the card
        :param y: new Y-coordinate for the centre of the card
        :param theta: new angle for the card
        :return: none
        """
        pass
 
    def shift(self, x=None, y=None):
        """
        Apply a X/Y translation on this image
        :param x: amount of X-translation. If range is given, translate by a random amount within that range
        :param y: amount of Y-translation. Refer to x when a range is given.
        :return: none
        """
        pass
 
    def rotate(self, centre, theta=None):
        """
        Apply a rotation on this image with a centre
        :param centre: coordinate of the centre of the rotation in relation to the centre of this card (self._x, self._y)
        :param theta: amount of rotation in radian. If a range is given, rotate by a random amount within that range
        :return: none
        """
        pass
 
 
class ExtractedObject:
    """
    Simple struct to hold information about an extracted object
    """
    def __init__(self, label, key_pts):
        self._label = label
        self._key_pts = key_pts
 
 
def main():
    pass
 
 
if __name__ == '__main__':
    main()