bitwise_and throws Exception

asked 2017-09-04 07:40:18 -0500

ggotpimus gravatar image

Hi there,

i try to define a mask to gain the raw background of my source Image. My source Image is a floor plan where all objects are colored. Therefore i use the inRange and the bitwise_and function to filter my desired mask and get the Background. But my program is throwing an exception and i don't know how to fix it :(

The code:

Mat mSrc = imread("IMG.png", CV_LOAD_IMAGE_COLOR);
Mat mask = Mat::Zeros(mSrc.size(), CV_8U);

inRang(mSrc, Scalar(90,90,90), Scalar(180,180,180), mask);
cvtColor(mask, mask, CV_GRAY2BGR);

Mat mResult= Mat::Zeros(mSrc.size(), CV_8U);

The output from Visual Studio is:

"Unhandled exception at XXXXXXX in opencvcontourtest.exe: Microsoft C++ exception cv::Exception at Memory Location XXXXXX" kernelbase.pdb contains the debug Information requiered to find the source for the module KernelBase.dll

If i replace the inRange function with rectangle (mask, Point(50,50), Point(400,100), Scalar(255,255,255), -1);, the program runs without any Problems and the masked area is displayed.

Any ideas ?

edit retag flag offensive close merge delete


this is not an opencv exception, but a system one.

can you check, if you accidentally link release libs to a debug build (or vice versa) ?

problem might be in your project, not the code.

berak gravatar imageberak ( 2017-09-05 02:45:34 -0500 )edit