16 #ifndef mitkEndoDebug_h
17 #define mitkEndoDebug_h
23 #include <MitkCameraCalibrationExports.h>
46 static std::string GetUniqueFileName(
const std::string& dir,
const std::string& ext=
"jpg" ,
const std::string &prefix=
"");
51 void SetDebugEnabled(
bool _DebugEnabled);
56 bool GetDebugEnabled();
61 void SetShowImagesInDebug(
bool _ShowImagesInDebug);
66 bool GetShowImagesInDebug();
71 void SetShowImagesTimeOut(
size_t _ShowImagesTimeOut);
76 size_t GetShowImagesTimeOut();
82 void SetDebugImagesOutputDirectory(
const std::string& _DebugImagesOutputDirectory);
87 std::string GetDebugImagesOutputDirectory()
const;
92 std::string GetFilenameWithoutExtension(
const std::string& s);
101 bool AddFileToDebug(
const std::string& fileToDebug);
106 void SetFilesToDebug(
const std::set<std::string>& filesToDebug);
111 std::set<std::string> GetFilesToDebug();
118 bool AddSymbolToDebug(
const std::string& symbolToDebug);
123 void SetSymbolsToDebug(
const std::set<std::string>& symbolsToDebug);
128 std::set<std::string> GetSymbolsToDebug();
133 bool DebugFile(
const std::string& fileToDebug );
138 bool DebugSymbol(
const std::string& symbolToDebug );
143 bool Debug(
const std::string& fileToDebug,
const std::string& symbol=
"" );
147 void SetLogFile(
const std::string& file );
151 void ShowMessage(
const std::string& message );
170 #if (defined(WIN32) && !defined(_DEBUG)) || defined(NDEBUG)
171 #define endodebugmarker
172 #define endodebug(msg)
173 #define endodebugvar(var)
174 #define endodebugsymbol(var, mSymbol)
175 #define endodebugimg(imgVariableName)
176 #define endodebugbegin if( false ) {
177 #define endodebugend }
178 #define endoAssert(a) \
180 throw std::invalid_argument("FAILED: " #a); \
183 #define endoAssertMsg(a, msg) \
185 throw std::invalid_argument( "FAILED: " #a ); \
188 #define endodebugcode(code)
189 #define endoAssertCode(assertCode)
191 #define endodebugmarker\
195 if( mitk::EndoDebug::GetInstance().Debug(__FILE__) ) \
197 std::ostringstream ___ostringstream; \
198 ___ostringstream << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " << __LINE__\
199 << ": " << __FUNCTION__ << std::endl;\
200 mitk::EndoDebug::GetInstance().ShowMessage( ___ostringstream.str() ); \
206 #define endodebug(msg)\
207 if( mitk::EndoDebug::GetInstance().Debug(__FILE__) ) \
209 std::ostringstream ___ostringstream; \
210 ___ostringstream << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " << __LINE__\
211 << ": " << msg << std::endl;\
212 mitk::EndoDebug::GetInstance().ShowMessage( ___ostringstream.str() ); \
218 #define endodebugvar(var)\
219 if( mitk::EndoDebug::GetInstance().Debug(__FILE__) ) \
221 std::ostringstream ___ostringstream; \
222 ___ostringstream << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " << __LINE__\
223 << ": " #var " = " << var << std::endl;\
224 mitk::EndoDebug::GetInstance().ShowMessage( ___ostringstream.str() ); \
230 #define endodebugsymbol(var, mSymbol)\
231 if( mitk::EndoDebug::GetInstance().Debug(__FILE__, mSymbol) ) \
233 std::ostringstream ___ostringstream; \
234 ___ostringstream << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " << __LINE__\
235 << ": " #var " = " << var << std::endl;\
236 mitk::EndoDebug::GetInstance().ShowMessage( ___ostringstream.str() ); \
243 #define endodebugimg(imgVariableName)\
244 if( mitk::EndoDebug::GetInstance().Debug(__FILE__) \
245 && mitk::EndoDebug::GetInstance().GetShowImagesInDebug() \
246 && (imgVariableName).cols > 0 && (imgVariableName).rows > 0 && (imgVariableName).data) \
248 std::ostringstream ___ostringstream; \
249 ___ostringstream << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " << __LINE__\
250 << ": Showing " #imgVariableName << std::endl; \
251 mitk::EndoDebug::GetInstance().ShowMessage( ___ostringstream.str() ); \
252 std::string outputFile = mitk::EndoDebug::GetInstance().GetDebugImagesOutputDirectory(); \
253 if( !outputFile.empty() ) \
255 outputFile = mitk::EndoDebug::GetInstance().GetUniqueFileName(outputFile, "jpg", std::string(#imgVariableName) );\
256 cv::imwrite(outputFile, imgVariableName);\
260 cv::imshow( "Debug", imgVariableName ); \
261 cv::waitKey( mitk::EndoDebug::GetInstance().GetShowImagesTimeOut() ); \
268 #define endodebugbegin \
269 if( mitk::EndoDebug::GetInstance().Debug(__FILE__) ) \
275 #define endodebugend \
278 #define endodebugcode(code) \
286 #define endoAssert(a) \
288 std::ostringstream s; \
289 s << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " \
290 << __LINE__ << ", failed: " << #a; \
291 throw std::invalid_argument(s.str()); }
297 #define endoAssertMsg(a, msg) \
299 std::ostringstream s; \
300 s << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " \
301 << __LINE__ << ": " << msg; \
302 throw std::invalid_argument(s.str()); \
305 #define endoAssertCode(assertCode) \
310 #endif // mitkEndoDebug_h
DataCollection - Class to facilitate loading/accessing structured data.