I am trying to run the following 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<<"Error: Could not connect to camera.";
return 0;
}
...
}
Now, i know that whenever the resource referred to by argv[1] is not there, I will get a warning like
warning: Error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:545)
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.
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.
Any help is appreciated.