【问题标题】:Can't run VS2010 opencv project from IDE [closed]无法从 IDE 运行 VS2010 opencv 项目 [关闭]
【发布时间】:2013-07-04 13:06:33
【问题描述】:

当我在调试模式下运行 OpenCV 项目时,它会以代码 0 退出。

但这从文件夹运行没有问题。有人可以帮助我。

P.S : 这似乎是 Visual Studio 的一个问题,因为从资源管理器中双击运行程序时,程序运行时没有任何错误。

#include <opencv2/objdetect/objdetect.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

#include <stdio.h>
#include<fstream>
#include <iostream>

using namespace std;
using namespace cv;


int main(int argc, char** argv) {

    VideoCapture capture;
    Mat frame;

    capture.open(0);
    if (capture.isOpened()) {
       while (true) {
            capture >> frame;
            if (!frame.empty()) {
                imshow("Test", frame);
            } else {
                printf(" --(!) No captured frame -- Break!");
                break;
            }

            int c = waitKey(10);
            if ((char) c == 'c') {
                break;
            }
        }
    }
    return 0;
}

【问题讨论】:

  • 程序以什么方式失败?
  • 在 VS2012 / OCV2.4.4 中运行良好。

标签: c++ visual-studio-2010 visual-c++ opencv


【解决方案1】:

退出状态为 0 表示程序成功终止,因此您没有问题。 参见例如What is the difference between exit(0) and exit(1) in C?

【讨论】:

  • 问题不是退出代码。问题是程序在 VS2010 上没有按预期运行,但在使用 explorer/cmd 从外部运行时运行正常。
猜你喜欢
  • 1970-01-01
  • 2020-12-29
  • 1970-01-01
  • 2016-05-26
  • 2016-11-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-03-03
相关资源
最近更新 更多