I'm working on a stereo disparity program, I have left and right images that I'm trying to read in. However I'm getting an error when trying to debug, but it works fine if I just build it...So I've just reduced the code to something very simple...
#include <bunch of opencv bits...>
using namespace std;
using namespace cv;
int main()
{
Mat Left= imread("Left.png", 0); //read images as grayscale
Mat Right= imread("Right.png", 0);
while (true) {
imshow("Left",Left);
imshow("Right",Right);
}
}
Running with debug (F5) I get to the line imshow("Left",Left); and it crashes, reporting OpenCV Error: Bad flag (parameter or structure field) (unrecognized or unsupported array type) ....blah blah
Stepping through the code I can see that nothing is read stored in Left or Right
However where things get really confusing is if I just build the program (F7) and run the .exe from explorer (Misc Projects\SteroExp\Debug).... it runs completely fine.
My thoughts.... Does VS run the debug version from a different temp directory somewhere on the PC where the images aren't stored?
I'm using... W7 64bit, VS2010, C++, OpenCV 2.3.1
-
smells like undefined behaviourAndrew– Andrew2012年08月03日 09:58:19 +00:00Commented Aug 3, 2012 at 9:58
-
hmmm does this mean I can never debug this program?YMDW– YMDW2012年08月03日 10:27:44 +00:00Commented Aug 3, 2012 at 10:27
2 Answers 2
First, double-check that the working directory in Project | Properties | Debugging> WorkingDirectory is set to a directory that contains those two files.
2 Comments
The problem is the current working directory. When you run from explorer the current directory is 'Misc Projects\SteroExp\Debug' but when you from from the debugger it's 'Misc Projects\SteroExp'. The answer is to move your image files to the correct directory.
1 Comment
Explore related questions
See similar questions with these tags.