diff --git a/modules/flann/include/opencv2/flann/flann.hpp b/modules/flann/include/opencv2/flann/flann.hpp
index 0a9f38ffa..aecb584d2 100644
--- a/modules/flann/include/opencv2/flann/flann.hpp
+++ b/modules/flann/include/opencv2/flann/flann.hpp
@@ -104,7 +104,7 @@ Index_<T>::Index_(const Mat& dataset, const IndexParams& params)
 {
     CV_Assert(dataset.type() == CvType<T>::type());
     CV_Assert(dataset.isContinuous());
-    ::cvflann::Matrix<float> m_dataset((T*)dataset.ptr<T>(0), dataset.rows, dataset.cols);
+    ::cvflann::Matrix<T> m_dataset((T*)dataset.ptr<T>(0), dataset.rows, dataset.cols);
     
     nnIndex = new ::cvflann::Index<T>(m_dataset, params);
     nnIndex->buildIndex();