Take a close look at how many brackets your array has. I met an example when a function returned an answer with an extra bracket, for example:
>>>approx array([[[1192, 391]], [[1191, 409]], [[1209, 438]], [[1191, 409]]])
And it didnโt work
>>> approx[1,1] IndexError: index 1 is out of bounds for axis 1 with size 1
This may open the brackets:
>>> approx[:,0] array([[1192, 391], [1191, 409], [1209, 438], [1191, 409]])
Now you can use the standard entry for accessing the element:
>>> approx[:,0][1,1] 409
Uladzimir Simankou
source share