In [2]:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
%matplotlib inline
%config InlineBackend.figure_format = 'retina'

img = np.zeros((512,512,3), np.uint8)
img = cv2.line(img,(0,0),(250,511),(255,0,0),5)
img = cv2.rectangle(img,(384,10),(500,250),(0,255,0),5)
img = cv2.circle(img, (100,200), 25, (0,0,255), -1)
img = cv2.ellipse(img,(256,256),(100,50),0,10,270,255,-1)

pts = np.array([[100,50],[200,300],[350,200],[250,100]], np.int32)
# pts = pts.reshape((-1,1,2))
img = cv2.polylines(img,[pts],True,(0,255,255),3)


font = cv2.FONT_HERSHEY_SIMPLEX
img = cv2.putText(img,'OpenCV',(10,500), font, 4,(255,255,255),2,cv2.LINE_AA)

plt.imshow(img)  #call as plt.imshow(gray, cmap='gray') to show a grayscaled image


Out[2]:
<matplotlib.image.AxesImage at 0x7f50f60b7ac8>

In [3]:
pts


Out[3]:
array([[100,  50],
       [200, 300],
       [350, 200],
       [250, 100]], dtype=int32)

In [ ]: