浮点型数据需要转化为int,才能作为点,被读取abc = np.array(abc, dtype=np.int)

import cv2
import numpy as np
import matplotlib.pyplot as plt


img = 'test.jpg'
img = cv2.imread(img)
triangle = np.array([[0, 0], [1500, 800], [500, 400]])
abc = np.zeros((3, 2))
print(abc)
abc[0,0] = 23
abc[0,1] = 300
abc[1,0] = 200
abc[1,1] = 500
abc[2,0] = 233
abc[2,1] = 800
abc = np.array(abc, dtype=np.int)
print(type(triangle))
print(abc)
cv2.fillConvexPoly(img, triangle, (0, 0, 0))
cv2.fillConvexPoly(img, abc, (0, 0, 0))
plt.imshow(img)
plt.show()

 

posted on 2019-07-15 17:51  Hebye  阅读(816)  评论(0编辑  收藏  举报

导航