You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

261 lines
8.9 KiB

8 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. /** @file covdet.h
  2. ** @brief Covariant feature detectors (@ref covdet)
  3. ** @author Karel Lenc
  4. ** @author Andrea Vedaldi
  5. ** @author Michal Perdoch
  6. **/
  7. /*
  8. Copyright (C) 2013-14 Andrea Vedaldi.
  9. Copyright (C) 2012 Karel Lenc, Andrea Vedaldi and Michal Perdoch.
  10. All rights reserved.
  11. This file is part of the VLFeat library and is made available under
  12. the terms of the BSD license (see the COPYING file).
  13. */
  14. #ifndef VL_COVDET_H
  15. #define VL_COVDET_H
  16. #include "generic.h"
  17. #include "stringop.h"
  18. #include "scalespace.h"
  19. #include <stdio.h>
  20. /* ---------------------------------------------------------------- */
  21. /* Feature Frames */
  22. /* ---------------------------------------------------------------- */
  23. /** @name Feature frames
  24. ** @{ */
  25. /** @brief Types of feature frames */
  26. typedef enum _VlFrameType {
  27. VL_FRAMETYPE_DISC = 1, /**< A disc. */
  28. VL_FRAMETYPE_ORIENTED_DISC, /**< An oriented disc. */
  29. VL_FRAMETYPE_ELLIPSE, /**< An ellipse. */
  30. VL_FRAMETYPE_ORIENTED_ELLIPSE, /**< An oriented ellipse. */
  31. VL_FRAMETYPE_NUM
  32. } VlFrameType ;
  33. /** @brief Names of the frame types */
  34. VL_EXPORT const char* vlFrameNames [VL_FRAMETYPE_NUM] ;
  35. /** @brief Mapping between string values and VlFrameType values */
  36. VL_EXPORT VlEnumerator vlFrameTypes [VL_FRAMETYPE_NUM] ;
  37. /** @brief Disc feature frame */
  38. typedef struct _VlFrameDisc
  39. {
  40. float x ; /**< center x-coordinate */
  41. float y ; /**< center y-coordinate */
  42. float sigma ; /**< radius or scale */
  43. } VlFrameDisc ;
  44. /** @brief Oriented disc feature frame
  45. ** An upright frame has @c angle equal to zero.
  46. **/
  47. typedef struct _VlFrameOrientedDisc {
  48. float x ; /**< center x-coordinate */
  49. float y ; /**< center y-coordinate */
  50. float sigma ; /**< radius or scale */
  51. float angle ; /**< rotation angle (rad) */
  52. } VlFrameOrientedDisc ;
  53. /** @brief Ellipse feature frame */
  54. typedef struct _VlFrameEllipse {
  55. float x ; /**< center x-coordinate */
  56. float y ; /**< center y-coordinate */
  57. float e11 ; /**< */
  58. float e12 ;
  59. float e22 ;
  60. } VlFrameEllipse ;
  61. /** @brief Oriented ellipse feature frame
  62. ** The affine transformation transforms the ellipse shape into
  63. ** a circular region. */
  64. typedef struct _VlFrameOrientedEllipse {
  65. float x ; /**< center x-coordinate */
  66. float y ; /**< center y-coordinate */
  67. float a11 ; /**< */
  68. float a12 ;
  69. float a21 ;
  70. float a22 ;
  71. } VlFrameOrientedEllipse;
  72. /** @brief Get the size of a frame structure
  73. ** @param frameType identifier of the type of frame.
  74. ** @return size of the corresponding frame structure in bytes.
  75. **/
  76. VL_INLINE vl_size
  77. vl_get_frame_size (VlFrameType frameType) {
  78. switch (frameType) {
  79. case VL_FRAMETYPE_DISC: return sizeof(VlFrameDisc);
  80. case VL_FRAMETYPE_ORIENTED_DISC: return sizeof(VlFrameOrientedDisc);
  81. case VL_FRAMETYPE_ELLIPSE: return sizeof(VlFrameEllipse);
  82. case VL_FRAMETYPE_ORIENTED_ELLIPSE: return sizeof(VlFrameOrientedEllipse);
  83. default:
  84. assert(0);
  85. break;
  86. }
  87. return 0;
  88. }
  89. /** @brief Get the size of a frame structure
  90. ** @param affineAdaptation whether the detector use affine adaptation.
  91. ** @param orientation whether the detector estimates the feature orientation.
  92. ** @return the type of extracted frame.
  93. **
  94. ** Depedning on whether the detector estimate the affine shape
  95. ** and orientation of a feature, different frame types
  96. ** are extracted. */
  97. VL_INLINE VlFrameType
  98. vl_get_frame_type (vl_bool affineAdaptation, vl_bool orientation)
  99. {
  100. if (affineAdaptation) {
  101. if (orientation) {
  102. return VL_FRAMETYPE_ORIENTED_ELLIPSE;
  103. } else {
  104. return VL_FRAMETYPE_ELLIPSE;
  105. }
  106. } else {
  107. if (orientation) {
  108. return VL_FRAMETYPE_ORIENTED_DISC;
  109. } else {
  110. return VL_FRAMETYPE_DISC;
  111. }
  112. }
  113. }
  114. /* ---------------------------------------------------------------- */
  115. /* Covariant Feature Detector */
  116. /* ---------------------------------------------------------------- */
  117. /** @brief A detected feature shape and location */
  118. typedef struct _VlCovDetFeature
  119. {
  120. VlFrameOrientedEllipse frame ; /**< feature frame. */
  121. float peakScore ; /**< peak score. */
  122. float edgeScore ; /**< edge score. */
  123. float orientationScore ; /**< orientation score. */
  124. float laplacianScaleScore ; /**< Laplacian scale score. */
  125. } VlCovDetFeature ;
  126. /** @brief A detected feature orientation */
  127. typedef struct _VlCovDetFeatureOrientation
  128. {
  129. double angle ;
  130. double score ;
  131. } VlCovDetFeatureOrientation ;
  132. /** @brief A detected feature Laplacian scale */
  133. typedef struct _VlCovDetFeatureLaplacianScale
  134. {
  135. double scale ;
  136. double score ;
  137. } VlCovDetFeatureLaplacianScale ;
  138. /** @brief Covariant feature detection method */
  139. typedef enum _VlCovDetMethod
  140. {
  141. VL_COVDET_METHOD_DOG = 1,
  142. VL_COVDET_METHOD_HESSIAN,
  143. VL_COVDET_METHOD_HESSIAN_LAPLACE,
  144. VL_COVDET_METHOD_HARRIS_LAPLACE,
  145. VL_COVDET_METHOD_MULTISCALE_HESSIAN,
  146. VL_COVDET_METHOD_MULTISCALE_HARRIS,
  147. VL_COVDET_METHOD_NUM
  148. } VlCovDetMethod;
  149. /** @brief Mapping between strings and ::VlCovDetMethod values */
  150. VL_EXPORT VlEnumerator vlCovdetMethods [VL_COVDET_METHOD_NUM] ;
  151. #ifdef __DOXYGEN__
  152. /** @brief Covariant feature detector
  153. ** @see @ref covdet */
  154. struct _VlCovDet { }
  155. #endif
  156. /** @brief Covariant feature detector
  157. ** @see @ref covdet */
  158. typedef struct _VlCovDet VlCovDet ;
  159. /** @name Create and destroy
  160. ** @{ */
  161. VL_EXPORT VlCovDet * vl_covdet_new (VlCovDetMethod method) ;
  162. VL_EXPORT void vl_covdet_delete (VlCovDet * self) ;
  163. VL_EXPORT void vl_covdet_reset (VlCovDet * self) ;
  164. /** @} */
  165. /** @name Process data
  166. ** @{ */
  167. VL_EXPORT int vl_covdet_put_image (VlCovDet * self,
  168. float const * image,
  169. vl_size width, vl_size height) ;
  170. VL_EXPORT void vl_covdet_detect (VlCovDet * self) ;
  171. VL_EXPORT int vl_covdet_append_feature (VlCovDet * self, VlCovDetFeature const * feature) ;
  172. VL_EXPORT void vl_covdet_extract_orientations (VlCovDet * self) ;
  173. VL_EXPORT void vl_covdet_extract_laplacian_scales (VlCovDet * self) ;
  174. VL_EXPORT void vl_covdet_extract_affine_shape (VlCovDet * self) ;
  175. VL_EXPORT VlCovDetFeatureOrientation *
  176. vl_covdet_extract_orientations_for_frame (VlCovDet * self,
  177. vl_size *numOrientations,
  178. VlFrameOrientedEllipse frame) ;
  179. VL_EXPORT VlCovDetFeatureLaplacianScale *
  180. vl_covdet_extract_laplacian_scales_for_frame (VlCovDet * self,
  181. vl_size * numScales,
  182. VlFrameOrientedEllipse frame) ;
  183. VL_EXPORT int
  184. vl_covdet_extract_affine_shape_for_frame (VlCovDet * self,
  185. VlFrameOrientedEllipse * adapted,
  186. VlFrameOrientedEllipse frame) ;
  187. VL_EXPORT vl_bool
  188. vl_covdet_extract_patch_for_frame (VlCovDet * self, float * patch,
  189. vl_size resolution,
  190. double extent,
  191. double sigma,
  192. VlFrameOrientedEllipse frame) ;
  193. VL_EXPORT void
  194. vl_covdet_drop_features_outside (VlCovDet * self, double margin) ;
  195. /** @} */
  196. /** @name Retrieve data and parameters
  197. ** @{ */
  198. VL_EXPORT vl_size vl_covdet_get_num_features (VlCovDet const * self) ;
  199. VL_EXPORT void * vl_covdet_get_features (VlCovDet * self) ;
  200. VL_EXPORT vl_index vl_covdet_get_first_octave (VlCovDet const * self) ;
  201. VL_EXPORT vl_size vl_covdet_get_octave_resolution (VlCovDet const * self) ;
  202. VL_EXPORT double vl_covdet_get_peak_threshold (VlCovDet const * self) ;
  203. VL_EXPORT double vl_covdet_get_edge_threshold (VlCovDet const * self) ;
  204. VL_EXPORT double vl_covdeg_get_laplacian_peak_threshold (VlCovDet const * self) ;
  205. VL_EXPORT vl_bool vl_covdet_get_transposed (VlCovDet const * self) ;
  206. VL_EXPORT VlScaleSpace * vl_covdet_get_gss (VlCovDet const * self) ;
  207. VL_EXPORT VlScaleSpace * vl_covdet_get_css (VlCovDet const * self) ;
  208. VL_EXPORT vl_bool vl_covdet_get_aa_accurate_smoothing (VlCovDet const * self) ;
  209. VL_EXPORT vl_size const * vl_covdet_get_laplacian_scales_statistics (VlCovDet const * self, vl_size * numScales) ;
  210. VL_EXPORT double vl_covdet_get_non_extrema_suppression_threshold (VlCovDet const * self) ;
  211. VL_EXPORT vl_size vl_covdet_get_num_non_extrema_suppressed (VlCovDet const * self) ;
  212. /** @} */
  213. /** @name Set parameters
  214. ** @{ */
  215. VL_EXPORT void vl_covdet_set_first_octave (VlCovDet * self, vl_index o) ;
  216. VL_EXPORT void vl_covdet_set_octave_resolution (VlCovDet * self, vl_size r) ;
  217. VL_EXPORT void vl_covdet_set_peak_threshold (VlCovDet * self, double peakThreshold) ;
  218. VL_EXPORT void vl_covdet_set_edge_threshold (VlCovDet * self, double edgeThreshold) ;
  219. VL_EXPORT void vl_covdet_set_laplacian_peak_threshold (VlCovDet * self, double peakThreshold) ;
  220. VL_EXPORT void vl_covdet_set_transposed (VlCovDet * self, vl_bool t) ;
  221. VL_EXPORT void vl_covdet_set_aa_accurate_smoothing (VlCovDet * self, vl_bool x) ;
  222. VL_EXPORT void vl_covdet_set_non_extrema_suppression_threshold (VlCovDet * self, double x) ;
  223. /** @} */
  224. /* VL_COVDET_H */
  225. #endif