diff --git a/modules/core/src/out.cpp b/modules/core/src/out.cpp index 89919715e..2c6ba5396 100644 --- a/modules/core/src/out.cpp +++ b/modules/core/src/out.cpp @@ -43,9 +43,9 @@ #include "precomp.hpp" -namespace +namespace cv { - class FormattedImpl : public cv::Formatted + class FormattedImpl : public Formatted { enum { STATE_PROLOGUE, STATE_EPILOGUE, STATE_INTERLUDE, STATE_ROW_OPEN, STATE_ROW_CLOSE, STATE_CN_OPEN, STATE_CN_CLOSE, STATE_VALUE, STATE_FINISHED, @@ -55,7 +55,7 @@ namespace char floatFormat[8]; char buf[32]; // enough for double with precision up to 20 - cv::Mat mtx; + Mat mtx; int mcn; // == mtx.channels() bool singleLine; bool alignOrder; // true when cn first order @@ -65,8 +65,8 @@ namespace int col; int cn; - cv::String prologue; - cv::String epilogue; + String prologue; + String epilogue; char braces[5]; void (FormattedImpl::*valueToStr)(); @@ -81,7 +81,7 @@ namespace public: - FormattedImpl(cv::String pl, cv::String el, cv::Mat m, char br[5], bool sLine, bool aOrder, int precision) + FormattedImpl(String pl, String el, Mat m, char br[5], bool sLine, bool aOrder, int precision) { CV_Assert(m.dims <= 2); @@ -253,7 +253,7 @@ namespace } }; - class FormatterBase : public cv::Formatter + class FormatterBase : public Formatter { public: FormatterBase() : prec32f(8), prec64f(16), multiline(true) {} @@ -278,14 +278,15 @@ namespace int prec64f; int multiline; }; + class DefaultFormatter : public FormatterBase { public: - cv::Ptr format(const cv::Mat& mtx) const + Ptr format(const Mat& mtx) const { char braces[5] = {'\0', '\0', ';', '\0', '\0'}; - return cv::makePtr("[", "]", mtx, &*braces, + return makePtr("[", "]", mtx, &*braces, mtx.rows == 1 || !multiline, false, mtx.depth() == CV_64F ? prec64f : prec32f ); } }; @@ -294,10 +295,10 @@ namespace { public: - cv::Ptr format(const cv::Mat& mtx) const + Ptr format(const Mat& mtx) const { char braces[5] = {'\0', '\0', ';', '\0', '\0'}; - return cv::makePtr("", "", mtx, &*braces, + return makePtr("", "", mtx, &*braces, mtx.rows == 1 || !multiline, true, mtx.depth() == CV_64F ? prec64f : prec32f ); } }; @@ -306,12 +307,12 @@ namespace { public: - cv::Ptr format(const cv::Mat& mtx) const + Ptr format(const Mat& mtx) const { char braces[5] = {'[', ']', '\0', '[', ']'}; if (mtx.cols == 1) braces[0] = braces[1] = '\0'; - return cv::makePtr("[", "]", mtx, &*braces, + return makePtr("[", "]", mtx, &*braces, mtx.rows == 1 || !multiline, false, mtx.depth() == CV_64F ? prec64f : prec32f ); } }; @@ -320,7 +321,7 @@ namespace { public: - cv::Ptr format(const cv::Mat& mtx) const + Ptr format(const Mat& mtx) const { static const char* numpyTypes[] = { @@ -329,7 +330,7 @@ namespace char braces[5] = {'[', ']', '\0', '[', ']'}; if (mtx.cols == 1) braces[0] = braces[1] = '\0'; - return cv::makePtr("array([", + return makePtr("array([", cv::format("], type='%s')", numpyTypes[mtx.depth()]), mtx, &*braces, mtx.rows == 1 || !multiline, false, mtx.depth() == CV_64F ? prec64f : prec32f ); } @@ -339,11 +340,11 @@ namespace { public: - cv::Ptr format(const cv::Mat& mtx) const + Ptr format(const Mat& mtx) const { char braces[5] = {'\0', '\0', '\0', '\0', '\0'}; - return cv::makePtr(cv::String(), - mtx.rows > 1 ? cv::String("\n") : cv::String(), mtx, &*braces, + return makePtr(String(), + mtx.rows > 1 ? String("\n") : String(), mtx, &*braces, mtx.rows == 1 || !multiline, false, mtx.depth() == CV_64F ? prec64f : prec32f ); } }; @@ -352,19 +353,14 @@ namespace { public: - cv::Ptr format(const cv::Mat& mtx) const + Ptr format(const Mat& mtx) const { char braces[5] = {'\0', '\0', ',', '\0', '\0'}; - return cv::makePtr("{", "}", mtx, &*braces, + return makePtr("{", "}", mtx, &*braces, mtx.rows == 1 || !multiline, false, mtx.depth() == CV_64F ? prec64f : prec32f ); } }; -} // namespace - - -namespace cv -{ Formatted::~Formatted() {} Formatter::~Formatter() {}