diff --git a/modules/flann/include/opencv2/flann/all_indices.h b/modules/flann/include/opencv2/flann/all_indices.h index 2de18af24ad4042c36ba0c18fbfe13dbed470576..03877ab6adcad1c93f561104fb0db1a61b5ecd88 100644 --- a/modules/flann/include/opencv2/flann/all_indices.h +++ b/modules/flann/include/opencv2/flann/all_indices.h @@ -82,7 +82,7 @@ struct index_creator nnIndex = new LshIndex(dataset, params, distance); break; default: - throw FLANNException("Unknown index type"); + FLANN_THROW(cv::Error::StsBadArg, "Unknown index type"); } return nnIndex; @@ -111,7 +111,7 @@ struct index_creator nnIndex = new LshIndex(dataset, params, distance); break; default: - throw FLANNException("Unknown index type"); + FLANN_THROW(cv::Error::StsBadArg, "Unknown index type"); } return nnIndex; @@ -140,7 +140,7 @@ struct index_creator nnIndex = new LshIndex(dataset, params, distance); break; default: - throw FLANNException("Unknown index type"); + FLANN_THROW(cv::Error::StsBadArg, "Unknown index type"); } return nnIndex; diff --git a/modules/flann/include/opencv2/flann/autotuned_index.h b/modules/flann/include/opencv2/flann/autotuned_index.h index 54a60a73d687fb18839a6b5cec7a440384f80a91..d90f739aff24da2c76159ccb531321191e65d1c1 100644 --- a/modules/flann/include/opencv2/flann/autotuned_index.h +++ b/modules/flann/include/opencv2/flann/autotuned_index.h @@ -34,7 +34,6 @@ #include -#include "general.h" #include "nn_index.h" #include "ground_truth.h" #include "index_testing.h" diff --git a/modules/flann/include/opencv2/flann/composite_index.h b/modules/flann/include/opencv2/flann/composite_index.h index bcf0827c9f728eb069ec8184331df37fc39f02fe..f1af41ac2622a043b22298765b3c66d7547fdac3 100644 --- a/modules/flann/include/opencv2/flann/composite_index.h +++ b/modules/flann/include/opencv2/flann/composite_index.h @@ -33,7 +33,6 @@ //! @cond IGNORED -#include "general.h" #include "nn_index.h" #include "kdtree_index.h" #include "kmeans_index.h" diff --git a/modules/flann/include/opencv2/flann/flann_base.hpp b/modules/flann/include/opencv2/flann/flann_base.hpp index 0f23930024b724cb2346d954056929ad277462b6..258ec38d207840b4702db6055ffd59f5db749ec1 100644 --- a/modules/flann/include/opencv2/flann/flann_base.hpp +++ b/modules/flann/include/opencv2/flann/flann_base.hpp @@ -82,11 +82,11 @@ NNIndex* load_saved_index(const Matrix IndexHeader header = load_header(fin); if (header.data_type != Datatype::type()) { fclose(fin); - throw FLANNException("Datatype of saved index is different than of the one to be created."); + FLANN_THROW(cv::Error::StsError, "Datatype of saved index is different than of the one to be created."); } if ((size_t(header.rows) != dataset.rows)||(size_t(header.cols) != dataset.cols)) { fclose(fin); - throw FLANNException("The index saved belongs to a different dataset"); + FLANN_THROW(cv::Error::StsError, "The index saved belongs to a different dataset"); } IndexParams params; @@ -140,7 +140,7 @@ public: { FILE* fout = fopen(filename.c_str(), "wb"); if (fout == NULL) { - throw FLANNException("Cannot open file"); + FLANN_THROW(cv::Error::StsError, "Cannot open file"); } save_header(fout, *nnIndex_); saveIndex(fout); diff --git a/modules/flann/include/opencv2/flann/general.h b/modules/flann/include/opencv2/flann/general.h index ac848d6230fabadd13fd9fa3373bc38e802ac0fd..29fa8be121142dff2b8af90663ff133aaa5a855a 100644 --- a/modules/flann/include/opencv2/flann/general.h +++ b/modules/flann/include/opencv2/flann/general.h @@ -31,6 +31,8 @@ #ifndef OPENCV_FLANN_GENERAL_H_ #define OPENCV_FLANN_GENERAL_H_ +#if CV_VERSION_MAJOR <= 4 + //! @cond IGNORED #include "opencv2/core.hpp" @@ -48,6 +50,14 @@ public: } +#define FLANN_THROW(TYPE, STR) throw FLANNException(STR) + +#else + +#define FLANN_THROW(TYPE, STR) CV_Error(TYPE, STR) + +#endif + //! @endcond #endif /* OPENCV_FLANN_GENERAL_H_ */ diff --git a/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h b/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h index 78ac4016300b0098e7eb5b03aac63a5c56dd9504..7085d6901ea1b602cae096f5a8c2a946d4741ab9 100644 --- a/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h +++ b/modules/flann/include/opencv2/flann/hierarchical_clustering_index.h @@ -382,7 +382,7 @@ public: chooseCenters = &HierarchicalClusteringIndex::GroupWiseCenterChooser; } else { - throw FLANNException("Unknown algorithm for choosing initial centers."); + FLANN_THROW(cv::Error::StsError, "Unknown algorithm for choosing initial centers."); } root = new NodePtr[trees_]; @@ -446,7 +446,7 @@ public: void buildIndex() CV_OVERRIDE { if (branching_<2) { - throw FLANNException("Branching factor must be at least 2"); + FLANN_THROW(cv::Error::StsError, "Branching factor must be at least 2"); } free_indices(); diff --git a/modules/flann/include/opencv2/flann/index_testing.h b/modules/flann/include/opencv2/flann/index_testing.h index f3d147588d3e43ae79b536cf94ec50d317eba358..207adef44986310e72d390a0f9670e4bf64143f5 100644 --- a/modules/flann/include/opencv2/flann/index_testing.h +++ b/modules/flann/include/opencv2/flann/index_testing.h @@ -93,7 +93,7 @@ float search_with_ground_truth(NNIndex& index, const Matrix resultSet(nn+skipMatches); diff --git a/modules/flann/include/opencv2/flann/kdtree_index.h b/modules/flann/include/opencv2/flann/kdtree_index.h index acc87a3198a8d687a82fb61662b04f2021d7810e..ea3550ad1d80391a84b8322a8fc36c852ff06c66 100644 --- a/modules/flann/include/opencv2/flann/kdtree_index.h +++ b/modules/flann/include/opencv2/flann/kdtree_index.h @@ -37,7 +37,6 @@ #include #include -#include "general.h" #include "nn_index.h" #include "dynamic_bitset.h" #include "matrix.h" diff --git a/modules/flann/include/opencv2/flann/kdtree_single_index.h b/modules/flann/include/opencv2/flann/kdtree_single_index.h index e571403b105903d89819fb656ba4b8179d134f7b..ed95c3db7d550e7ee9f50385cded659ac7c0db4c 100644 --- a/modules/flann/include/opencv2/flann/kdtree_single_index.h +++ b/modules/flann/include/opencv2/flann/kdtree_single_index.h @@ -37,7 +37,6 @@ #include #include -#include "general.h" #include "nn_index.h" #include "matrix.h" #include "result_set.h" diff --git a/modules/flann/include/opencv2/flann/kmeans_index.h b/modules/flann/include/opencv2/flann/kmeans_index.h index 6f63629d05523e8b5ecd3f4687fa7292d60ec0ac..10b272daaa0cdbb2bd4b111ad3032f776ff9c773 100644 --- a/modules/flann/include/opencv2/flann/kmeans_index.h +++ b/modules/flann/include/opencv2/flann/kmeans_index.h @@ -381,7 +381,7 @@ public: chooseCenters = &KMeansIndex::chooseCentersKMeanspp; } else { - throw FLANNException("Unknown algorithm for choosing initial centers."); + FLANN_THROW(cv::Error::StsBadArg, "Unknown algorithm for choosing initial centers."); } cb_index_ = 0.4f; @@ -453,7 +453,7 @@ public: void buildIndex() CV_OVERRIDE { if (branching_<2) { - throw FLANNException("Branching factor must be at least 2"); + FLANN_THROW(cv::Error::StsError, "Branching factor must be at least 2"); } free_indices(); @@ -570,7 +570,7 @@ public: { int numClusters = centers.rows; if (numClusters<1) { - throw FLANNException("Number of clusters must be at least 1"); + FLANN_THROW(cv::Error::StsBadArg, "Number of clusters must be at least 1"); } DistanceType variance; diff --git a/modules/flann/include/opencv2/flann/linear_index.h b/modules/flann/include/opencv2/flann/linear_index.h index 8a0f10fd86c8a58ef20937a6800240713d9750c8..6428c0d7efd94c30ed738ca7c8b3019904fffd14 100644 --- a/modules/flann/include/opencv2/flann/linear_index.h +++ b/modules/flann/include/opencv2/flann/linear_index.h @@ -33,7 +33,6 @@ //! @cond IGNORED -#include "general.h" #include "nn_index.h" namespace cvflann diff --git a/modules/flann/include/opencv2/flann/lsh_index.h b/modules/flann/include/opencv2/flann/lsh_index.h index 9ac30136ff849f67e4932a0037dcef3f66eb5835..9ff86b8b6684cae91da3e01bf34ebcad448b01f5 100644 --- a/modules/flann/include/opencv2/flann/lsh_index.h +++ b/modules/flann/include/opencv2/flann/lsh_index.h @@ -42,7 +42,6 @@ #include #include -#include "general.h" #include "nn_index.h" #include "matrix.h" #include "result_set.h" diff --git a/modules/flann/include/opencv2/flann/matrix.h b/modules/flann/include/opencv2/flann/matrix.h index 34893b72c3e99bf206ebaea42687ec4ef4259e29..fb871bd73cedc482b647eb2edb4d42219fcd5cb2 100644 --- a/modules/flann/include/opencv2/flann/matrix.h +++ b/modules/flann/include/opencv2/flann/matrix.h @@ -35,8 +35,6 @@ #include -#include "general.h" - namespace cvflann { diff --git a/modules/flann/include/opencv2/flann/nn_index.h b/modules/flann/include/opencv2/flann/nn_index.h index fbb4c7924c565558af65b2a16ec6959d780dc21b..f6e17d19fc1fa94f9b0bc274f9e1629e7a154e5c 100644 --- a/modules/flann/include/opencv2/flann/nn_index.h +++ b/modules/flann/include/opencv2/flann/nn_index.h @@ -31,7 +31,6 @@ #ifndef OPENCV_FLANN_NNINDEX_H #define OPENCV_FLANN_NNINDEX_H -#include "general.h" #include "matrix.h" #include "result_set.h" #include "params.h" diff --git a/modules/flann/include/opencv2/flann/params.h b/modules/flann/include/opencv2/flann/params.h index b8f7331905543363d0ecaef6ff7922387894d661..a7920d0b7187023dde10014411356927224afa34 100644 --- a/modules/flann/include/opencv2/flann/params.h +++ b/modules/flann/include/opencv2/flann/params.h @@ -77,7 +77,7 @@ T get_param(const IndexParams& params, cv::String name) return it->second.cast(); } else { - throw FLANNException(cv::String("Missing parameter '")+name+cv::String("' in the parameters given")); + FLANN_THROW(cv::Error::StsBadArg, cv::String("Missing parameter '")+name+cv::String("' in the parameters given")); } } diff --git a/modules/flann/include/opencv2/flann/random.h b/modules/flann/include/opencv2/flann/random.h index 3bb48b687bd0d4e3351f6c677570360f11c76273..2c1809c3a93a01fe8cea01a7f7e207f270aadb03 100644 --- a/modules/flann/include/opencv2/flann/random.h +++ b/modules/flann/include/opencv2/flann/random.h @@ -37,8 +37,6 @@ #include #include -#include "general.h" - namespace cvflann { diff --git a/modules/flann/include/opencv2/flann/saving.h b/modules/flann/include/opencv2/flann/saving.h index 53359b4b7b114b318211de5493a69ea748c8fdb9..8b3aeb7f0a89646776e0bbb8aa05eb9709e872b7 100644 --- a/modules/flann/include/opencv2/flann/saving.h +++ b/modules/flann/include/opencv2/flann/saving.h @@ -112,11 +112,11 @@ inline IndexHeader load_header(FILE* stream) size_t read_size = fread(&header,sizeof(header),1,stream); if (read_size!=(size_t)1) { - throw FLANNException("Invalid index file, cannot read"); + FLANN_THROW(cv::Error::StsError, "Invalid index file, cannot read"); } if (strcmp(header.signature,FLANN_SIGNATURE_)!=0) { - throw FLANNException("Invalid index file, wrong signature"); + FLANN_THROW(cv::Error::StsError, "Invalid index file, wrong signature"); } return header; @@ -150,7 +150,7 @@ void load_value(FILE* stream, T& value, size_t count = 1) { size_t read_cnt = fread(&value, sizeof(value), count, stream); if (read_cnt != count) { - throw FLANNException("Cannot read from file"); + FLANN_THROW(cv::Error::StsParseError, "Cannot read from file"); } } @@ -159,12 +159,12 @@ void load_value(FILE* stream, cvflann::Matrix& value) { size_t read_cnt = fread(&value, sizeof(value), 1, stream); if (read_cnt != 1) { - throw FLANNException("Cannot read from file"); + FLANN_THROW(cv::Error::StsParseError, "Cannot read from file"); } value.data = new T[value.rows*value.cols]; read_cnt = fread(value.data, sizeof(T), value.rows*value.cols, stream); if (read_cnt != (size_t)(value.rows*value.cols)) { - throw FLANNException("Cannot read from file"); + FLANN_THROW(cv::Error::StsParseError, "Cannot read from file"); } } @@ -175,12 +175,12 @@ void load_value(FILE* stream, std::vector& value) size_t size; size_t read_cnt = fread(&size, sizeof(size_t), 1, stream); if (read_cnt!=1) { - throw FLANNException("Cannot read from file"); + FLANN_THROW(cv::Error::StsError, "Cannot read from file"); } value.resize(size); read_cnt = fread(&value[0], sizeof(T), size, stream); if (read_cnt != size) { - throw FLANNException("Cannot read from file"); + FLANN_THROW(cv::Error::StsError, "Cannot read from file"); } } diff --git a/modules/flann/src/precomp.hpp b/modules/flann/src/precomp.hpp index 099a6abce1fca0231564570259c30224efa1fb8a..66de0c1a9c0d878a41b06e418125db639a2a9b78 100644 --- a/modules/flann/src/precomp.hpp +++ b/modules/flann/src/precomp.hpp @@ -13,7 +13,6 @@ #include "opencv2/flann/index_testing.h" #include "opencv2/flann/params.h" #include "opencv2/flann/saving.h" -#include "opencv2/flann/general.h" // index types #include "opencv2/flann/all_indices.h"