My error is :
Point3D = np.vstack((Point3D, np.hstack((EMap[ID, 3:].reshape(-1, 2), np.zeros((4, 1))))))
IndexError: index 391 is out of bounds for axis 0 with size 4
This is the source code:
import numpy as np
import cv2
import cv2.aruco as aruco
np.set_printoptions(suppress=True, precision=4)
parameters = cv2.aruco.DetectorParameters_create()
dict = aruco.getPredefinedDictionary(aruco.DICT_4X4_1000)
EMap = np.loadtxt('EMap.txt')
def DealMarker(Img):
Corners, IDs, rejectedCandidates = aruco.detectMarkers(Img, dict, parameters=parameters)
if len(Corners) >= 4:
Point3D = np.empty((0, 3))
Point2D = np.empty((0, 2))
for i, Corner in enumerate(Corners):
Point2D = np.vstack((Point2D, Corner.reshape(-1, 2)))
ID = IDs.flatten()[i]
Point3D = np.vstack((Point3D, np.hstack((EMap[ID, 3:].reshape(-1, 2), np.zeros((4, 1))))))
return XXX
This is the content of the EMap.txt
0.00 0.00 0.00 -27.00 -27.00 27.00 -27.00 27.00 27.00 -27.00 27.00
1.00 87.00 0.00 60.00 -27.00 114.00 -27.00 114.00 27.00 60.00 27.00
2.00 0.00 74.00 -27.00 47.00 27.00 47.00 27.00 101.00 -27.00 101.00
3.00 87.00 74.00 60.00 47.00 114.00 47.00 114.00 101.00 60.00 101.00
index 391 is so weird that I can not solve the error
question from:
https://stackoverflow.com/questions/65951166/use-np-loadtxt-indexerror-index-391-is-out-of-bounds-for-axis-0-with-size-4 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…