Skip to content

Commit d07eb9a

Browse files
committed
Merge pull request opencv#9157 from zhmu:opencv-dshow-allow-enable-disable-of-debug-messages
2 parents 5a54ace + df7fb00 commit d07eb9a

File tree

1 file changed

+9
-20
lines changed

1 file changed

+9
-20
lines changed

modules/videoio/src/cap_dshow.cpp

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -337,11 +337,17 @@ interface ISampleGrabber : public IUnknown
337337
#ifdef _DEBUG
338338
#include <strsafe.h>
339339

340-
//change for verbose debug info
341-
static bool gs_verbose = true;
342-
343340
static void DebugPrintOut(const char *format, ...)
344341
{
342+
static int gs_verbose = -1;
343+
if (gs_verbose < 0)
344+
{
345+
// Fetch initial debug state from environment - defaults to disabled
346+
const char* s = getenv("OPENCV_DSHOW_DEBUG");
347+
gs_verbose = s != NULL && atoi(s) != 0;
348+
}
349+
350+
345351
if (gs_verbose)
346352
{
347353
va_list args;
@@ -487,9 +493,6 @@ class videoInput{
487493
videoInput();
488494
~videoInput();
489495

490-
//turns off console messages - default is to print messages
491-
static void setVerbose(bool _verbose);
492-
493496
//Functions in rough order they should be used.
494497
static int listDevices(bool silent = false);
495498

@@ -1130,20 +1133,6 @@ videoInput::videoInput(){
11301133

11311134
}
11321135

1133-
1134-
// ----------------------------------------------------------------------
1135-
// static - set whether messages get printed to console or not
1136-
//
1137-
// ----------------------------------------------------------------------
1138-
1139-
void videoInput::setVerbose(bool _verbose){
1140-
#ifdef _DEBUG
1141-
gs_verbose = _verbose;
1142-
#else
1143-
(void)_verbose; // Suppress 'unreferenced parameter' warning
1144-
#endif
1145-
}
1146-
11471136
// ----------------------------------------------------------------------
11481137
// change to use callback or regular capture
11491138
// callback tells you when a new frame has arrived

0 commit comments

Comments
 (0)