diff --git a/modules/features2d/src/descriptors.cpp b/modules/features2d/src/descriptors.cpp index 619a158a60..6335037e4b 100644 --- a/modules/features2d/src/descriptors.cpp +++ b/modules/features2d/src/descriptors.cpp @@ -277,6 +277,7 @@ void BruteForceMatcher >::matchImpl( const Mat& descriptors_1, const M { matches.clear(); matches.reserve( descriptors_1.rows ); +//TODO: remove _DEBUG if bag 416 fixed #if (defined _DEBUG || !defined HAVE_EIGEN2) Mat norms; cv::reduce( descriptors_2.mul( descriptors_2 ), norms, 1, 0); @@ -292,20 +293,25 @@ void BruteForceMatcher >::matchImpl( const Mat& descriptors_1, const M } #else - Eigen::Matrix desc1; + Eigen::Matrix desc1t; Eigen::Matrix desc2; - cv2eigen( descriptors_1, desc1); + cv2eigen( descriptors_1.t(), desc1t); cv2eigen( descriptors_2, desc2 ); - Eigen::Matrix norms = desc2.rowwise().squaredNorm().transpose(); + //Eigen::Matrix norms = desc2.rowwise().squaredNorm(); + Eigen::Matrix norms = desc2.rowwise().squaredNorm() / 2; for( int i=0;i distances = (-2)*desc1.row(i)*desc2.transpose(); + //Eigen::Matrix distances = (-2) * (desc2*desc1t.col(i)); + Eigen::Matrix distances = desc2*desc1t.col(i); + + //distances += norms; + distances -= norms; - distances += norms; int idx; - distances.minCoeff(&idx); + + //distances.minCoeff(&idx); + distances.maxCoeff(&idx); matches.push_back( idx ); } #endif