diff --git a/openbr/gui/utility.cpp b/openbr/gui/utility.cpp index ff30e33..77d6d25 100644 --- a/openbr/gui/utility.cpp +++ b/openbr/gui/utility.cpp @@ -1,12 +1,11 @@ -#include #include #include #include +#include "utility.h" using namespace cv; -/**** STATIC ****/ -QImage toQImage(const Mat &mat) +QImage br::toQImage(const Mat &mat) { // Convert to 8U depth Mat mat8u; diff --git a/openbr/gui/utility.h b/openbr/gui/utility.h index f4c3d60..da5a147 100644 --- a/openbr/gui/utility.h +++ b/openbr/gui/utility.h @@ -3,7 +3,13 @@ #include #include +#include -QImage toQImage(const cv::Mat &mat); +namespace br +{ + +BR_EXPORT QImage toQImage(const cv::Mat &mat); + +} // namespace br #endif // BR_UTILITY_H diff --git a/openbr/janus b/openbr/janus index aa2abb3..f8e6e45 160000 --- a/openbr/janus +++ b/openbr/janus @@ -1 +1 @@ -Subproject commit aa2abb334a3179a04e14b713cd31f133d0c81321 +Subproject commit f8e6e450e554612c3f173740beddf9b8daa84270 diff --git a/openbr/plugins/gui.cpp b/openbr/plugins/gui.cpp index d3af3b2..6d82687 100644 --- a/openbr/plugins/gui.cpp +++ b/openbr/plugins/gui.cpp @@ -13,6 +13,7 @@ #include #include "openbr_internal.h" +#include "openbr/gui/utility.h" using namespace cv; @@ -121,45 +122,6 @@ public slots: } }; -QImage toQImage(const Mat &mat) -{ - // Convert to 8U depth - Mat mat8u; - if (mat.depth() != CV_8U) { - double globalMin = std::numeric_limits::max(); - double globalMax = -std::numeric_limits::max(); - - std::vector mv; - split(mat, mv); - for (size_t i=0; i= globalMin); - - double range = globalMax - globalMin; - if (range != 0) { - double scale = 255 / range; - convertScaleAbs(mat, mat8u, scale, -(globalMin * scale)); - } else { - // Monochromatic - mat8u = Mat(mat.size(), CV_8UC1, Scalar((globalMin+globalMax)/2)); - } - } else { - mat8u = mat; - } - - // Convert to 3 channels - Mat mat8uc3; - if (mat8u.channels() == 4) cvtColor(mat8u, mat8uc3, CV_BGRA2RGB); - else if (mat8u.channels() == 3) cvtColor(mat8u, mat8uc3, CV_BGR2RGB); - else if (mat8u.channels() == 1) cvtColor(mat8u, mat8uc3, CV_GRAY2RGB); - - return QImage(mat8uc3.data, mat8uc3.cols, mat8uc3.rows, 3*mat8uc3.cols, QImage::Format_RGB888).copy(); -} - class DisplayWindow : public QLabel { Q_OBJECT