Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
cd029345
Commit
cd029345
authored
Aug 19, 2016
by
Vitaliy Lyudvichenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid throwing glog exeptions from destructor
parent
662fc9c7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
20 deletions
+35
-20
caffe_importer.cpp
modules/dnn/src/caffe/caffe_importer.cpp
+9
-1
glog_emulator.hpp
modules/dnn/src/caffe/glog_emulator.hpp
+26
-19
No files found.
modules/dnn/src/caffe/caffe_importer.cpp
View file @
cd029345
...
...
@@ -375,7 +375,15 @@ Ptr<Importer> cv::dnn::createCaffeImporter(const String&, const String&)
Net
cv
::
dnn
::
readNetFromCaffe
(
const
String
&
prototxt
,
const
String
&
caffeModel
/*= String()*/
)
{
Ptr
<
Importer
>
caffeImporter
=
createCaffeImporter
(
prototxt
,
caffeModel
);
Ptr
<
Importer
>
caffeImporter
;
try
{
caffeImporter
=
createCaffeImporter
(
prototxt
,
caffeModel
);
}
catch
(...)
{
}
Net
net
;
if
(
caffeImporter
)
caffeImporter
->
populateNet
(
net
);
...
...
modules/dnn/src/caffe/glog_emulator.hpp
View file @
cd029345
...
...
@@ -46,52 +46,59 @@
#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 LOG(TYPE)
cv::GLogWrapper(__FILE__, CV_Func, __LINE__, #TYPE
)
#define CHECK(cond)
for(cv::dnn::GLogWrapper _logger(__FILE__, CV_Func, __LINE__, "CHECK", #cond, cond); _logger.exit(); _logger.check()) _logger.stream(
)
#define CHECK_EQ(a, b)
for(cv::dnn::GLogWrapper _logger(__FILE__, CV_Func, __LINE__, "CHECK", #a"="#b, ((a) == (b))); _logger.exit(); _logger.check()) _logger.stream(
)
#define LOG(TYPE)
for(cv::dnn::GLogWrapper _logger(__FILE__, CV_Func, __LINE__, #TYPE); _logger.exit(); _logger.check()) _logger.stream(
)
namespace
cv
{
namespace
dnn
{
class
GLogWrapper
{
std
::
stringstream
stream
;
const
char
*
file
,
*
func
,
*
type
,
*
cond_str
;
int
line
;
bool
cond_staus
;
bool
cond_staus
,
exit_loop
;
std
::
stringstream
sstream
;
public
:
GLogWrapper
(
const
char
*
_file
,
const
char
*
_func
,
int
_line
,
const
char
*
_type
,
const
char
*
_cond_str
=
NULL
,
bool
_cond_status
=
true
)
:
file
(
_file
),
func
(
_func
),
type
(
_type
),
cond_str
(
_cond_str
),
line
(
_line
),
cond_staus
(
_cond_status
)
{}
const
char
*
_type
,
const
char
*
_cond_str
=
NULL
,
bool
_cond_status
=
true
)
:
file
(
_file
),
func
(
_func
),
type
(
_type
),
cond_str
(
_cond_str
),
line
(
_line
),
cond_staus
(
_cond_status
),
exit_loop
(
true
)
{}
std
::
iostream
&
stream
()
{
return
sstream
;
}
template
<
typename
T
>
GLogWrapper
&
operator
<<
(
const
T
&
v
)
bool
exit
()
{
if
(
!
cond_str
||
cond_str
&&
!
cond_staus
)
stream
<<
v
;
return
*
this
;
return
exit_loop
;
}
~
GLogWrapper
()
void
check
()
{
exit_loop
=
false
;
if
(
cond_str
&&
!
cond_staus
)
{
cv
::
error
(
cv
::
Error
::
StsError
,
"FAILED: "
+
String
(
cond_str
)
+
".
"
+
stream
.
str
(),
func
,
file
,
line
);
cv
::
error
(
cv
::
Error
::
StsError
,
"FAILED: "
+
String
(
cond_str
)
+
".
"
+
s
stream
.
str
(),
func
,
file
,
line
);
}
else
if
(
!
cond_str
&&
strcmp
(
type
,
"CHECK"
))
{
if
(
!
std
::
strcmp
(
type
,
"INFO"
))
std
::
cout
<<
stream
.
str
()
<<
std
::
endl
;
std
::
cout
<<
s
s
tream
.
str
()
<<
std
::
endl
;
else
std
::
cerr
<<
stream
.
str
()
<<
std
::
endl
;
std
::
cerr
<<
s
s
tream
.
str
()
<<
std
::
endl
;
}
}
};
}
}
#endif
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment