为什么即使我确定间距,也会出现这种缩进错误?

2024-09-24 02:27:09 发布

您现在位置:Python中文网/ 问答频道 /正文


cnts = cv2.findContours(thresh.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE) 
cnts = imutils.grab_contours(cnts)

X = []
Y = []

for c1 in cnts:
    # compute the center of the contour
    M = cv2.moments(c1)
    cX = int(M["m10"] / M["m00"])
    cY = int(M["m01"] / M["m00"])
    cv2.drawContours(imCrop, [c1], -1, (0, 255, 0), 2)
    cv2.circle(imCrop, (cX, cY), 7, (255, 255, 255), -1)
    X.append(cX)
    Y.append(cY)

我一直得到以下错误,我没有线索。当我去掉需要存储的X.append(cX)和Y.append(cY)(记录多帧的所有质心坐标)时,它确实消失了。我已经检查了很多次间距/制表符问题,但实际上是这些list.append行导致了错误。有什么想法吗

    X.append(cX)
               ^
IndentationError: unindent does not match any outer indentation level

Tags: the错误cv2intcxcopyc1append