Declare a matrix correctly

0

QUESTION EDITED, the first time I had misplaced the case

I want to work with matrices but I can not understand how to do it. I want each time you click with the mouse to save the X and Y positions of your position.

For this I wanted to create a matrix. With the first click save the coordinates in matriz[0][0] and matriz[0][1] , with the second click save them in matriz[1][0] and matriz[1][1]

For this I created this code

def buscar_circulos(event,x,y,flags,param):

global cont

global posicionAnterior

if event == cv2.EVENT_LBUTTONUP and cont == False:
    posicionAnterior[0][0] = x
    posicionAnterior[0][1] = y
    cont = True

elif event == cv2.EVENT_LBUTTONUP and cont == True:
    posicionAnterior[1][0] = x
    posicionAnterior[1][1] = y

    print('Valor posicionAnterior[0][0]: ',posicionAnterior[0][0])
    print('Valor posicionAnterior[0][1]: ',posicionAnterior[0][1])
    print('Valor posicionAnterior[1][0]: ',posicionAnterior[1][0])
    print('Valor posicionAnterior[1][1]: ',posicionAnterior[1][1])

Say that cont is a global initialized as cont = False and anterior position as posicionAnterior = [[],[]]

I have also tried with .append() , for example posicionAnterior[0][0].append(x) and I also do not get anything. (I think this is more correct than what I have in the code)

I understand that I should not be declaring the matrix well, but I do not understand the reason.

    
asked by NEA 02.09.2018 в 18:32
source

0 answers