TypeError: list indices must be integers or slices, not tuple error while image processing
TypeError: list indices must be integers or slices, not tuple error while image processing
索尼克= Kesilmis_Kare.copy()
cnts,层次结构 = cv2.findContours(Renk_Fılte_Sonucu,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
Max_Genislik=0
Max_Uzunluk=0
Max_Index=-1
for t in range(len(cnts)):
cnt=cnts[t]
x,y,w,h= cv2.boundingRect(cnt)
if(w>Max_Genislik and h>Max_Uzunluk):
Max_Uzunluk= h
Max_Genislik= w
Max_Index= t,
if(len(cnts)>0):
x,y,w,h= cv2.boundingRect(cnts[Max_Index])
cv2.rectangle(Sonuc,(x,y),(x+w,y+h), (0,255,0),2)
我拍了
x,y,w,h= cv2.boundingRect(cnts[Max_Index])
类型错误:列表索引必须是整数或切片,而不是元组
这个错误你能帮我吗
Max_Index= t,
这一行将 Max_Index
变成一个元组。
x,y,w,h= cv2.boundingRect(cnts[Max_Index])
在这一行中,您使用 Max_Index
作为列表索引,但如错误消息所述,它只能是整数,因此您应该使用另一个变量。
索尼克= Kesilmis_Kare.copy() cnts,层次结构 = cv2.findContours(Renk_Fılte_Sonucu,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)
Max_Genislik=0
Max_Uzunluk=0
Max_Index=-1
for t in range(len(cnts)):
cnt=cnts[t]
x,y,w,h= cv2.boundingRect(cnt)
if(w>Max_Genislik and h>Max_Uzunluk):
Max_Uzunluk= h
Max_Genislik= w
Max_Index= t,
if(len(cnts)>0):
x,y,w,h= cv2.boundingRect(cnts[Max_Index])
cv2.rectangle(Sonuc,(x,y),(x+w,y+h), (0,255,0),2)
我拍了
x,y,w,h= cv2.boundingRect(cnts[Max_Index])
类型错误:列表索引必须是整数或切片,而不是元组
这个错误你能帮我吗
Max_Index= t,
这一行将 Max_Index
变成一个元组。
x,y,w,h= cv2.boundingRect(cnts[Max_Index])
在这一行中,您使用 Max_Index
作为列表索引,但如错误消息所述,它只能是整数,因此您应该使用另一个变量。