[英]IndexError: too many indices for array in python (still error occur)
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 22 15:09:13 2021
@author:
"""
import cv2
import numpy as np
import numpy
...
...
...
...
thickness = int(pointsarray[1,0]) - int(pointsarray[0,0]) #here is the error
print(thickness)
cv2.line(img, (cx, cy), (cx+50, cy), (0,0,255), 1)
cv2.putText(img, 'Thickness : '+str(thickness),(x-20, y-10), font, 0.4,(0,0,0),1,cv2.LINE_AA)
cv2.imshow('img', img)
The following error occurs:出现以下错误:
thickness = int(pointsarray[1,0]) - int(pointsarray[0,0]) IndexError: too many indices for array厚度 = int(pointsarray[1,0]) - int(pointsarray[0,0]) IndexError: 数组索引过多
if you have 2D array try this:如果你有二维数组试试这个:
thickness = int(pointsarray[1][0]) - int(pointsarray[0][0])
list object needs to be accessed separately, or you can use numpy arrays list object 需要单独访问,也可以使用 numpy arrays
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.