|
|
|
@ -40,6 +40,7 @@ |
|
|
|
|
//M*/
|
|
|
|
|
|
|
|
|
|
#include "precomp.hpp" |
|
|
|
|
#include "opencv2/flann/miniflann.hpp" |
|
|
|
|
#include <limits> |
|
|
|
|
#include "opencl_kernels_features2d.hpp" |
|
|
|
|
|
|
|
|
@ -1167,6 +1168,8 @@ void FlannBasedMatcher::train() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
using namespace cv::flann; |
|
|
|
|
|
|
|
|
|
void FlannBasedMatcher::read( const FileNode& fn) |
|
|
|
|
{ |
|
|
|
|
if (!indexParams) |
|
|
|
@ -1179,32 +1182,34 @@ void FlannBasedMatcher::read( const FileNode& fn) |
|
|
|
|
{ |
|
|
|
|
CV_Assert(ip[i].type() == FileNode::MAP); |
|
|
|
|
String _name = (String)ip[i]["name"]; |
|
|
|
|
int type = (int)ip[i]["type"]; |
|
|
|
|
FlannIndexType type = (FlannIndexType)(int)ip[i]["type"]; |
|
|
|
|
CV_CheckLE((int)type, (int)LAST_VALUE_FLANN_INDEX_TYPE, ""); |
|
|
|
|
|
|
|
|
|
switch(type) |
|
|
|
|
{ |
|
|
|
|
case CV_8U: |
|
|
|
|
case CV_8S: |
|
|
|
|
case CV_16U: |
|
|
|
|
case CV_16S: |
|
|
|
|
case CV_32S: |
|
|
|
|
case FLANN_INDEX_TYPE_8U: |
|
|
|
|
case FLANN_INDEX_TYPE_8S: |
|
|
|
|
case FLANN_INDEX_TYPE_16U: |
|
|
|
|
case FLANN_INDEX_TYPE_16S: |
|
|
|
|
case FLANN_INDEX_TYPE_32S: |
|
|
|
|
indexParams->setInt(_name, (int) ip[i]["value"]); |
|
|
|
|
break; |
|
|
|
|
case CV_32F: |
|
|
|
|
case FLANN_INDEX_TYPE_32F: |
|
|
|
|
indexParams->setFloat(_name, (float) ip[i]["value"]); |
|
|
|
|
break; |
|
|
|
|
case CV_64F: |
|
|
|
|
case FLANN_INDEX_TYPE_64F: |
|
|
|
|
indexParams->setDouble(_name, (double) ip[i]["value"]); |
|
|
|
|
break; |
|
|
|
|
case CV_USRTYPE1: |
|
|
|
|
case FLANN_INDEX_TYPE_STRING: |
|
|
|
|
indexParams->setString(_name, (String) ip[i]["value"]); |
|
|
|
|
break; |
|
|
|
|
case CV_MAKETYPE(CV_USRTYPE1,2): |
|
|
|
|
case FLANN_INDEX_TYPE_BOOL: |
|
|
|
|
indexParams->setBool(_name, (int) ip[i]["value"] != 0); |
|
|
|
|
break; |
|
|
|
|
case CV_MAKETYPE(CV_USRTYPE1,3): |
|
|
|
|
case FLANN_INDEX_TYPE_ALGORITHM: |
|
|
|
|
indexParams->setAlgorithm((int) ip[i]["value"]); |
|
|
|
|
break; |
|
|
|
|
// don't default: - compiler warning is here
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1218,32 +1223,34 @@ void FlannBasedMatcher::read( const FileNode& fn) |
|
|
|
|
{ |
|
|
|
|
CV_Assert(sp[i].type() == FileNode::MAP); |
|
|
|
|
String _name = (String)sp[i]["name"]; |
|
|
|
|
int type = (int)sp[i]["type"]; |
|
|
|
|
FlannIndexType type = (FlannIndexType)(int)sp[i]["type"]; |
|
|
|
|
CV_CheckLE((int)type, (int)LAST_VALUE_FLANN_INDEX_TYPE, ""); |
|
|
|
|
|
|
|
|
|
switch(type) |
|
|
|
|
{ |
|
|
|
|
case CV_8U: |
|
|
|
|
case CV_8S: |
|
|
|
|
case CV_16U: |
|
|
|
|
case CV_16S: |
|
|
|
|
case CV_32S: |
|
|
|
|
case FLANN_INDEX_TYPE_8U: |
|
|
|
|
case FLANN_INDEX_TYPE_8S: |
|
|
|
|
case FLANN_INDEX_TYPE_16U: |
|
|
|
|
case FLANN_INDEX_TYPE_16S: |
|
|
|
|
case FLANN_INDEX_TYPE_32S: |
|
|
|
|
searchParams->setInt(_name, (int) sp[i]["value"]); |
|
|
|
|
break; |
|
|
|
|
case CV_32F: |
|
|
|
|
case FLANN_INDEX_TYPE_32F: |
|
|
|
|
searchParams->setFloat(_name, (float) ip[i]["value"]); |
|
|
|
|
break; |
|
|
|
|
case CV_64F: |
|
|
|
|
case FLANN_INDEX_TYPE_64F: |
|
|
|
|
searchParams->setDouble(_name, (double) ip[i]["value"]); |
|
|
|
|
break; |
|
|
|
|
case CV_USRTYPE1: |
|
|
|
|
case FLANN_INDEX_TYPE_STRING: |
|
|
|
|
searchParams->setString(_name, (String) ip[i]["value"]); |
|
|
|
|
break; |
|
|
|
|
case CV_MAKETYPE(CV_USRTYPE1,2): |
|
|
|
|
case FLANN_INDEX_TYPE_BOOL: |
|
|
|
|
searchParams->setBool(_name, (int) ip[i]["value"] != 0); |
|
|
|
|
break; |
|
|
|
|
case CV_MAKETYPE(CV_USRTYPE1,3): |
|
|
|
|
case FLANN_INDEX_TYPE_ALGORITHM: |
|
|
|
|
searchParams->setAlgorithm((int) ip[i]["value"]); |
|
|
|
|
break; |
|
|
|
|
// don't default: - compiler warning is here
|
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1258,7 +1265,7 @@ void FlannBasedMatcher::write( FileStorage& fs) const |
|
|
|
|
if (indexParams) |
|
|
|
|
{ |
|
|
|
|
std::vector<String> names; |
|
|
|
|
std::vector<int> types; |
|
|
|
|
std::vector<FlannIndexType> types; |
|
|
|
|
std::vector<String> strValues; |
|
|
|
|
std::vector<double> numValues; |
|
|
|
|
|
|
|
|
@ -1267,38 +1274,43 @@ void FlannBasedMatcher::write( FileStorage& fs) const |
|
|
|
|
for(size_t i = 0; i < names.size(); ++i) |
|
|
|
|
{ |
|
|
|
|
fs << "{" << "name" << names[i] << "type" << types[i] << "value"; |
|
|
|
|
switch(types[i]) |
|
|
|
|
FlannIndexType type = (FlannIndexType)types[i]; |
|
|
|
|
if ((int)type < 0 || type > LAST_VALUE_FLANN_INDEX_TYPE) |
|
|
|
|
{ |
|
|
|
|
fs << (double)numValues[i]; |
|
|
|
|
fs << "typename" << strValues[i]; |
|
|
|
|
fs << "}"; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
switch(type) |
|
|
|
|
{ |
|
|
|
|
case CV_8U: |
|
|
|
|
case FLANN_INDEX_TYPE_8U: |
|
|
|
|
fs << (uchar)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_8S: |
|
|
|
|
case FLANN_INDEX_TYPE_8S: |
|
|
|
|
fs << (char)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_16U: |
|
|
|
|
case FLANN_INDEX_TYPE_16U: |
|
|
|
|
fs << (ushort)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_16S: |
|
|
|
|
case FLANN_INDEX_TYPE_16S: |
|
|
|
|
fs << (short)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_32S: |
|
|
|
|
case CV_MAKETYPE(CV_USRTYPE1,2): |
|
|
|
|
case CV_MAKETYPE(CV_USRTYPE1,3): |
|
|
|
|
case FLANN_INDEX_TYPE_32S: |
|
|
|
|
case FLANN_INDEX_TYPE_BOOL: |
|
|
|
|
case FLANN_INDEX_TYPE_ALGORITHM: |
|
|
|
|
fs << (int)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_32F: |
|
|
|
|
case FLANN_INDEX_TYPE_32F: |
|
|
|
|
fs << (float)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_64F: |
|
|
|
|
case FLANN_INDEX_TYPE_64F: |
|
|
|
|
fs << (double)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_USRTYPE1: |
|
|
|
|
case FLANN_INDEX_TYPE_STRING: |
|
|
|
|
fs << strValues[i]; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
fs << (double)numValues[i]; |
|
|
|
|
fs << "typename" << strValues[i]; |
|
|
|
|
break; |
|
|
|
|
// don't default: - compiler warning is here
|
|
|
|
|
} |
|
|
|
|
fs << "}"; |
|
|
|
|
} |
|
|
|
@ -1309,7 +1321,7 @@ void FlannBasedMatcher::write( FileStorage& fs) const |
|
|
|
|
if (searchParams) |
|
|
|
|
{ |
|
|
|
|
std::vector<String> names; |
|
|
|
|
std::vector<int> types; |
|
|
|
|
std::vector<FlannIndexType> types; |
|
|
|
|
std::vector<String> strValues; |
|
|
|
|
std::vector<double> numValues; |
|
|
|
|
|
|
|
|
@ -1318,23 +1330,31 @@ void FlannBasedMatcher::write( FileStorage& fs) const |
|
|
|
|
for(size_t i = 0; i < names.size(); ++i) |
|
|
|
|
{ |
|
|
|
|
fs << "{" << "name" << names[i] << "type" << types[i] << "value"; |
|
|
|
|
switch(types[i]) |
|
|
|
|
FlannIndexType type = (FlannIndexType)types[i]; |
|
|
|
|
if ((int)type < 0 || type > LAST_VALUE_FLANN_INDEX_TYPE) |
|
|
|
|
{ |
|
|
|
|
fs << (double)numValues[i]; |
|
|
|
|
fs << "typename" << strValues[i]; |
|
|
|
|
fs << "}"; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
switch(type) |
|
|
|
|
{ |
|
|
|
|
case CV_8U: |
|
|
|
|
case FLANN_INDEX_TYPE_8U: |
|
|
|
|
fs << (uchar)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_8S: |
|
|
|
|
case FLANN_INDEX_TYPE_8S: |
|
|
|
|
fs << (char)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_16U: |
|
|
|
|
case FLANN_INDEX_TYPE_16U: |
|
|
|
|
fs << (ushort)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_16S: |
|
|
|
|
case FLANN_INDEX_TYPE_16S: |
|
|
|
|
fs << (short)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_32S: |
|
|
|
|
case CV_MAKETYPE(CV_USRTYPE1,2): |
|
|
|
|
case CV_MAKETYPE(CV_USRTYPE1,3): |
|
|
|
|
case FLANN_INDEX_TYPE_32S: |
|
|
|
|
case FLANN_INDEX_TYPE_BOOL: |
|
|
|
|
case FLANN_INDEX_TYPE_ALGORITHM: |
|
|
|
|
fs << (int)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_32F: |
|
|
|
@ -1343,13 +1363,10 @@ void FlannBasedMatcher::write( FileStorage& fs) const |
|
|
|
|
case CV_64F: |
|
|
|
|
fs << (double)numValues[i]; |
|
|
|
|
break; |
|
|
|
|
case CV_USRTYPE1: |
|
|
|
|
case FLANN_INDEX_TYPE_STRING: |
|
|
|
|
fs << strValues[i]; |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
fs << (double)numValues[i]; |
|
|
|
|
fs << "typename" << strValues[i]; |
|
|
|
|
break; |
|
|
|
|
// don't default: - compiler warning is here
|
|
|
|
|
} |
|
|
|
|
fs << "}"; |
|
|
|
|
} |
|
|
|
|