nnIndex = new LshIndex<Distance>(dataset, params, distance);
break;
default:
- throw FLANNException("Unknown index type");
+ FLANN_THROW(cv::Error::StsBadArg, "Unknown index type");
}
return nnIndex;
nnIndex = new LshIndex<Distance>(dataset, params, distance);
break;
default:
- throw FLANNException("Unknown index type");
+ FLANN_THROW(cv::Error::StsBadArg, "Unknown index type");
}
return nnIndex;
nnIndex = new LshIndex<Distance>(dataset, params, distance);
break;
default:
- throw FLANNException("Unknown index type");
+ FLANN_THROW(cv::Error::StsBadArg, "Unknown index type");
}
return nnIndex;
#include <sstream>
-#include "general.h"
#include "nn_index.h"
#include "ground_truth.h"
#include "index_testing.h"
//! @cond IGNORED
-#include "general.h"
#include "nn_index.h"
#include "kdtree_index.h"
#include "kmeans_index.h"
IndexHeader header = load_header(fin);
if (header.data_type != Datatype<ElementType>::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;
{
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);
#ifndef OPENCV_FLANN_GENERAL_H_
#define OPENCV_FLANN_GENERAL_H_
+#if CV_VERSION_MAJOR <= 4
+
//! @cond IGNORED
#include "opencv2/core.hpp"
}
+#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_ */
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_];
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();
if (matches.cols<size_t(nn)) {
Logger::info("matches.cols=%d, nn=%d\n",matches.cols,nn);
- throw FLANNException("Ground truth is not computed for as many neighbors as requested");
+ FLANN_THROW(cv::Error::StsError, "Ground truth is not computed for as many neighbors as requested");
}
KNNResultSet<DistanceType> resultSet(nn+skipMatches);
#include <map>
#include <cstring>
-#include "general.h"
#include "nn_index.h"
#include "dynamic_bitset.h"
#include "matrix.h"
#include <map>
#include <cstring>
-#include "general.h"
#include "nn_index.h"
#include "matrix.h"
#include "result_set.h"
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;
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();
{
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;
//! @cond IGNORED
-#include "general.h"
#include "nn_index.h"
namespace cvflann
#include <map>
#include <vector>
-#include "general.h"
#include "nn_index.h"
#include "matrix.h"
#include "result_set.h"
#include <stdio.h>
-#include "general.h"
-
namespace cvflann
{
#ifndef OPENCV_FLANN_NNINDEX_H
#define OPENCV_FLANN_NNINDEX_H
-#include "general.h"
#include "matrix.h"
#include "result_set.h"
#include "params.h"
return it->second.cast<T>();
}
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"));
}
}
#include <cstdlib>
#include <vector>
-#include "general.h"
-
namespace cvflann
{
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;
{
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");
}
}
{
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");
}
}
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");
}
}
#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"