structured_edge_detection.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. // By downloading, copying, installing or using the software you agree to this license.
  6. // If you do not agree to this license, do not download, install,
  7. // copy or use the software.
  8. //
  9. //
  10. // License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
  14. // Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved.
  15. // Third party copyrights are property of their respective owners.
  16. //
  17. // Redistribution and use in source and binary forms, with or without modification,
  18. // are permitted provided that the following conditions are met:
  19. //
  20. // * Redistribution's of source code must retain the above copyright notice,
  21. // this list of conditions and the following disclaimer.
  22. //
  23. // * Redistribution's in binary form must reproduce the above copyright notice,
  24. // this list of conditions and the following disclaimer in the documentation
  25. // and/or other materials provided with the distribution.
  26. //
  27. // * The name of the copyright holders may not be used to endorse or promote products
  28. // derived from this software without specific prior written permission.
  29. //
  30. // This software is provided by the copyright holders and contributors "as is" and
  31. // any express or implied warranties, including, but not limited to, the implied
  32. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  33. // In no event shall the Intel Corporation or contributors be liable for any direct,
  34. // indirect, incidental, special, exemplary, or consequential damages
  35. // (including, but not limited to, procurement of substitute goods or services;
  36. // loss of use, data, or profits; or business interruption) however caused
  37. // and on any theory of liability, whether in contract, strict liability,
  38. // or tort (including negligence or otherwise) arising in any way out of
  39. // the use of this software, even if advised of the possibility of such damage.
  40. //
  41. //M*/
  42. #ifndef __OPENCV_STRUCTURED_EDGE_DETECTION_HPP__
  43. #define __OPENCV_STRUCTURED_EDGE_DETECTION_HPP__
  44. #ifdef __cplusplus
  45. /** @file
  46. @date Jun 17, 2014
  47. @author Yury Gitman
  48. */
  49. #include <opencv2/core.hpp>
  50. namespace cv
  51. {
  52. namespace ximgproc
  53. {
  54. //! @addtogroup ximgproc_edge
  55. //! @{
  56. /*!
  57. Helper class for training part of [P. Dollar and C. L. Zitnick. Structured Forests for Fast Edge Detection, 2013].
  58. */
  59. class CV_EXPORTS_W RFFeatureGetter : public Algorithm
  60. {
  61. public:
  62. /*!
  63. * This functions extracts feature channels from src.
  64. * Than StructureEdgeDetection uses this feature space
  65. * to detect edges.
  66. *
  67. * \param src : source image to extract features
  68. * \param features : output n-channel floating point feature matrix.
  69. *
  70. * \param gnrmRad : __rf.options.gradientNormalizationRadius
  71. * \param gsmthRad : __rf.options.gradientSmoothingRadius
  72. * \param shrink : __rf.options.shrinkNumber
  73. * \param outNum : __rf.options.numberOfOutputChannels
  74. * \param gradNum : __rf.options.numberOfGradientOrientations
  75. */
  76. CV_WRAP virtual void getFeatures(const Mat &src, Mat &features,
  77. const int gnrmRad,
  78. const int gsmthRad,
  79. const int shrink,
  80. const int outNum,
  81. const int gradNum) const = 0;
  82. };
  83. CV_EXPORTS_W Ptr<RFFeatureGetter> createRFFeatureGetter();
  84. /** @brief Class implementing edge detection algorithm from @cite Dollar2013 :
  85. */
  86. class CV_EXPORTS_W StructuredEdgeDetection : public Algorithm
  87. {
  88. public:
  89. /** @brief The function detects edges in src and draw them to dst.
  90. The algorithm underlies this function is much more robust to texture presence, than common
  91. approaches, e.g. Sobel
  92. @param src source image (RGB, float, in [0;1]) to detect edges
  93. @param dst destination image (grayscale, float, in [0;1]) where edges are drawn
  94. @sa Sobel, Canny
  95. */
  96. CV_WRAP virtual void detectEdges(const Mat &src, CV_OUT Mat &dst) const = 0;
  97. };
  98. /*!
  99. * The only constructor
  100. *
  101. * \param model : name of the file where the model is stored
  102. * \param howToGetFeatures : optional object inheriting from RFFeatureGetter.
  103. * You need it only if you would like to train your
  104. * own forest, pass NULL otherwise
  105. */
  106. CV_EXPORTS_W Ptr<StructuredEdgeDetection> createStructuredEdgeDetection(const String &model,
  107. Ptr<const RFFeatureGetter> howToGetFeatures = Ptr<RFFeatureGetter>());
  108. //! @}
  109. }
  110. }
  111. #endif
  112. #endif /* __OPENCV_STRUCTURED_EDGE_DETECTION_HPP__ */