Compile opencv_test_core with cv::String instead of std::string
All tests passed!
This commit is contained in:
@@ -112,7 +112,7 @@ public:
|
||||
int radiusSearch(const Mat& query, Mat& indices, Mat& dists,
|
||||
DistanceType radius, const ::cvflann::SearchParams& params);
|
||||
|
||||
void save(std::string filename) { nnIndex->save(filename); }
|
||||
void save(cv::String filename) { nnIndex->save(filename); }
|
||||
|
||||
int veclen() const { return nnIndex->veclen(); }
|
||||
|
||||
@@ -244,7 +244,7 @@ public:
|
||||
int radiusSearch(const std::vector<ElementType>& query, std::vector<int>& indices, std::vector<DistanceType>& dists, DistanceType radius, const ::cvflann::SearchParams& params);
|
||||
int radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& params);
|
||||
|
||||
void save(std::string filename)
|
||||
void save(cv::String filename)
|
||||
{
|
||||
if (nnIndex_L1) nnIndex_L1->save(filename);
|
||||
if (nnIndex_L2) nnIndex_L2->save(filename);
|
||||
|
@@ -106,6 +106,11 @@ template<> inline void big_any_policy<flann_algorithm_t>::print(std::ostream& ou
|
||||
out << int(*reinterpret_cast<flann_algorithm_t const*>(*src));
|
||||
}
|
||||
|
||||
template<> inline void big_any_policy<cv::String>::print(std::ostream& out, void* const* src)
|
||||
{
|
||||
out << (*reinterpret_cast<cv::String const*>(*src)).c_str();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
struct choose_policy
|
||||
{
|
||||
|
@@ -62,7 +62,7 @@ inline void log_verbosity(int level)
|
||||
*/
|
||||
struct SavedIndexParams : public IndexParams
|
||||
{
|
||||
SavedIndexParams(std::string filename)
|
||||
SavedIndexParams(cv::String filename)
|
||||
{
|
||||
(* this)["algorithm"] = FLANN_INDEX_SAVED;
|
||||
(*this)["filename"] = filename;
|
||||
@@ -71,7 +71,7 @@ struct SavedIndexParams : public IndexParams
|
||||
|
||||
|
||||
template<typename Distance>
|
||||
NNIndex<Distance>* load_saved_index(const Matrix<typename Distance::ElementType>& dataset, const std::string& filename, Distance distance)
|
||||
NNIndex<Distance>* load_saved_index(const Matrix<typename Distance::ElementType>& dataset, const cv::String& filename, Distance distance)
|
||||
{
|
||||
typedef typename Distance::ElementType ElementType;
|
||||
|
||||
@@ -111,7 +111,7 @@ public:
|
||||
loaded_ = false;
|
||||
|
||||
if (index_type == FLANN_INDEX_SAVED) {
|
||||
nnIndex_ = load_saved_index<Distance>(features, get_param<std::string>(params,"filename"), distance);
|
||||
nnIndex_ = load_saved_index<Distance>(features, get_param<cv::String>(params,"filename"), distance);
|
||||
loaded_ = true;
|
||||
}
|
||||
else {
|
||||
@@ -134,7 +134,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void save(std::string filename)
|
||||
void save(cv::String filename)
|
||||
{
|
||||
FILE* fout = fopen(filename.c_str(), "wb");
|
||||
if (fout == NULL) {
|
||||
|
@@ -31,19 +31,17 @@
|
||||
#ifndef OPENCV_FLANN_GENERAL_H_
|
||||
#define OPENCV_FLANN_GENERAL_H_
|
||||
|
||||
#include "defines.h"
|
||||
#include <stdexcept>
|
||||
#include <cassert>
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
namespace cvflann
|
||||
{
|
||||
|
||||
class FLANNException : public std::runtime_error
|
||||
class FLANNException : public cv::Exception
|
||||
{
|
||||
public:
|
||||
FLANNException(const char* message) : std::runtime_error(message) { }
|
||||
FLANNException(const char* message) : cv::Exception(0, message, "", __FILE__, __LINE__) { }
|
||||
|
||||
FLANNException(const std::string& message) : std::runtime_error(message) { }
|
||||
FLANNException(const cv::String& message) : cv::Exception(0, message, "", __FILE__, __LINE__) { }
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -73,7 +73,7 @@ hid_t get_hdf5_type<double>() { return H5T_NATIVE_DOUBLE; }
|
||||
#define CHECK_ERROR(x,y) if ((x)<0) throw FLANNException((y));
|
||||
|
||||
template<typename T>
|
||||
void save_to_file(const cvflann::Matrix<T>& dataset, const std::string& filename, const std::string& name)
|
||||
void save_to_file(const cvflann::Matrix<T>& dataset, const cv::String& filename, const cv::String& name)
|
||||
{
|
||||
|
||||
#if H5Eset_auto_vers == 2
|
||||
@@ -125,7 +125,7 @@ void save_to_file(const cvflann::Matrix<T>& dataset, const std::string& filename
|
||||
|
||||
|
||||
template<typename T>
|
||||
void load_from_file(cvflann::Matrix<T>& dataset, const std::string& filename, const std::string& name)
|
||||
void load_from_file(cvflann::Matrix<T>& dataset, const cv::String& filename, const cv::String& name)
|
||||
{
|
||||
herr_t status;
|
||||
hid_t file_id = H5Fopen(filename.c_str(), H5F_ACC_RDWR, H5P_DEFAULT);
|
||||
@@ -166,7 +166,7 @@ namespace mpi
|
||||
* @param name Name of dataset inside file
|
||||
*/
|
||||
template<typename T>
|
||||
void load_from_file(cvflann::Matrix<T>& dataset, const std::string& filename, const std::string& name)
|
||||
void load_from_file(cvflann::Matrix<T>& dataset, const cv::String& filename, const cv::String& name)
|
||||
{
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
MPI_Info info = MPI_INFO_NULL;
|
||||
|
@@ -266,9 +266,7 @@ private:
|
||||
const size_t key_size_upper_bound = std::min(sizeof(BucketKey) * CHAR_BIT + 1, sizeof(size_t) * CHAR_BIT);
|
||||
if (key_size < key_size_lower_bound || key_size >= key_size_upper_bound)
|
||||
{
|
||||
std::stringstream errorMessage;
|
||||
errorMessage << "Invalid key_size (=" << key_size << "). Valid values for your system are " << key_size_lower_bound << " <= key_size < " << key_size_upper_bound << ".";
|
||||
CV_Error(CV_StsBadArg, errorMessage.str());
|
||||
CV_Error(CV_StsBadArg, cv::format("Invalid key_size (=%d). Valid values for your system are %d <= key_size < %d.", (int)key_size, (int)key_size_lower_bound, (int)key_size_upper_bound));
|
||||
}
|
||||
|
||||
speed_level_ = kHash;
|
||||
|
@@ -59,20 +59,20 @@ struct CV_EXPORTS IndexParams
|
||||
IndexParams();
|
||||
~IndexParams();
|
||||
|
||||
std::string getString(const std::string& key, const std::string& defaultVal=std::string()) const;
|
||||
int getInt(const std::string& key, int defaultVal=-1) const;
|
||||
double getDouble(const std::string& key, double defaultVal=-1) const;
|
||||
cv::String getString(const cv::String& key, const cv::String& defaultVal=cv::String()) const;
|
||||
int getInt(const cv::String& key, int defaultVal=-1) const;
|
||||
double getDouble(const cv::String& key, double defaultVal=-1) const;
|
||||
|
||||
void setString(const std::string& key, const std::string& value);
|
||||
void setInt(const std::string& key, int value);
|
||||
void setDouble(const std::string& key, double value);
|
||||
void setFloat(const std::string& key, float value);
|
||||
void setBool(const std::string& key, bool value);
|
||||
void setString(const cv::String& key, const cv::String& value);
|
||||
void setInt(const cv::String& key, int value);
|
||||
void setDouble(const cv::String& key, double value);
|
||||
void setFloat(const cv::String& key, float value);
|
||||
void setBool(const cv::String& key, bool value);
|
||||
void setAlgorithm(int value);
|
||||
|
||||
void getAll(std::vector<std::string>& names,
|
||||
void getAll(std::vector<cv::String>& names,
|
||||
std::vector<int>& types,
|
||||
std::vector<std::string>& strValues,
|
||||
std::vector<cv::String>& strValues,
|
||||
std::vector<double>& numValues) const;
|
||||
|
||||
void* params;
|
||||
@@ -119,7 +119,7 @@ struct CV_EXPORTS LshIndexParams : public IndexParams
|
||||
|
||||
struct CV_EXPORTS SavedIndexParams : public IndexParams
|
||||
{
|
||||
SavedIndexParams(const std::string& filename);
|
||||
SavedIndexParams(const cv::String& filename);
|
||||
};
|
||||
|
||||
struct CV_EXPORTS SearchParams : public IndexParams
|
||||
@@ -142,8 +142,8 @@ public:
|
||||
OutputArray dists, double radius, int maxResults,
|
||||
const SearchParams& params=SearchParams());
|
||||
|
||||
CV_WRAP virtual void save(const std::string& filename) const;
|
||||
CV_WRAP virtual bool load(InputArray features, const std::string& filename);
|
||||
CV_WRAP virtual void save(const cv::String& filename) const;
|
||||
CV_WRAP virtual bool load(InputArray features, const cv::String& filename);
|
||||
CV_WRAP virtual void release();
|
||||
CV_WRAP cvflann::flann_distance_t getDistance() const;
|
||||
CV_WRAP cvflann::flann_algorithm_t getAlgorithm() const;
|
||||
|
@@ -39,7 +39,7 @@
|
||||
namespace cvflann
|
||||
{
|
||||
|
||||
typedef std::map<std::string, any> IndexParams;
|
||||
typedef std::map<cv::String, any> IndexParams;
|
||||
|
||||
struct SearchParams : public IndexParams
|
||||
{
|
||||
@@ -56,7 +56,7 @@ struct SearchParams : public IndexParams
|
||||
|
||||
|
||||
template<typename T>
|
||||
T get_param(const IndexParams& params, std::string name, const T& default_value)
|
||||
T get_param(const IndexParams& params, cv::String name, const T& default_value)
|
||||
{
|
||||
IndexParams::const_iterator it = params.find(name);
|
||||
if (it != params.end()) {
|
||||
@@ -68,14 +68,14 @@ T get_param(const IndexParams& params, std::string name, const T& default_value)
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T get_param(const IndexParams& params, std::string name)
|
||||
T get_param(const IndexParams& params, cv::String name)
|
||||
{
|
||||
IndexParams::const_iterator it = params.find(name);
|
||||
if (it != params.end()) {
|
||||
return it->second.cast<T>();
|
||||
}
|
||||
else {
|
||||
throw FLANNException(std::string("Missing parameter '")+name+std::string("' in the parameters given"));
|
||||
throw FLANNException(cv::String("Missing parameter '")+name+cv::String("' in the parameters given"));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user