utils.cpp
Go to the documentation of this file.
1 
2 #include <string>
3 #include <iostream>
4 #include <sstream>
5 #include <iomanip>
6 #include <tuw_geometry/utils.h>
7 
8 
9 namespace tuw{
10 
11 std::string format(const cv::Mat_<int8_t> &m){
12  std::stringstream ss;
13  for (int r = 0; r < m.rows; r++) {
14  ss << (r==0?"[":" ");
15  for (int c = 0; c < m.cols; c++) {
16  ss << (c==0?"":", ") << std::setw(6) << m(r,c);
17  }
18  ss << (r<m.cols-1?";":"]") << std::endl;
19  }
20  return ss.str();
21 }
22 std::string format(const cv::Mat_<int> &m){
23  std::stringstream ss;
24  for (int r = 0; r < m.rows; r++) {
25  ss << (r==0?"[":" ");
26  for (int c = 0; c < m.cols; c++) {
27  ss << (c==0?"":", ") << std::setw(12) << m(r,c);
28  }
29  ss << (r<m.cols-1?";":"]") << std::endl;
30  }
31  return ss.str();
32 }
33 std::string format(const cv::Mat_<float> &m){
34  std::stringstream ss;
35  for (int r = 0; r < m.rows; r++) {
36  ss << std::setprecision(std::numeric_limits<float>::digits10 + 1);
37  ss << (r==0?"[":" ");
38  for (int c = 0; c < m.cols; c++) {
39  ss << (c==0?"":", ") << std::setw(12) << m(r,c);
40  }
41  ss << (r<m.cols-1?";":"]") << std::endl;
42  }
43  return ss.str();
44 }
45 std::string format(const cv::Mat_<double> &m){
46  std::stringstream ss;
47  for (int r = 0; r < m.rows; r++) {
48  ss << std::setprecision(std::numeric_limits<double>::digits10 + 1);
49  ss << (r==0?"[":" ");
50  for (int c = 0; c < m.cols; c++) {
51  ss << (c==0?"":", ") << std::setw(24) << m(r,c);
52  }
53  ss << (r<m.cols-1?";":"]") << std::endl;
54  }
55  return ss.str();
56 }
57 std::string format(const cv::Matx33d &m){
58  std::stringstream ss;
59  for (int r = 0; r < m.rows; r++) {
60  ss << std::setprecision(std::numeric_limits<double>::digits10 + 1);
61  ss << (r==0?"[":" ");
62  for (int c = 0; c < m.cols; c++) {
63  ss << (c==0?"":", ") << std::setw(24) << m(r,c);
64  }
65  ss << (r<m.cols-1?";":"]") << std::endl;
66  }
67  return ss.str();
68 }
69 }
Definition: command.h:8
std::string format(const cv::Mat_< int8_t > &m)
Definition: utils.cpp:11


tuw_geometry
Author(s): Markus Bader
autogenerated on Mon Jun 10 2019 15:33:09