| 1 | #ifndef CVD_FAST_CORNER_H |
| 2 | #define CVD_FAST_CORNER_H |
| 3 | |
| 4 | #include <utility> |
| 5 | #include <vector> |
| 6 | |
| 7 | #include <cvd/byte.h> |
| 8 | #include <cvd/image.h> |
| 9 | |
| 10 | namespace CVD |
| 11 | { |
| 12 | |
| 13 | /** Perform non-maximal suppression on a set of FAST features. This cleans up |
| 14 | areas where there are multiple adjacent features, using a computed score |
| 15 | function to leave only the 'best' features. This function is typically called |
| 16 | immediately after a call to fast_corner_detect() (or one of its variants). This |
| 17 | uses the scoring function given in the paper given in @ref fast_corner_detect_9: |
| 18 | |
| 19 | @param im The image used to generate the FAST features |
| 20 | @param corners The FAST features previously detected (e.g. by calling fast_corner_detect()) |
| 21 | @param barrier The barrier used to calculate the score, which should be the same as that passed to fast_corner_detect() |
| 22 | @param max_corners Vector to be filled with the new list of locally maximal corners. |
| 23 | @ingroup gVision |
| 24 | */ |
| 25 | void fast_nonmax(const BasicImage<byte>& im, const std::vector<ImageRef>& corners, int barrier, std::vector<ImageRef>& max_corners); |
| 26 | |
| 27 | /** Perform non-maximal suppression on a set of FAST features, also returning |
| 28 | the score for each remaining corner. This function cleans up areas where |
| 29 | there are multiple adjacent features, using a computed score function to leave |
| 30 | only the 'best' features. This function is typically called immediately after |
| 31 | a call to fast_corner_detect() (or one of its variants). |
| 32 | |
| 33 | @param im The image used to generate the FAST features |
| 34 | @param corners The FAST features previously detected (e.g. by calling fast_corner_detect()) |
| 35 | @param barrier The barrier used to calculate the score, which should be the same as that passed to fast_corner_detect() |
| 36 | @param max_corners Vector to be filled with the new list of |
| 37 | locally maximal corners, and their scores. |
| 38 | <code>non_maxcorners[i].first</code> gives the location and |
| 39 | <code>non_maxcorners[i].second</code> gives the score (higher is better). |
| 40 | |
| 41 | @ingroup gVision |
| 42 | */ |
| 43 | void fast_nonmax_with_scores(const BasicImage<byte>& im, const std::vector<ImageRef>& corners, int barrier, std::vector<std::pair<ImageRef, int>>& max_corners); |
| 44 | |
| 45 | /// Perform tree based 7 point FAST feature detection. This is more like an edge detector. |
| 46 | /// If you use this, please cite the paper given in @ref fast_corner_detect_9 |
| 47 | /// |
| 48 | /// @param im The input image |
| 49 | /// @param corners The resulting container of corner locations |
| 50 | /// @param barrier Corner detection threshold |
| 51 | /// @ingroup gVision |
| 52 | void fast_corner_detect_7(const BasicImage<byte>& im, std::vector<ImageRef>& corners, int barrier); |
| 53 | |
| 54 | /// Compute the 7 point score (as the maximum threshold at which the point will still be detected) for |
| 55 | /// a std::vector of features. |
| 56 | /// |
| 57 | /// @param im The input image |
| 58 | /// @param corners The resulting container of corner locations |
| 59 | /// @param barrier Initial corner detection threshold. Using the same threshold as for corner detection will produce the |
| 60 | /// quickest results, but any lower value (e.g. 0) will produce correct results. |
| 61 | /// @ingroup gVision |
| 62 | void fast_corner_score_7(const BasicImage<byte>& i, const std::vector<ImageRef>& corners, int b, std::vector<int>& scores); |
| 63 | |
| 64 | /// Perform tree based 8 point FAST feature detection. This is more like an edge detector. |
| 65 | /// If you use this, please cite the paper given in @ref fast_corner_detect_9 |
| 66 | /// |
| 67 | /// @param im The input image |
| 68 | /// @param corners The resulting container of corner locations |
| 69 | /// @param barrier Corner detection threshold |
| 70 | /// @ingroup gVision |
| 71 | void fast_corner_detect_8(const BasicImage<byte>& im, std::vector<ImageRef>& corners, int barrier); |
| 72 | |
| 73 | /// Compute the 8 point score (as the maximum threshold at which the point will still be detected) for |
| 74 | /// a std::vector of features. |
| 75 | /// |
| 76 | /// @param im The input image |
| 77 | /// @param corners The resulting container of corner locations |
| 78 | /// @param barrier Initial corner detection threshold. Using the same threshold as for corner detection will produce the |
| 79 | /// quickest results, but any lower value (e.g. 0) will produce correct results. |
| 80 | /// @ingroup gVision |
| 81 | void fast_corner_score_8(const BasicImage<byte>& i, const std::vector<ImageRef>& corners, int b, std::vector<int>& scores); |
| 82 | |
| 83 | /** Perform tree based 9 point FAST feature detection as described in: |
| 84 | Machine Learning for High Speed Corner Detection, E. Rosten and T. Drummond. |
| 85 | Results show that this is both the fastest and the best of the detectors. |
| 86 | If you use this in published work, please cite: |
| 87 | |
| 88 | \verbatim |
| 89 | @inproceedings{rosten2006machine, |
| 90 | title = "Machine Learning for High Speed Corner Detection", |
| 91 | author = "Edward Rosten and Tom Drummond", |
| 92 | year = "2006", |
| 93 | month = "May", |
| 94 | booktitle = "9th European Conference on Computer Vision", |
| 95 | } |
| 96 | \endverbatim |
| 97 | |
| 98 | @param im The input image |
| 99 | @param corners The resulting container of corner locations |
| 100 | @param barrier Corner detection threshold |
| 101 | @ingroup gVision |
| 102 | **/ |
| 103 | void fast_corner_detect_9(const BasicImage<byte>& im, std::vector<ImageRef>& corners, int barrier); |
| 104 | |
| 105 | /// Compute the 9 point score (as the maximum threshold at which the point will still be detected) for |
| 106 | /// a std::vector of features. |
| 107 | /// |
| 108 | /// @param im The input image |
| 109 | /// @param corners The resulting container of corner locations |
| 110 | /// @param barrier Initial corner detection threshold. Using the same threshold as for corner detection will produce the |
| 111 | /// quickest results, but any lower value (e.g. 0) will produce correct results. |
| 112 | /// @ingroup gVision |
| 113 | void fast_corner_score_9(const BasicImage<byte>& i, const std::vector<ImageRef>& corners, int b, std::vector<int>& scores); |
| 114 | |
| 115 | ///Perform FAST-9 corner detection (see @ref fast_corner_detect_9), with nonmaximal |
| 116 | ///suppression (see @ref fast_corner_score_9 and @ref nonmax_suppression) |
| 117 | /// |
| 118 | /// @param im The input image |
| 119 | /// @param corners The resulting container of locally maximal corner locations |
| 120 | /// @param barrier Corner detection threshold |
| 121 | /// @ingroup gVision |
| 122 | void fast_corner_detect_9_nonmax(const BasicImage<byte>& im, std::vector<ImageRef>& max_corners, int barrier); |
| 123 | |
| 124 | /// Perform tree based 10 point FAST feature detection |
| 125 | /// If you use this, please cite the paper given in @ref fast_corner_detect |
| 126 | /// |
| 127 | /// @param im The input image |
| 128 | /// @param corners The resulting container of corner locations |
| 129 | /// @param barrier Corner detection threshold |
| 130 | /// @ingroup gVision |
| 131 | void fast_corner_detect_10(const BasicImage<byte>& im, std::vector<ImageRef>& corners, int barrier); |
| 132 | |
| 133 | /// Compute the 10 point score (as the maximum threshold at which the point will still be detected) for |
| 134 | /// a std::vector of features. |
| 135 | /// |
| 136 | /// @param im The input image |
| 137 | /// @param corners The resulting container of corner locations |
| 138 | /// @param barrier Initial corner detection threshold. Using the same threshold as for corner detection will produce the |
| 139 | /// quickest results, but any lower value (e.g. 0) will produce correct results. |
| 140 | /// @ingroup gVision |
| 141 | void fast_corner_score_10(const BasicImage<byte>& i, const std::vector<ImageRef>& corners, int b, std::vector<int>& scores); |
| 142 | |
| 143 | /// Perform tree based 11 point FAST feature detection |
| 144 | /// If you use this, please cite the paper given in @ref fast_corner_detect_9 |
| 145 | /// |
| 146 | /// @param im The input image |
| 147 | /// @param corners The resulting container of corner locations |
| 148 | /// @param barrier Corner detection threshold |
| 149 | /// @ingroup gVision |
| 150 | void fast_corner_detect_11(const BasicImage<byte>& im, std::vector<ImageRef>& corners, int barrier); |
| 151 | |
| 152 | /// Compute the 11 point score (as the maximum threshold at which the point will still be detected) for |
| 153 | /// a std::vector of features. |
| 154 | /// |
| 155 | /// @param im The input image |
| 156 | /// @param corners The resulting container of corner locations |
| 157 | /// @param barrier Initial corner detection threshold. Using the same threshold as for corner detection will produce the |
| 158 | /// quickest results, but any lower value (e.g. 0) will produce correct results. |
| 159 | /// @ingroup gVision |
| 160 | void fast_corner_score_11(const BasicImage<byte>& i, const std::vector<ImageRef>& corners, int b, std::vector<int>& scores); |
| 161 | |
| 162 | /// Perform tree based 12 point FAST feature detection |
| 163 | /// If you use this, please cite the paper given in @ref fast_corner_detect_9 |
| 164 | /// |
| 165 | /// @param im The input image |
| 166 | /// @param corners The resulting container of corner locations |
| 167 | /// @param barrier Corner detection threshold |
| 168 | /// @ingroup gVision |
| 169 | void fast_corner_detect_12(const BasicImage<byte>& im, std::vector<ImageRef>& corners, int barrier); |
| 170 | |
| 171 | /// Compute the 11 point score (as the maximum threshold at which the point will still be detected) for |
| 172 | /// a std::vector of features. |
| 173 | /// |
| 174 | /// @param im The input image |
| 175 | /// @param corners The resulting container of corner locations |
| 176 | /// @param barrier Initial corner detection threshold. Using the same threshold as for corner detection will produce the |
| 177 | /// quickest results, but any lower value (e.g. 0) will produce correct results. |
| 178 | /// @ingroup gVision |
| 179 | void fast_corner_score_12(const BasicImage<byte>& i, const std::vector<ImageRef>& corners, int b, std::vector<int>& scores); |
| 180 | |
| 181 | /// The 16 offsets from the centre pixel used in FAST feature detection. |
| 182 | /// |
| 183 | /// @ingroup gVision |
| 184 | extern const ImageRef fast_pixel_ring[16]; |
| 185 | } |
| 186 | |
| 187 | #endif |