运行我的代码后,我收到错误消息轮廓元组必须具有长度2或3,否则opencv再次更改了它们的返回签名。我目前运行的是 opencv 3.4.3.18 版本。当我抓取运行 imutils ver 0.5.2 的轮廓时,会出现此问题
该代码查找计数并返回在进行一些边缘检测后找到的轮廓。然后该算法使用 imutils 来抓取轮廓。这是正确的处理方法还是有一些最新的方法来获取轮廓而不是使用 imutils?
请看下面的例子:
image, contours, hier = cv.findContours(edged.copy(), cv.RETR_EXTERNAL, cv.CHAIN_APPROX_SIMPLE)
cnts = imutils.grab_contours(contours)
cnts = sorted(contours, key = cv.contourArea, reverse = True)[:5]
Run Code Online (Sandbox Code Playgroud)