35 #include <boost/serialization/singleton.hpp> 36 #include <boost/thread/mutex.hpp> 38 #include <opencv2/highgui/highgui.hpp> 39 #include <opencv2/imgproc/imgproc.hpp> 52 boost::unique_lock<boost::mutex> lock(
mutex_);
56 cvStartWindowThread();
63 cvNamedWindow(name.c_str(), CV_WINDOW_NORMAL);
67 #if (BOOST_VERSION / 100 % 1000) >= 65 68 friend class boost::serialization::singleton<CvWindows>;
70 friend class boost::serialization::detail::singleton_wrapper<CvWindows>;
80 const std::string& name,
91 CvWindowsSingleton::get_mutable_instance().RegisterWindow(name);
99 cv::minMaxLoc(mat, &min, &max, 0, 0, mask);
101 if(mat.type() == CV_8UC1)
103 a = 255.0 / std::max(max - min, DBL_EPSILON);
105 mat.convertTo(scaled, CV_8U, a, b);
107 else if(mat.type() == CV_32FC1)
109 a = 255.0 / std::max(max - min, DBL_EPSILON);
111 mat.convertTo(scaled, CV_8U, a, b);
115 cv::cvtColor(scaled, color, CV_GRAY2BGR);
116 color.setTo(cv::Scalar(0.0,0.0,255.0), mask == 0);
120 else if(mat.type() == CV_32FC3)
122 a = 255.0 / std::max(max - min, DBL_EPSILON);
124 mat.convertTo(scaled, CV_8UC3, a, b);
126 else if(mat.type() == CV_8UC3)
128 a = 255.0 / std::max(max - min, DBL_EPSILON);
130 mat.convertTo(scaled, CV_8UC3, a, b);
135 mat.convertTo(scaled, CV_8U, a, b);
138 cv::imshow(name, scaled);
void RegisterWindow(const std::string &name)
void ShowScaled(const std::string &name, const cv::Mat &mat, const cv::Mat &mask=cv::Mat(), double a=-1.0, double b=0.0)
std::map< std::string, std::string > windows_
boost::serialization::singleton< CvWindows > CvWindowsSingleton