Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef OPENCV_FLANN_DATASET_H_
00032 #define OPENCV_FLANN_DATASET_H_
00033
00034 #include <stdio.h>
00035
00036 #include "general.h"
00037
00038 namespace cvflann
00039 {
00040
00045 template <typename T>
00046 class Matrix
00047 {
00048 public:
00049 typedef T type;
00050
00051 size_t rows;
00052 size_t cols;
00053 size_t stride;
00054 T* data;
00055
00056 Matrix() : rows(0), cols(0), stride(0), data(NULL)
00057 {
00058 }
00059
00060 Matrix(T* data_, size_t rows_, size_t cols_, size_t stride_ = 0) :
00061 rows(rows_), cols(cols_), stride(stride_), data(data_)
00062 {
00063 if (stride==0) stride = cols;
00064 }
00065
00069 FLANN_DEPRECATED void free()
00070 {
00071 fprintf(stderr, "The cvflann::Matrix<T>::free() method is deprecated "
00072 "and it does not do any memory deallocation any more. You are"
00073 "responsible for deallocating the matrix memory (by doing"
00074 "'delete[] matrix.data' for example)");
00075 }
00076
00080 T* operator[](size_t index) const
00081 {
00082 return data+index*stride;
00083 }
00084 };
00085
00086
00087 class UntypedMatrix
00088 {
00089 public:
00090 size_t rows;
00091 size_t cols;
00092 void* data;
00093 flann_datatype_t type;
00094
00095 UntypedMatrix(void* data_, long rows_, long cols_) :
00096 rows(rows_), cols(cols_), data(data_)
00097 {
00098 }
00099
00100 ~UntypedMatrix()
00101 {
00102 }
00103
00104
00105 template<typename T>
00106 Matrix<T> as()
00107 {
00108 return Matrix<T>((T*)data, rows, cols);
00109 }
00110 };
00111
00112
00113
00114 }
00115
00116 #endif //OPENCV_FLANN_DATASET_H_