diff --git a/modules/ximgproc/include/opencv2/ximgproc/structured_edge_detection.hpp b/modules/ximgproc/include/opencv2/ximgproc/structured_edge_detection.hpp index 6b9df9772..23f0af7e1 100644 --- a/modules/ximgproc/include/opencv2/ximgproc/structured_edge_detection.hpp +++ b/modules/ximgproc/include/opencv2/ximgproc/structured_edge_detection.hpp @@ -42,6 +42,7 @@ #ifndef __OPENCV_STRUCTURED_EDGE_DETECTION_HPP__ #define __OPENCV_STRUCTURED_EDGE_DETECTION_HPP__ +#ifdef __cplusplus /* * structured_edge_detection.hpp @@ -57,7 +58,8 @@ */ namespace cv { - +namespace ximgproc +{ /*! \class RFFeatureGetter Helper class for training part of [P. Dollar and C. L. Zitnick. Structured Forests for Fast Edge Detection, 2013]. */ @@ -120,5 +122,6 @@ CV_EXPORTS_W Ptr createStructuredEdgeDetection(const St const RFFeatureGetter *howToGetFeatures = NULL); } - +} +#endif #endif /* __OPENCV_STRUCTURED_EDGE_DETECTION_HPP__ */ \ No newline at end of file diff --git a/modules/ximgproc/samples/structured_edge_detection.cpp b/modules/ximgproc/samples/structured_edge_detection.cpp index 936bf7813..fed8da40d 100644 --- a/modules/ximgproc/samples/structured_edge_detection.cpp +++ b/modules/ximgproc/samples/structured_edge_detection.cpp @@ -1,10 +1,9 @@ -#include "opencv2/ximpgroc/structured_edge_detection.hpp" - -#include "opencv2/imgproc.hpp" +#include #include "opencv2/highgui.hpp" - #include "opencv2/core/utility.hpp" -#include "opencv2/imgproc/types_c.h" + +using namespace cv; +using namespace cv::ximgproc; const char* keys = { @@ -49,8 +48,8 @@ int main( int argc, const char** argv ) cv::Mat edges(image.size(), image.type()); - cv::Ptr pDollar = - cv::createStructuredEdgeDetection(modelFilename); + cv::Ptr pDollar = + createStructuredEdgeDetection(modelFilename); pDollar->detectEdges(image, edges); if ( outFilename == "" ) diff --git a/modules/ximgproc/src/advanced_types.hpp b/modules/ximgproc/src/advanced_types.hpp index dac55d7a9..3cc19d6ed 100644 --- a/modules/ximgproc/src/advanced_types.hpp +++ b/modules/ximgproc/src/advanced_types.hpp @@ -39,6 +39,7 @@ #ifndef __ADVANCED_TYPES_HPP__ #define __ADVANCED_TYPES_HPP__ +#ifdef __cplusplus #include @@ -69,6 +70,8 @@ typedef cv::Mat NChannelsMat; namespace cv { +namespace ximgproc +{ template inline cv::Size_<_Tp> operator * (const _Tp2 &x, const cv::Size_<_Tp> &sz) @@ -83,5 +86,6 @@ template inline } } // cv - +} +#endif #endif /* __ADVANCED_TYPES_HPP__ */ \ No newline at end of file diff --git a/modules/ximgproc/src/structured_edge_detection.cpp b/modules/ximgproc/src/structured_edge_detection.cpp index 25c86bab5..f8812d48d 100644 --- a/modules/ximgproc/src/structured_edge_detection.cpp +++ b/modules/ximgproc/src/structured_edge_detection.cpp @@ -43,17 +43,9 @@ #include #include -#include "opencv2/ximpgroc/structured_edge_detection.hpp" - -#include "opencv2/imgproc.hpp" - -#include "opencv2/core.hpp" -#include "opencv2/core/core_c.h" +#include "precomp.hpp" #include "advanced_types.hpp" -#include "opencv2/core/types.hpp" -#include "opencv2/core/types_c.h" - /********************* Helper functions *********************/ @@ -196,7 +188,7 @@ static void gradientHist(const cv::Mat &src, cv::Mat &magnitude, cv::Mat &histog magnitude.create( src.size(), cv::DataType::type ); phase.create( src.size(), cv::DataType::type ); - histogram.create( src.size()/float(pSize), + histogram.create( cv::Size(src.size().width/float(pSize), src.size().height/float(pSize)) , CV_MAKETYPE(cv::DataType::type, nBins) ); histogram.setTo(0); @@ -258,6 +250,8 @@ static void gradientHist(const cv::Mat &src, cv::Mat &magnitude, cv::Mat &histog namespace cv { +namespace ximgproc +{ class RFFeatureGetterImpl : public RFFeatureGetter { @@ -325,12 +319,15 @@ Ptr createRFFeatureGetter() return makePtr(); } -}; +} +} /********************* StructuredEdgeDetection class *********************/ namespace cv { +namespace ximgproc +{ class StructuredEdgeDetectionImpl : public StructuredEdgeDetection { @@ -692,3 +689,4 @@ Ptr createStructuredEdgeDetection(const String &model, } } +} diff --git a/modules/ximgproc/test/test_structured_edge_detection.cpp b/modules/ximgproc/test/test_structured_edge_detection.cpp index cf82fd988..c022ac54f 100644 --- a/modules/ximgproc/test/test_structured_edge_detection.cpp +++ b/modules/ximgproc/test/test_structured_edge_detection.cpp @@ -10,8 +10,8 @@ TEST(ximpgroc_StructuredEdgeDetection, regression) float threshold = 0.01f; cv::String modelName = dir + "model.yml.gz"; - cv::Ptr pDollar = - cv::createStructuredEdgeDetection(modelName); + cv::Ptr pDollar = + cv::ximgproc::createStructuredEdgeDetection(modelName); for (int i = 0; i < nTests; ++i) {