Found in the code can actually use Chinese as a variable name and function name, good.
#-*-Coding=utf-8-*-
import cv2
import random
import NumPy as np
wide =
high =
def Get location ():
return Random.randint (30, High -30), Random.randint (30, Width -30)
def getrandfloat (): Return
random.uniform (0, wide)
# Create black image
img = Np.zeros ((High, wide, 3), np.uint8)
# Draw a 5-pixel Blue line
cv2.line (IMG, get location (), get Location (), (255,0,0) , 5
Cv2.rectangle (IMG, get location (), get Location (), (0,255,0), 3)
cv2.circle (IMG, get Location (), (0,0,255),-1)
Cv2.ellipse (IMG, get Location (), (100,50), 0,0,180,255,-1)
# Draw polygon
pts = Np.array ([[10,5],[20,30],[70,20],[50,10]] , np.int32)
pts = Pts.reshape (( -1,1,2))
Cv2.polylines (Img,[pts],true, (0,255,255))
# display text
font = Cv2. Font_hershey_simplex
cv2.puttext (img, ' num: ' +str (Getrandfloat ()), (10,30), font,0.8, (255,255,255), 2,cv2. LINE_AA)
cv2.imshow (' Test ', img)
cv2.waitkey ( -1)
cv2.destroyallwindows ()
Show Results: