浮點型數據需要轉化為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