I am a BEGINNER of Python and I would really need some help.
I have a (working) script that retrieves simple shapes in images drawn by hand. The next step is to determine the spatial relations between the shapes and a data structure that contains all those information. I know how to determine the spatial relations between the shapes, like inside, next to, above and below. However, I need a data structure to contain all those information: shapes (x,y) coordinate of the edges and relation with other shapes. I was thinking about a hierarchical representation, something like this picture:
In which each shape contains the info.
Shape = (x0, y0, ..., xn, yn), position(Shape)
where
- (x0, y0, ..., xn, yn) are the coordinates of the edges of the shape
- position(Shape) is the relation of the shape against another.
For example:
S1: (x0, y0, x1, y1, x2, y2, x3, y3), below(T1)
T1: (x0, y0, x1, y1, x2, y2), above(S1)
C1: (radius), inside(S1), above(C2)
C2: (radius), inside(S1), below(C1)
But how to implement it in python? I read about dictionaries (here) but I am not sure if it's the right tool to use here. Why? Because I need to write in the data structure the position of a shape against others. So how could I write this relation? I am quite confused about the argument and I would really need an help.