title: How to suppress OpenCV warnings
body: <p>I am trying to run the following code:</p>
  
  <pre><code>int main(int argc, char** argv )
  {
      cv::redirectError(cvNulDevReport);
      std::string address(argv[1]);
      cv::VideoCapture cap(address); // open the camera
      if(!cap.isOpened())  // check if we succeeded
      {
          std::cerr&lt;&lt;"Error: Could not connect to camera.";
          return 0;
      }
      ...
  }
  </code></pre>
  
  <p>Now, i know that whenever the resource referred to by argv[1] is not there, I will get a warning like</p>
  
  <pre><code>warning: Error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:545)
  </code></pre>
  
  <p>What I want is to suppress this and any other warning or error from console output, because I want to supply a simple, more comprehensible error myself. As I understand, the call to cv::redirectError should have worked. I have also tried making a dummy error handler function and calling cv::redirectError with a pointer to that function, but I still get the same warning.</p>
  
  <p>Looking at the source code of the file pointed to by warning, I see that it is CV_WARN macro that is substitued, which, looking from the same source file, is either a call to fprintf or nothing.</p>
  
  <p>Any help is appreciated.</p>