opencv程序仅在附加调试器时崩溃

时间:2015-12-25 17:25:56

标签: c++ debugging opencv

#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include "opencv2/opencv.hpp"
#include <opencv2/highgui.hpp>
#include <iostream>
#include <Windows.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <direct.h>
#pragma comment(lib, "vfw32.lib")
#pragma comment( lib, "comctl32.lib" )
using namespace cv;
using namespace std;

void PrintFullPath(char * partialPath)
{
    char full[_MAX_PATH];
    if (_fullpath(full, partialPath, _MAX_PATH) != NULL)
        printf("Full path is: %s\n", full);
    else
        printf("Invalid path\n");
}

int main(int argc, char** argv)
{
    PrintFullPath(".\\");
    Mat edges;
    VideoCapture cap;
    try
    {
        cap.open(0); // open the default camera
    }
    catch (...)
    {
        cout << "error!!" << endl;
    }
    if (!cap.isOpened())  // check if we succeeded
        return -1;
    //Mat edges;
    namedWindow("edges", 1);
    for (;;)
    {
        Mat frame;
        cap >> frame; // get a new frame from camera
        edges = frame;
        GaussianBlur(edges, edges, Size(7, 7), 1.5, 1.5);
        //Canny(edges, edges, 0, 30, 3);
        //Sleep(2000);
        imshow("edges", edges);
        if (waitKey(30) >= 0) break;
    }
    return 0;
}

程序在连接调试器时崩溃,当我按f5时它会在“cap.open(0)”行中崩溃,但是当我按下cntrol f5它运行完美时。

我得到的错误是:

opencv_1.exe中0x09068EFB处的未处理异常:0xC0000005:访问冲突执行位置0x09068EFB。

即时通讯使用visual studio 2013,Windows 8.0,opencv 3.0。

如果我在命令行中运行exe文件,prorgam运行完美。

0 个答案:

没有答案