contours, hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)出现错误:
ValueError: too many values to unpack (expected 2)contours, hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
ValueError: too many values to unpack (expected 2)
出现错误原因:如果用的是cv 4.0版本,findContours返回的是两个参数,旧版的返回的则是三个参数,而如果出现这个错误说明你使用的是旧版本,所以需要改为:
image, contours, hierarchy = cv2.findContours(thresh.copy(),cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
再运行就对了