【问题标题】:IndexError: too many indices for array in python (still error occur)IndexError:python中数组的索引过多(仍然出现错误)
【发布时间】:2021-02-23 16:21:14
【问题描述】:
    # -*- 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)

出现以下错误:

厚度 = int(pointsarray[1,0]) - int(pointsarray[0,0]) IndexError: 数组索引过多

【问题讨论】:

    标签: python image


    【解决方案1】:

    如果你有二维数组试试这个:

    thickness = int(pointsarray[1][0]) - int(pointsarray[0][0])
    

    list对象需要单独访问,也可以使用numpy数组

    【讨论】:

      猜你喜欢
      • 2014-02-06
      • 1970-01-01
      • 2021-07-20
      • 1970-01-01
      • 1970-01-01
      • 2016-01-01
      • 2015-09-09
      • 2016-11-15
      • 2011-04-11
      相关资源
      最近更新 更多