Commit 1c8113157bcac14778f6e533da371d7e5b4f745a

Authored by Scott Klum
2 parents 21d379d2 fc69f628

Merge branch 'master' of https://github.com/biometrics/openbr into progressin

openbr/gui/utility.cpp
1 -#include <QImage>  
2 #include <limits> 1 #include <limits>
3 #include <vector> 2 #include <vector>
4 #include <opencv2/imgproc/imgproc.hpp> 3 #include <opencv2/imgproc/imgproc.hpp>
  4 +#include "utility.h"
5 5
6 using namespace cv; 6 using namespace cv;
7 7
8 -/**** STATIC ****/  
9 -QImage toQImage(const Mat &mat) 8 +QImage br::toQImage(const Mat &mat)
10 { 9 {
11 // Convert to 8U depth 10 // Convert to 8U depth
12 Mat mat8u; 11 Mat mat8u;
openbr/gui/utility.h
@@ -3,7 +3,13 @@ @@ -3,7 +3,13 @@
3 3
4 #include <QImage> 4 #include <QImage>
5 #include <opencv2/core/core.hpp> 5 #include <opencv2/core/core.hpp>
  6 +#include <openbr/openbr_export.h>
6 7
7 -QImage toQImage(const cv::Mat &mat); 8 +namespace br
  9 +{
  10 +
  11 +BR_EXPORT QImage toQImage(const cv::Mat &mat);
  12 +
  13 +} // namespace br
8 14
9 #endif // BR_UTILITY_H 15 #endif // BR_UTILITY_H
1 -Subproject commit aa2abb334a3179a04e14b713cd31f133d0c81321 1 +Subproject commit f8e6e450e554612c3f173740beddf9b8daa84270
openbr/plugins/gui.cpp
@@ -13,6 +13,7 @@ @@ -13,6 +13,7 @@
13 13
14 #include <opencv2/imgproc/imgproc.hpp> 14 #include <opencv2/imgproc/imgproc.hpp>
15 #include "openbr_internal.h" 15 #include "openbr_internal.h"
  16 +#include "openbr/gui/utility.h"
16 17
17 using namespace cv; 18 using namespace cv;
18 19
@@ -121,45 +122,6 @@ public slots: @@ -121,45 +122,6 @@ public slots:
121 } 122 }
122 }; 123 };
123 124
124 -QImage toQImage(const Mat &mat)  
125 -{  
126 - // Convert to 8U depth  
127 - Mat mat8u;  
128 - if (mat.depth() != CV_8U) {  
129 - double globalMin = std::numeric_limits<double>::max();  
130 - double globalMax = -std::numeric_limits<double>::max();  
131 -  
132 - std::vector<Mat> mv;  
133 - split(mat, mv);  
134 - for (size_t i=0; i<mv.size(); i++) {  
135 - double min, max;  
136 - minMaxLoc(mv[i], &min, &max);  
137 - globalMin = std::min(globalMin, min);  
138 - globalMax = std::max(globalMax, max);  
139 - }  
140 - assert(globalMax >= globalMin);  
141 -  
142 - double range = globalMax - globalMin;  
143 - if (range != 0) {  
144 - double scale = 255 / range;  
145 - convertScaleAbs(mat, mat8u, scale, -(globalMin * scale));  
146 - } else {  
147 - // Monochromatic  
148 - mat8u = Mat(mat.size(), CV_8UC1, Scalar((globalMin+globalMax)/2));  
149 - }  
150 - } else {  
151 - mat8u = mat;  
152 - }  
153 -  
154 - // Convert to 3 channels  
155 - Mat mat8uc3;  
156 - if (mat8u.channels() == 4) cvtColor(mat8u, mat8uc3, CV_BGRA2RGB);  
157 - else if (mat8u.channels() == 3) cvtColor(mat8u, mat8uc3, CV_BGR2RGB);  
158 - else if (mat8u.channels() == 1) cvtColor(mat8u, mat8uc3, CV_GRAY2RGB);  
159 -  
160 - return QImage(mat8uc3.data, mat8uc3.cols, mat8uc3.rows, 3*mat8uc3.cols, QImage::Format_RGB888).copy();  
161 -}  
162 -  
163 class DisplayWindow : public QLabel 125 class DisplayWindow : public QLabel
164 { 126 {
165 Q_OBJECT 127 Q_OBJECT