Draw Examples¶
[1]:
from easycv import Image
from easycv.transforms.draw import Draw
For this example we will load an image with random(). For more examples of image loading check Image examples.
[2]:
img = Image.random()
img
[2]:

Ellipse¶
To draw an ellipse apply the method Draw and select the method ellipse, for more information check reference.
[3]:
img.apply(Draw(method="ellipse",
ellipse=((200,100),100,60),
rotation_angle=20,
start_angle=0,
end_angle=300,
filled=False,
color=(100,200,200),
thickness=5))
[3]:

A closed ellipse can also be drawn passing filled as True
[4]:
img.apply(Draw(method="ellipse",
ellipse=((200,100),100,60),
rotation_angle=20,
start_angle=0,
end_angle=300,
filled=True,
color=(100,200,200),
thickness=5,))
[4]:

Line¶
To draw a line apply the method Draw and select the method line, for more information check reference.
[5]:
img.apply(Draw(method="line",
pt1=(30,20),
pt2=(200,150),
color=(0,200,0),
thickness=5))
[5]:

Polygon¶
To draw multiple lines or a polygon apply the method Draw and select the method polygon, for more information check reference.
Not closed and not Filled
[6]:
img.apply(Draw(method = "polygon",
points=[[50,50],[100,100],[50,100],[100,50]],
color=(250,0,0),
thickness=2,
closed=False,
filled=False))
[6]:

Closed and not Filled
[7]:
img.apply(Draw(method = "polygon",
points=[[50,50],[100,100],[50,100],[100,50]],
color=(0,0,250),
thickness=2,
closed=True,
filled=False))
[7]:

Closed and Filled
[8]:
img.apply(Draw(method = "polygon",
points=[[50,50],[100,100],[50,100],[100,50]],
color=(100,0,70),
thickness=2,
closed=False,
filled=True))
[8]:

Rectangle¶
To draw a rectangle apply the method Draw and select the method rectangle, for more information check reference.
Not Filled
[9]:
img.apply(Draw(method="rectangle", rectangle=((95,50),(350,250)),filled=True))
[9]:

Filled
[10]:
img.apply(Draw(method="rectangle", rectangle=((95,50),(350,250)),color=(50,100,200),filled=False))
[10]:

Text¶
To draw Text apply the method Draw and select the method Text, for more information check reference.
[11]:
img.apply(Draw(method = "text", text="easyCV", org=(1,200), font="SIMPLEX", size=4, color=(0,150,250),thickness=5))
[11]:

The text can be mirrored using x_mirror
[12]:
img.apply(Draw(method = "text", text="easyCV", org=(1,200), font="SIMPLEX", size=4, color=(0,150,250),thickness=5,x_mirror=True))
[12]:
