Coordinate designation of arrays in python

Asked 1 years ago, Updated 1 years ago, 102 views

python 3.6 opencv3
I don't know how to find one position (x,y) coordinate in numpy ndarray.
The reason why I want to access the numpyndarray address is because I thought that the cv2.Keypoints() argument has rows x, columns y of the matrix, and I have to use the address to get the argument.

patches[x]=
[[[255 255 255]
[255 255 255]
[255 255 255]]

How do I specify the location of 255 in the middle of an array like the one above as a variable?

Array a = [255 255]
    [255 255 255]
    [255 255 255]
I would like to substitute b for the address of row 1 column 1 in b in python.
The goal is simply to get raw addresses as variables

opencv python3 numpy

2022-09-30 21:26

1 Answers

Am I correct in understanding that you would like to obtain the value in the middle position?
The code presented had a lot of starting parentheses and could not determine whether it was a tertiary or secondary array.
C++ says &a[1][1], so I'll interpret it as a secondary array.

import numpy

patches = numpy.array([
  [255, 255, 255],
  [255, 255, 255],
  [255, 255, 255]
  ])

print (patches[1,1])
# = > 255

patches[1,1] = 100
print(patches)
# = > [[255 255 255]
#    [255 100 255]
#    [255 255 255]]

ndarray can be a collection of indexes for each dimension.
If not specified, everything you do not specify will be the new ndarray selected.

 print (patches[1])
# = > [255 100 255 ]

Note: Memory addresses, such as those in C language, cannot be accessed due to the abstraction of numpy.


2022-09-30 21:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.