我在图像处理方面非常业余。我可以成功地进行正常的阈值处理,但是我在自适应阈值处理时遇到错误。 这是我的代码:
import cv2
import numpy as np
img = cv2.imread("vehicle004.jpg")
img = cv2.medianBlur(img,5)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
_,th2=cv2.adaptiveThreshold(gray,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,11,2)
cv2.imshow("window2",th2)
cv2.waitKey(0)
cv2.destroyAllWindows()
错误讯息:
line 7, in <module>
_,th2 = cv2.adaptiveThreshold(gray,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,11,2)
ValueError: too many values to unpack
感谢任何帮助。
答案 0 :(得分:1)
根据the documentation,import cv2
import numpy as np
img = cv2.imread("vehicle004.jpg")
img = cv2.medianBlur(img,5)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
th2=cv2.adaptiveThreshold(gray,255,cv2.ADAPTIVE_THRESH_MEAN_C,cv2.THRESH_BINARY,11,2)
cv2.imshow("window2",th2)
cv2.waitKey(0)
cv2.destroyAllWindows()
只返回1个值阈值图片,在这种情况下,您尝试从该方法接收2个值,即这就是为什么会出现Workbooks.Open("filepath.xlsx")
错误。
解决问题后,代码可能如下所示:
SQL Error: ORA-00933: SQL command not properly ended