# Revision history [back]

### Is there any way to use a custom distance with FLANN?

Hey guys, so I see te GenericIndex class is templated. FLANN originally, however, is a bit more flexible than that. It allows defining the distance function. Is it possible with OpenCV as well? (In other words, in the code below, I would like Knn_Distance be my own class definition)

    this->p_index = std::make_shared< cv::flann::GenericIndex<Knn_Distance> >(
train_vectors,
cvflann::KDTreeIndexParams(this->params.num_trees),
Knn_Distance()
);


Thanks!