我尝试使用OpenCV和python检索图像的矩形部分(文档、护照照片或类似的东西)。它可以工作,但不是对每个图像都有效,并在以下代码块中失败,错误为axis = normalize_axis_index(axis, nd)
numpy.core._internal.AxisError: axis 1 is out of bounds for array of dimension 1
:
for cnt in contours:
perimeter = cv2.arcLength(cnt, True)
approx = cv2.approxPolyDP(cnt, 0.03 * perimeter, True)
if (len(approx) == 4 and
cv2.isContourConvex(approx) and
maxAreaFound < cv2.contourArea(approx) < MAX_COUNTOUR_AREA):
maxAreaFound = cv2.contourArea(approx)
pageContour = approx
完整代码:
^{pr2}$为什么会这样?在
或者只是在图像中保存。。在
相关问题 更多 >
编程相关推荐