python-3.x 如何修复“类型错误:“list”和“int”的示例之间不支持“〈“”?

gz5pxeao  于 2023-01-27  发布在  Python
关注(0)|答案(1)|浏览(153)

嗨,我只是需要一个代码的手程度在现场摄像头,在谷歌上有一些项目,但与头部.无论我改变代码返回我,这个错误:
TypeError:在"list"和"int"的示例之间不支持"〈"
下面是我的代码:
enter image description here

`contours, hierarchy = cv2.findContours(fg_mask_bb,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)[-2:]
    area = [cv2.contourArea(c) for c in contours]  
    
    if area < 3700 or 10000 < area :continue
    rect = cv2.minAreaRect(c)
    box = cv2.boxPoints(rect)
    box = np.int0(box)
    center = (int(rect[0][0]),int(rect[0][1])) 
    width = int(rect[1][0])
    height = int(rect[1][1])
    angle = int(rect[2])
    
    if width < height:
        angle = 90 - angle
    else:
        angle = -angle`
zzlelutf

zzlelutf1#

如果您想查看列表中的每一项是〉3700还是〈10000,可以这样做:

for n in area:
    if n < 3700 or n > 10000: continue

或者,确保这些条目甚至不在区域中结束:

area = [cv2.contourArea(c) for c in contours if cv2.contourArea(c) >= 3700 and cv2.contourArea(c) <= 10000]

相关问题