Search code examples
python-3.xnumpycomputer-visionconcatenationdata-analysis

Save all the descriptors taken from multiple images in Python 3.5


I'm trying to extract the descriptors of multiple images that i have in my database. The method used give me a matrix of keypoints and a matrix of the descriptors for every image, so i want to group them into a sigle matrix.

I've tried over a loop:

kp_all = numpy.hstack((kp_all, kp))
des_all = numpy.hstack((des_all, des))

where kp_all and des_all are correctlly initialized because is the descriptor of the first image, so i want to concatenate the other descriptors into that matrix. The error given is:

ValueError: all the input array dimensions except for the concatenation 
axis must match exactly

The dimensions of the vectors are:

Processing image....
dimension kp_all and des_all (10, 7) (10, 32)
Processing image....
dimension kp and des (46, 7) (46, 32)
Processing image....
dimension kp and des (17, 7) (17, 32)

anyone has any idea? Thank you!!!


Solution

  • Based on OP's comment and observing the dimensions of the variables kp_all, des_all, kp, des

    dimension kp_all and des_all (10, 7) (10, 32)
    dimension kp and des (46, 7) (46, 32)
    dimension kp and des (17, 7) (17, 32)

    We can use, np.vstack

    kp_all = np.vstack((kp_all, kp))
    des_all = np.vstack((des_all, des))