|
|
|
@ -1,10 +1,11 @@ |
|
|
|
|
#pragma once |
|
|
|
|
#include <stdlib.h> |
|
|
|
|
#include <iostream> |
|
|
|
|
#include <sstream> |
|
|
|
|
#include <opencv2/core.hpp> |
|
|
|
|
|
|
|
|
|
#define CHECK(cond) cv::GLogWrapper(__FILE__, CV_Func, __LINE__, "CHECK", #cond, cond) |
|
|
|
|
#define CHECK_EQ(a, b) cv::GLogWrapper(__FILE__, CV_Func, __LINE__, "CHECK", #a #b, ((a) == (b))) |
|
|
|
|
#define CHECK_EQ(a, b) cv::GLogWrapper(__FILE__, CV_Func, __LINE__, "CHECK", #a"="#b, ((a) == (b))) |
|
|
|
|
#define LOG(TYPE) cv::GLogWrapper(__FILE__, CV_Func, __LINE__, #TYPE) |
|
|
|
|
|
|
|
|
|
namespace cv |
|
|
|
@ -12,18 +13,10 @@ namespace cv |
|
|
|
|
|
|
|
|
|
class GLogWrapper |
|
|
|
|
{ |
|
|
|
|
const char *type, *cond_str, *file, *func; |
|
|
|
|
std::stringstream stream; |
|
|
|
|
const char *file, *func, *type, *cond_str; |
|
|
|
|
int line; |
|
|
|
|
bool cond_staus; |
|
|
|
|
std::ostream &stream; |
|
|
|
|
|
|
|
|
|
static std::ostream &selectStream(const char *type) |
|
|
|
|
{ |
|
|
|
|
if (!strcmp(type, "INFO")) |
|
|
|
|
return std::cout; |
|
|
|
|
else |
|
|
|
|
return std::cerr; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public: |
|
|
|
|
|
|
|
|
@ -31,9 +24,8 @@ public: |
|
|
|
|
const char *_type, |
|
|
|
|
const char *_cond_str = NULL, bool _cond_status = true |
|
|
|
|
) : |
|
|
|
|
stream(selectStream(_type)), |
|
|
|
|
file(_file), func(_func), line(_line), |
|
|
|
|
type(_type), cond_str(_cond_str), cond_staus(_cond_status) {} |
|
|
|
|
file(_file), func(_func), type(_type), cond_str(_cond_str), |
|
|
|
|
line(_line), cond_staus(_cond_status) {} |
|
|
|
|
|
|
|
|
|
template<typename T> |
|
|
|
|
GLogWrapper &operator<<(const T &v) |
|
|
|
@ -47,13 +39,16 @@ public: |
|
|
|
|
{ |
|
|
|
|
if (cond_str && !cond_staus) |
|
|
|
|
{ |
|
|
|
|
cv::error(cv::Error::StsAssert, cond_str, func, file, line); |
|
|
|
|
cv::error(cv::Error::StsError, "FAILED: " + String(cond_str) + "." + stream.str(), func, file, line); |
|
|
|
|
} |
|
|
|
|
else if (!cond_str && strcmp(type, "CHECK")) |
|
|
|
|
{ |
|
|
|
|
if (!strcmp(type, "INFO")) |
|
|
|
|
std::cout << stream.str(); |
|
|
|
|
else |
|
|
|
|
std::cerr << stream.str(); |
|
|
|
|
} |
|
|
|
|
//else if (!cond_str && strcmp(type, "INFO"))
|
|
|
|
|
//{
|
|
|
|
|
// cv::error(cv::Error::StsAssert, type, func, file, line);
|
|
|
|
|
//}
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|