MITK-IGT
IGT Extension of MITK
Loading...
Searching...
No Matches
mitkStringFromCvMat.h
Go to the documentation of this file.
1/*============================================================================
2
3The Medical Imaging Interaction Toolkit (MITK)
4
5Copyright (c) German Cancer Research Center (DKFZ)
6All rights reserved.
7
8Use of this source code is governed by a 3-clause BSD license that can be
9found in the LICENSE file.
10
11============================================================================*/
12#ifndef mitkStringFromCvMat_h
13#define mitkStringFromCvMat_h
14
15#include <string>
16#include <mitkObservable.h>
17#include <mitkAlgorithm.h>
18#include <mitkEndoMacros.h>
19#include <sstream>
20
21#include "opencv2/core.hpp"
22
23namespace mitk
24{
29 virtual public Algorithm
30 {
31 public:
36 const cv::Mat* _CvMat,
37 std::string* _String):
38 m_CvMat(_CvMat),
39 m_String(_String)
40 {
41 }
42
43
47 template <typename TCvMat, char T_Delim>
48 void ToString( std::string& string, const cv::Mat& mat )
49 {
50 std::ostringstream s;
51
52
53 for(int i=0; i<mat.rows; ++i)
54 {
55 for(int j=0; j<mat.cols; ++j)
56 {
57 s << mat.at<TCvMat>(i,j) << " ";
58 }
59 s << T_Delim;
60 }
61 string = s.str();
62 }
63
65 const cv::Mat* _CvMat )
66 {
67 m_CvMat = _CvMat;
68 }
69
73 void Update() override
74 {
75 endoAccessCvMat( ToString, '\n', (*m_String), (*m_CvMat) );
76 }
77 private:
81 const cv::Mat* m_CvMat;
85 std::string* m_String;
86 };
87} // namespace mitk
88
89#endif
StringFromCvMat(const cv::Mat *_CvMat, std::string *_String)
void SetMatrix(const cv::Mat *_CvMat)
void ToString(std::string &string, const cv::Mat &mat)
#define endoAccessCvMat(function, T, arg1, arg2)
IGT Exceptions.