mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge pull request #18211 from pemmanuelviel:pev--handle-dna-vectors
* DNA-mode: update miniflann to handle DNA * DNA-mode: update hierarchical kmeans to handle DNA sequences
This commit is contained in:
@@ -345,6 +345,7 @@ typedef ::cvflann::Hamming<uchar> HammingDistance;
|
||||
#else
|
||||
typedef ::cvflann::HammingLUT HammingDistance;
|
||||
#endif
|
||||
typedef ::cvflann::DNAmming2<uchar> DNAmmingDistance;
|
||||
|
||||
Index::Index()
|
||||
{
|
||||
@@ -397,6 +398,9 @@ void Index::build(InputArray _data, const IndexParams& params, flann_distance_t
|
||||
buildIndex< ::cvflann::L1<float> >(index, data, params);
|
||||
break;
|
||||
#if MINIFLANN_SUPPORT_EXOTIC_DISTANCE_TYPES
|
||||
case FLANN_DIST_DNAMMING:
|
||||
buildIndex< DNAmmingDistance >(index, data, params);
|
||||
break;
|
||||
case FLANN_DIST_MAX:
|
||||
buildIndex< ::cvflann::MaxDistance<float> >(index, data, params);
|
||||
break;
|
||||
@@ -452,6 +456,9 @@ void Index::release()
|
||||
deleteIndex< ::cvflann::L1<float> >(index);
|
||||
break;
|
||||
#if MINIFLANN_SUPPORT_EXOTIC_DISTANCE_TYPES
|
||||
case FLANN_DIST_DNAMMING:
|
||||
deleteIndex< DNAmmingDistance >(index);
|
||||
break;
|
||||
case FLANN_DIST_MAX:
|
||||
deleteIndex< ::cvflann::MaxDistance<float> >(index);
|
||||
break;
|
||||
@@ -573,7 +580,8 @@ void Index::knnSearch(InputArray _query, OutputArray _indices,
|
||||
CV_INSTRUMENT_REGION();
|
||||
|
||||
Mat query = _query.getMat(), indices, dists;
|
||||
int dtype = distType == FLANN_DIST_HAMMING ? CV_32S : CV_32F;
|
||||
int dtype = (distType == FLANN_DIST_HAMMING)
|
||||
|| (distType == FLANN_DIST_DNAMMING) ? CV_32S : CV_32F;
|
||||
|
||||
createIndicesDists( _indices, _dists, indices, dists, query.rows, knn, knn, dtype );
|
||||
|
||||
@@ -589,6 +597,9 @@ void Index::knnSearch(InputArray _query, OutputArray _indices,
|
||||
runKnnSearch< ::cvflann::L1<float> >(index, query, indices, dists, knn, params);
|
||||
break;
|
||||
#if MINIFLANN_SUPPORT_EXOTIC_DISTANCE_TYPES
|
||||
case FLANN_DIST_DNAMMING:
|
||||
runKnnSearch<DNAmmingDistance>(index, query, indices, dists, knn, params);
|
||||
break;
|
||||
case FLANN_DIST_MAX:
|
||||
runKnnSearch< ::cvflann::MaxDistance<float> >(index, query, indices, dists, knn, params);
|
||||
break;
|
||||
@@ -617,7 +628,8 @@ int Index::radiusSearch(InputArray _query, OutputArray _indices,
|
||||
CV_INSTRUMENT_REGION();
|
||||
|
||||
Mat query = _query.getMat(), indices, dists;
|
||||
int dtype = distType == FLANN_DIST_HAMMING ? CV_32S : CV_32F;
|
||||
int dtype = (distType == FLANN_DIST_HAMMING)
|
||||
|| (distType == FLANN_DIST_DNAMMING) ? CV_32S : CV_32F;
|
||||
CV_Assert( maxResults > 0 );
|
||||
createIndicesDists( _indices, _dists, indices, dists, query.rows, maxResults, INT_MAX, dtype );
|
||||
|
||||
@@ -634,6 +646,8 @@ int Index::radiusSearch(InputArray _query, OutputArray _indices,
|
||||
case FLANN_DIST_L1:
|
||||
return runRadiusSearch< ::cvflann::L1<float> >(index, query, indices, dists, radius, params);
|
||||
#if MINIFLANN_SUPPORT_EXOTIC_DISTANCE_TYPES
|
||||
case FLANN_DIST_DNAMMING:
|
||||
return runRadiusSearch< DNAmmingDistance >(index, query, indices, dists, radius, params);
|
||||
case FLANN_DIST_MAX:
|
||||
return runRadiusSearch< ::cvflann::MaxDistance<float> >(index, query, indices, dists, radius, params);
|
||||
case FLANN_DIST_HIST_INTERSECT:
|
||||
@@ -697,6 +711,9 @@ void Index::save(const String& filename) const
|
||||
saveIndex< ::cvflann::L1<float> >(this, index, fout);
|
||||
break;
|
||||
#if MINIFLANN_SUPPORT_EXOTIC_DISTANCE_TYPES
|
||||
case FLANN_DIST_DNAMMING:
|
||||
saveIndex< DNAmmingDistance >(this, index, fout);
|
||||
break;
|
||||
case FLANN_DIST_MAX:
|
||||
saveIndex< ::cvflann::MaxDistance<float> >(this, index, fout);
|
||||
break;
|
||||
@@ -778,6 +795,7 @@ bool Index::load(InputArray _data, const String& filename)
|
||||
distType = (flann_distance_t)idistType;
|
||||
|
||||
if( !((distType == FLANN_DIST_HAMMING && featureType == CV_8U) ||
|
||||
(distType == FLANN_DIST_DNAMMING && featureType == CV_8U) ||
|
||||
(distType != FLANN_DIST_HAMMING && featureType == CV_32F)) )
|
||||
{
|
||||
fprintf(stderr, "Reading FLANN index error: unsupported feature type %d for the index type %d\n", featureType, algo);
|
||||
@@ -797,6 +815,9 @@ bool Index::load(InputArray _data, const String& filename)
|
||||
loadIndex< ::cvflann::L1<float> >(this, index, data, fin);
|
||||
break;
|
||||
#if MINIFLANN_SUPPORT_EXOTIC_DISTANCE_TYPES
|
||||
case FLANN_DIST_DNAMMING:
|
||||
loadIndex< DNAmmingDistance >(this, index, data, fin);
|
||||
break;
|
||||
case FLANN_DIST_MAX:
|
||||
loadIndex< ::cvflann::MaxDistance<float> >(this, index, data, fin);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user