vrcore  0.45
visuReal Messkern
 All Classes Files Functions Variables
log.h
Go to the documentation of this file.
1 #ifndef VRLOG_H
2 #define VRLOG_H
3 
6 #include <boost/format.hpp>
7 #include <opencv2/opencv.hpp>
8 
9 namespace vr {
10 namespace log {
11 
12 std::stringstream& getStream();
13 const char* getStr();
14 
15 template <int n> void vectorToStrStream(std::stringstream& ss, const cv::Vec<double, n>& v)
16 {
17  if
18  (n == 2) ss << boost::format(" %f, %f\n") % v(0) % v(1);
19  else if
20  (n == 3) ss << boost::format(" %f, %f, %f\n") % v(0) % v(1) % v(2);
21 }
22 
23 template <int n> std::string vectorToStr(const cv::Vec<double, n>& v)
24 {
25  std::stringstream ss;
26  vectorToStrStream(ss, v);
27  return ss.str();
28 }
29 
30 template <int n> void writeVector(const cv::Vec<double, n>& v)
31 {
32  vectorToStrStream(getStream(), v);
33 }
34 
35 void matrixToStrStream(std::stringstream& ss, const std::string& name, cv::InputArray m);
36 std::string matrixToStr(const std::string& name, cv::InputArray m);
37 
38 void writeMatrix(const std::string& name, const cv::Mat& m);
39 
40 } // namespace log
41 } // namespace vr
42 
43 #endif // VRLOG_H