Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ Visual Studio调试器失败,但程序在生成时运行正常。。。?_C++_Visual Studio 2010_Visual Studio Debugging - Fatal编程技术网

C++ Visual Studio调试器失败,但程序在生成时运行正常。。。?

C++ Visual Studio调试器失败,但程序在生成时运行正常。。。?,c++,visual-studio-2010,visual-studio-debugging,C++,Visual Studio 2010,Visual Studio Debugging,我正在做一个立体视差程序,我有左和右的图像,我正试图读入。然而,我在尝试调试时遇到了一个错误,但是如果我只是构建它,它就可以正常工作…所以我只是将代码简化为一些非常简单的东西 #include <bunch of opencv bits...> using namespace std; using namespace cv; int main() { Mat Left= imread("Left.png", 0); //read images as grayscal

我正在做一个立体视差程序,我有左和右的图像,我正试图读入。然而,我在尝试调试时遇到了一个错误,但是如果我只是构建它,它就可以正常工作…所以我只是将代码简化为一些非常简单的东西

#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);
    }

}
使用debug F5运行时,我到达行imshowleet,Left;它崩溃了,报告 OpenCV错误:错误的标志参数或结构字段无法识别或不支持数组类型…诸如此类

在代码中,我可以看到没有读取存储在左侧或右侧的内容

然而,真正令人困惑的是,如果我只是构建程序F7并从explorer Misc Projects\SteroExp\Debug运行.exe。。。。它运行完全正常

我的想法。。。。 VS是否从PC上未存储映像的其他临时目录运行调试版本


我在用。。。W7 64位、VS2010、C++、OpenCV 2.3.1

< P>问题是当前工作目录。从资源管理器运行时,当前目录为“Misc Projects\SteroExp\Debug”,但从调试器运行时,当前目录为“Misc Projects\SteroExp”。答案是将图像文件移动到正确的目录。

首先,仔细检查Project | Properties | Debugging>WorkingDirectory中的工作目录是否设置为包含这两个文件的目录。

闻起来像是未定义的行为HMMM这是否意味着我永远无法调试此程序?我刚刚尝试将Left.png和Right.png移到Misc Projects\SteroExp,但它仍然无法在debug中运行。它被设置为$ProjectDir,不确定它指向哪里,但我将它改为Misc Projects\SteroExp\Debug dir。现在可以了,谢谢。默认工作目录是Misc Projects\SteroExp\SteroExp,项目文件存储在这里。从工作目录下拉列表中选择,然后点击宏>>。键入ProjectDir并查看其实际值。它应该指向包含.vcxproj文件的项目目录。