如何在 opencv 3 中运行 CV_DIST_L2?

Abh*_*t n 4 python edge-detection opencv3.0

代码:检测对象中的 Opencv 线-> Amid 响应

情况1:

for xxx in contours:
   [vx,vy,x,y] = cv2.fitLine(xxx,cv2.cv.CV_DIST_L2,0,0.01,0.01)
Run Code Online (Sandbox Code Playgroud)

它抛出错误 -

AttributeError:模块“cv2”没有属性“cv”

案例2:

for xxx in contours:
   [vx,vy,x,y] = cv2.fitLine(xxx,cv2.CV_DIST_L2,0,0.01,0.01)
Run Code Online (Sandbox Code Playgroud)

它抛出错误 -

属性错误:模块“cv2”没有属性“CV_DIST_L2”

我已经opencv 3安装在我的机器上。我无法调试此错误。请让我知道我犯了什么错误?

小智 5

只需尝试没有 CV 的 DIST_L2 就可以了