【发布时间】:2021-05-12 08:48:02
【问题描述】:
这是我的 python 脚本: -def detect_corner(binary_map, intersections):
field_separation = np.copy(binary_map)
cv2.line(field_separation, (intersections[0][0],intersections[0][1]), (intersections[1][0],intersections[1][1]),0, 4)
contours = cv2.findContours(field_separation,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)[1]
print(contours)
#Find the greatest area contour
areas = []
for contour in contours:
areas.append(cv2.contourArea(contour))
max_index = np.argmax(areas)
max_area = areas.pop(max_index)
remaining_area = sum(areas)
return (remaining_area/max_area)
此代码在另一个系统上正常运行,但当我在我的系统中运行它时,它显示以下错误:
'cv2.error: OpenCV(4.0.0) /io/opencv/modules/imgproc/src/shapeescr.cpp:272: error: (-215:Assertion failed) npoints >= 0 && (depth == CV_32F || depth == CV_32S) 在函数'contourArea''中
你能帮帮我吗?
【问题讨论】: