mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -366,6 +366,7 @@ typedef ::cvflann::Hamming<uchar> HammingDistance;
|
||||
#else
|
||||
typedef ::cvflann::HammingLUT HammingDistance;
|
||||
#endif
|
||||
typedef ::cvflann::DNAmming2<uchar> DNAmmingDistance;
|
||||
|
||||
Index::Index()
|
||||
{
|
||||
@@ -418,6 +419,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;
|
||||
@@ -473,6 +477,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;
|
||||
@@ -594,7 +601,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 );
|
||||
|
||||
@@ -610,6 +618,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;
|
||||
@@ -638,7 +649,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 );
|
||||
|
||||
@@ -655,6 +667,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:
|
||||
@@ -718,6 +732,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;
|
||||
@@ -799,6 +816,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);
|
||||
@@ -818,6 +836,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