The problem was solved. The problem was that descriptors should not be converted to CV_32F and that I need to check if (matches[i].size() >= 2) Thanks!