12 #ifndef mitkEndoDebug_h 13 #define mitkEndoDebug_h 19 #include <MitkCameraCalibrationExports.h> 42 static std::string GetUniqueFileName(
const std::string& dir,
const std::string& ext=
"jpg" ,
const std::string &prefix=
"");
47 void SetDebugEnabled(
bool _DebugEnabled);
52 bool GetDebugEnabled();
57 void SetShowImagesInDebug(
bool _ShowImagesInDebug);
62 bool GetShowImagesInDebug();
67 void SetShowImagesTimeOut(
size_t _ShowImagesTimeOut);
72 size_t GetShowImagesTimeOut();
78 void SetDebugImagesOutputDirectory(
const std::string& _DebugImagesOutputDirectory);
83 std::string GetDebugImagesOutputDirectory()
const;
88 std::string GetFilenameWithoutExtension(
const std::string& s);
97 bool AddFileToDebug(
const std::string& fileToDebug);
102 void SetFilesToDebug(
const std::set<std::string>& filesToDebug);
107 std::set<std::string> GetFilesToDebug();
114 bool AddSymbolToDebug(
const std::string& symbolToDebug);
119 void SetSymbolsToDebug(
const std::set<std::string>& symbolsToDebug);
124 std::set<std::string> GetSymbolsToDebug();
129 bool DebugFile(
const std::string& fileToDebug );
134 bool DebugSymbol(
const std::string& symbolToDebug );
139 bool Debug(
const std::string& fileToDebug,
const std::string& symbol=
"" );
143 void SetLogFile(
const std::string& file );
147 void ShowMessage(
const std::string& message );
166 #if (defined(WIN32) && !defined(_DEBUG)) || defined(NDEBUG) 167 #define endodebugmarker 168 #define endodebug(msg) 169 #define endodebugvar(var) 170 #define endodebugsymbol(var, mSymbol) 171 #define endodebugimg(imgVariableName) 172 #define endodebugbegin if( false ) { 173 #define endodebugend } 174 #define endoAssert(a) \ 176 throw std::invalid_argument("FAILED: " #a); \ 179 #define endoAssertMsg(a, msg) \ 181 throw std::invalid_argument( "FAILED: " #a ); \ 184 #define endodebugcode(code) 185 #define endoAssertCode(assertCode) 187 #define endodebugmarker\ 191 if( mitk::EndoDebug::GetInstance().Debug(__FILE__) ) \ 193 std::ostringstream ___ostringstream; \ 194 ___ostringstream << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " << __LINE__\ 195 << ": " << __FUNCTION__ << std::endl;\ 196 mitk::EndoDebug::GetInstance().ShowMessage( ___ostringstream.str() ); \ 202 #define endodebug(msg)\ 203 if( mitk::EndoDebug::GetInstance().Debug(__FILE__) ) \ 205 std::ostringstream ___ostringstream; \ 206 ___ostringstream << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " << __LINE__\ 207 << ": " << msg << std::endl;\ 208 mitk::EndoDebug::GetInstance().ShowMessage( ___ostringstream.str() ); \ 214 #define endodebugvar(var)\ 215 if( mitk::EndoDebug::GetInstance().Debug(__FILE__) ) \ 217 std::ostringstream ___ostringstream; \ 218 ___ostringstream << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " << __LINE__\ 219 << ": " #var " = " << var << std::endl;\ 220 mitk::EndoDebug::GetInstance().ShowMessage( ___ostringstream.str() ); \ 226 #define endodebugsymbol(var, mSymbol)\ 227 if( mitk::EndoDebug::GetInstance().Debug(__FILE__, mSymbol) ) \ 229 std::ostringstream ___ostringstream; \ 230 ___ostringstream << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " << __LINE__\ 231 << ": " #var " = " << var << std::endl;\ 232 mitk::EndoDebug::GetInstance().ShowMessage( ___ostringstream.str() ); \ 239 #define endodebugimg(imgVariableName)\ 240 if( mitk::EndoDebug::GetInstance().Debug(__FILE__) \ 241 && mitk::EndoDebug::GetInstance().GetShowImagesInDebug() \ 242 && (imgVariableName).cols > 0 && (imgVariableName).rows > 0 && (imgVariableName).data) \ 244 std::ostringstream ___ostringstream; \ 245 ___ostringstream << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " << __LINE__\ 246 << ": Showing " #imgVariableName << std::endl; \ 247 mitk::EndoDebug::GetInstance().ShowMessage( ___ostringstream.str() ); \ 248 std::string outputFile = mitk::EndoDebug::GetInstance().GetDebugImagesOutputDirectory(); \ 249 if( !outputFile.empty() ) \ 251 outputFile = mitk::EndoDebug::GetInstance().GetUniqueFileName(outputFile, "jpg", std::string(#imgVariableName) );\ 252 cv::imwrite(outputFile, imgVariableName);\ 256 cv::imshow( "Debug", imgVariableName ); \ 257 cv::waitKey( mitk::EndoDebug::GetInstance().GetShowImagesTimeOut() ); \ 264 #define endodebugbegin \ 265 if( mitk::EndoDebug::GetInstance().Debug(__FILE__) ) \ 271 #define endodebugend \ 274 #define endodebugcode(code) \ 282 #define endoAssert(a) \ 284 std::ostringstream s; \ 285 s << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " \ 286 << __LINE__ << ", failed: " << #a; \ 287 throw std::invalid_argument(s.str()); } 293 #define endoAssertMsg(a, msg) \ 295 std::ostringstream s; \ 296 s << mitk::EndoDebug::GetInstance().GetFilenameWithoutExtension(__FILE__) << ", " \ 297 << __LINE__ << ": " << msg; \ 298 throw std::invalid_argument(s.str()); \ 301 #define endoAssertCode(assertCode) \ 306 #endif // mitkEndoDebug_h
DataCollection - Class to facilitate loading/accessing structured data.