ValueError: not enough values to unpack (expected 3, got 2) using Contour in OpenCV

ValueError: not enough values to unpack (expected 3, got 2) using Contour in OpenCV

所以我在更新所有包后收到此错误。

    <ipython-input-48-e9a9716d4b8c> in extractText(path)
     15     plt.show()
     16 
---> 17     img, contours, hierarchy = cv2.findContours(edged, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)
     18     contours = sorted(contours, key=cv2.contourArea, reverse=True)
     19 

ValueError: not enough values to unpack (expected 3, got 2)

在openCV4中,cv2.findContours() returns 2个值contours, hierarchy,所以应该是:

contours, hierarchy = cv2.findContours(edged, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)