openCV library for Renesas RZ/A
Dependents: RZ_A2M_Mbed_samples
include/opencv2/flann/matrix.h@0:0e0631af0305, 2021-01-29 (annotated)
- Committer:
- RyoheiHagimoto
- Date:
- Fri Jan 29 04:53:38 2021 +0000
- Revision:
- 0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RyoheiHagimoto | 0:0e0631af0305 | 1 | /*********************************************************************** |
RyoheiHagimoto | 0:0e0631af0305 | 2 | * Software License Agreement (BSD License) |
RyoheiHagimoto | 0:0e0631af0305 | 3 | * |
RyoheiHagimoto | 0:0e0631af0305 | 4 | * Copyright 2008-2009 Marius Muja (mariusm@cs.ubc.ca). All rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 5 | * Copyright 2008-2009 David G. Lowe (lowe@cs.ubc.ca). All rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 6 | * |
RyoheiHagimoto | 0:0e0631af0305 | 7 | * THE BSD LICENSE |
RyoheiHagimoto | 0:0e0631af0305 | 8 | * |
RyoheiHagimoto | 0:0e0631af0305 | 9 | * Redistribution and use in source and binary forms, with or without |
RyoheiHagimoto | 0:0e0631af0305 | 10 | * modification, are permitted provided that the following conditions |
RyoheiHagimoto | 0:0e0631af0305 | 11 | * are met: |
RyoheiHagimoto | 0:0e0631af0305 | 12 | * |
RyoheiHagimoto | 0:0e0631af0305 | 13 | * 1. Redistributions of source code must retain the above copyright |
RyoheiHagimoto | 0:0e0631af0305 | 14 | * notice, this list of conditions and the following disclaimer. |
RyoheiHagimoto | 0:0e0631af0305 | 15 | * 2. Redistributions in binary form must reproduce the above copyright |
RyoheiHagimoto | 0:0e0631af0305 | 16 | * notice, this list of conditions and the following disclaimer in the |
RyoheiHagimoto | 0:0e0631af0305 | 17 | * documentation and/or other materials provided with the distribution. |
RyoheiHagimoto | 0:0e0631af0305 | 18 | * |
RyoheiHagimoto | 0:0e0631af0305 | 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
RyoheiHagimoto | 0:0e0631af0305 | 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
RyoheiHagimoto | 0:0e0631af0305 | 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
RyoheiHagimoto | 0:0e0631af0305 | 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
RyoheiHagimoto | 0:0e0631af0305 | 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
RyoheiHagimoto | 0:0e0631af0305 | 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
RyoheiHagimoto | 0:0e0631af0305 | 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
RyoheiHagimoto | 0:0e0631af0305 | 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
RyoheiHagimoto | 0:0e0631af0305 | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
RyoheiHagimoto | 0:0e0631af0305 | 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
RyoheiHagimoto | 0:0e0631af0305 | 29 | *************************************************************************/ |
RyoheiHagimoto | 0:0e0631af0305 | 30 | |
RyoheiHagimoto | 0:0e0631af0305 | 31 | #ifndef OPENCV_FLANN_DATASET_H_ |
RyoheiHagimoto | 0:0e0631af0305 | 32 | #define OPENCV_FLANN_DATASET_H_ |
RyoheiHagimoto | 0:0e0631af0305 | 33 | |
RyoheiHagimoto | 0:0e0631af0305 | 34 | #include <stdio.h> |
RyoheiHagimoto | 0:0e0631af0305 | 35 | |
RyoheiHagimoto | 0:0e0631af0305 | 36 | #include "general.h" |
RyoheiHagimoto | 0:0e0631af0305 | 37 | |
RyoheiHagimoto | 0:0e0631af0305 | 38 | namespace cvflann |
RyoheiHagimoto | 0:0e0631af0305 | 39 | { |
RyoheiHagimoto | 0:0e0631af0305 | 40 | |
RyoheiHagimoto | 0:0e0631af0305 | 41 | /** |
RyoheiHagimoto | 0:0e0631af0305 | 42 | * Class that implements a simple rectangular matrix stored in a memory buffer and |
RyoheiHagimoto | 0:0e0631af0305 | 43 | * provides convenient matrix-like access using the [] operators. |
RyoheiHagimoto | 0:0e0631af0305 | 44 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 45 | template <typename T> |
RyoheiHagimoto | 0:0e0631af0305 | 46 | class Matrix |
RyoheiHagimoto | 0:0e0631af0305 | 47 | { |
RyoheiHagimoto | 0:0e0631af0305 | 48 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 49 | typedef T type; |
RyoheiHagimoto | 0:0e0631af0305 | 50 | |
RyoheiHagimoto | 0:0e0631af0305 | 51 | size_t rows; |
RyoheiHagimoto | 0:0e0631af0305 | 52 | size_t cols; |
RyoheiHagimoto | 0:0e0631af0305 | 53 | size_t stride; |
RyoheiHagimoto | 0:0e0631af0305 | 54 | T* data; |
RyoheiHagimoto | 0:0e0631af0305 | 55 | |
RyoheiHagimoto | 0:0e0631af0305 | 56 | Matrix() : rows(0), cols(0), stride(0), data(NULL) |
RyoheiHagimoto | 0:0e0631af0305 | 57 | { |
RyoheiHagimoto | 0:0e0631af0305 | 58 | } |
RyoheiHagimoto | 0:0e0631af0305 | 59 | |
RyoheiHagimoto | 0:0e0631af0305 | 60 | Matrix(T* data_, size_t rows_, size_t cols_, size_t stride_ = 0) : |
RyoheiHagimoto | 0:0e0631af0305 | 61 | rows(rows_), cols(cols_), stride(stride_), data(data_) |
RyoheiHagimoto | 0:0e0631af0305 | 62 | { |
RyoheiHagimoto | 0:0e0631af0305 | 63 | if (stride==0) stride = cols; |
RyoheiHagimoto | 0:0e0631af0305 | 64 | } |
RyoheiHagimoto | 0:0e0631af0305 | 65 | |
RyoheiHagimoto | 0:0e0631af0305 | 66 | /** |
RyoheiHagimoto | 0:0e0631af0305 | 67 | * Convenience function for deallocating the storage data. |
RyoheiHagimoto | 0:0e0631af0305 | 68 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 69 | FLANN_DEPRECATED void free() |
RyoheiHagimoto | 0:0e0631af0305 | 70 | { |
RyoheiHagimoto | 0:0e0631af0305 | 71 | fprintf(stderr, "The cvflann::Matrix<T>::free() method is deprecated " |
RyoheiHagimoto | 0:0e0631af0305 | 72 | "and it does not do any memory deallocation any more. You are" |
RyoheiHagimoto | 0:0e0631af0305 | 73 | "responsible for deallocating the matrix memory (by doing" |
RyoheiHagimoto | 0:0e0631af0305 | 74 | "'delete[] matrix.data' for example)"); |
RyoheiHagimoto | 0:0e0631af0305 | 75 | } |
RyoheiHagimoto | 0:0e0631af0305 | 76 | |
RyoheiHagimoto | 0:0e0631af0305 | 77 | /** |
RyoheiHagimoto | 0:0e0631af0305 | 78 | * Operator that return a (pointer to a) row of the data. |
RyoheiHagimoto | 0:0e0631af0305 | 79 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 80 | T* operator[](size_t index) const |
RyoheiHagimoto | 0:0e0631af0305 | 81 | { |
RyoheiHagimoto | 0:0e0631af0305 | 82 | return data+index*stride; |
RyoheiHagimoto | 0:0e0631af0305 | 83 | } |
RyoheiHagimoto | 0:0e0631af0305 | 84 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 85 | |
RyoheiHagimoto | 0:0e0631af0305 | 86 | |
RyoheiHagimoto | 0:0e0631af0305 | 87 | class UntypedMatrix |
RyoheiHagimoto | 0:0e0631af0305 | 88 | { |
RyoheiHagimoto | 0:0e0631af0305 | 89 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 90 | size_t rows; |
RyoheiHagimoto | 0:0e0631af0305 | 91 | size_t cols; |
RyoheiHagimoto | 0:0e0631af0305 | 92 | void* data; |
RyoheiHagimoto | 0:0e0631af0305 | 93 | flann_datatype_t type; |
RyoheiHagimoto | 0:0e0631af0305 | 94 | |
RyoheiHagimoto | 0:0e0631af0305 | 95 | UntypedMatrix(void* data_, long rows_, long cols_) : |
RyoheiHagimoto | 0:0e0631af0305 | 96 | rows(rows_), cols(cols_), data(data_) |
RyoheiHagimoto | 0:0e0631af0305 | 97 | { |
RyoheiHagimoto | 0:0e0631af0305 | 98 | } |
RyoheiHagimoto | 0:0e0631af0305 | 99 | |
RyoheiHagimoto | 0:0e0631af0305 | 100 | ~UntypedMatrix() |
RyoheiHagimoto | 0:0e0631af0305 | 101 | { |
RyoheiHagimoto | 0:0e0631af0305 | 102 | } |
RyoheiHagimoto | 0:0e0631af0305 | 103 | |
RyoheiHagimoto | 0:0e0631af0305 | 104 | |
RyoheiHagimoto | 0:0e0631af0305 | 105 | template<typename T> |
RyoheiHagimoto | 0:0e0631af0305 | 106 | Matrix<T> as() |
RyoheiHagimoto | 0:0e0631af0305 | 107 | { |
RyoheiHagimoto | 0:0e0631af0305 | 108 | return Matrix<T>((T*)data, rows, cols); |
RyoheiHagimoto | 0:0e0631af0305 | 109 | } |
RyoheiHagimoto | 0:0e0631af0305 | 110 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 111 | |
RyoheiHagimoto | 0:0e0631af0305 | 112 | |
RyoheiHagimoto | 0:0e0631af0305 | 113 | |
RyoheiHagimoto | 0:0e0631af0305 | 114 | } |
RyoheiHagimoto | 0:0e0631af0305 | 115 | |
RyoheiHagimoto | 0:0e0631af0305 | 116 | #endif //OPENCV_FLANN_DATASET_H_ |