python - Getting element from a certain numpy array returned from OpenCV? -


i trying information (coordinates) within numpy array , having difficult time extracting information it.

the numpy array returned opencv method, cv2.calcopticalflowpyrlk, produced coordinates of each point in numpy array.

this output single point:

[[[ 292.61154175  264.74569702]]] 

small sample of code:

p1, st, err = cv2.calcopticalflowpyrlk(old_gray, frame_gray, p0, none, **lk_params)  good_new = p1[st==1] good_old = p0[st==1] 

how extract numbers individually type of numpy array?

import numpy  # create such nested array d = numpy.array([[[1, 2]]])  # test can access individual elements assert d[0, 0, 0] == 1 assert d[0, 0, 1] == 2 

update:

please note above indexing works numpy arrays. standard python nested lists e = [[[1, 2]]] must indexed in standard python way: e[0][0][0].


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -