Skip to content

Commit df7fb00

Browse files
zhmurs-ph-lps
authored andcommitted
dshow: Only show debugging messages if environment variable OPENCV_DSHOW_DEBUG is explicitly set to non-zero
Based on discussion at: opencv#9051
1 parent 3ce1bca commit df7fb00

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

@@ -1120,20 +1123,6 @@ videoInput::videoInput(){
11201123

11211124
}
11221125

1123-
1124-
// ----------------------------------------------------------------------
1125-
// static - set whether messages get printed to console or not
1126-
//
1127-
// ----------------------------------------------------------------------
1128-
1129-
void videoInput::setVerbose(bool _verbose){
1130-
#ifdef _DEBUG
1131-
gs_verbose = _verbose;
1132-
#else
1133-
(void)_verbose; // Suppress 'unreferenced parameter' warning
1134-
#endif
1135-
}
1136-
11371126
// ----------------------------------------------------------------------
11381127
// change to use callback or regular capture
11391128
// callback tells you when a new frame has arrived

0 commit comments

Comments
 (0)