class vide(object):
def video(self,img):
img1 = np.asarray(img, dtype='float64')
print("陣列的維度", img1.shape)
print(img1)
img3 = img1.astype(np.uint8)
print(img3.dtype.name)
img2 = Image.fromarray(np.uint8(img3))
gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
ret,thresh = cv2.threshold(gray, 130, 255, 0)
thresh.show()
#賦值操作:自定義名 = 類名(屬性1,屬性2)
#self.name = 類名(name,type) #注意不需要self
#self.name.定義的類名()
img1 = cv2.imread("img\\3.jpg")
www = vide()
www.video(img1)
File "C:/Users/ZTL/Desktop/pycharm/jia.py", line 111, in video
gray = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
TypeError: Expected Ptr<cv::UMat> for argument '%s'
請問怎么解決上述錯誤
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/22183.html
標籤:單片機/工控
上一篇:485總線上存在傳感器讀數不準確
