浮点型数据需要转化为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()

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM