繁体   English   中英

Eclipse 的调试模式下的命令提示符? (OpenCV + Eclipse + Win7)

[英]Command prompt in debug mode for Eclipse? (OpenCV + Eclipse + Win7)

我是 Eclipse 的初学者。 I now have Eclipse C/C++ IDE with OpenCV library running on Windows 7. So far it works after spending hours trying to get it running. 但是后来我意识到 Eclipse 并没有像 VS2010 在调试时那样弹出命令提示符。 而且 Eclipse 的调试模式只是卡在那里并拒绝 output 任何东西。 但如果代码不涉及 OpenCV 事情,它会再次起作用。

下面是我用于测试的代码。 它从网络摄像头和 output 将图像捕获到屏幕上。 无限循环(直到你按下'q')确保它不断地从相机中获取新的输入。

我浏览了工作区并运行了刚刚编译的 exe,它运行完美。 所以我不认为代码有什么问题(无论如何这是一个示例代码

简而言之,我可以在调试模式下弹出命令提示符 window 吗? 当代码涉及一些 OpenCV 功能时,为什么 Eclipse 控制台会卡住?

#include <stdio.h>
#include <stdlib.h>
#include <tchar.h>
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>
#include <iostream>

int _tmain(int argc, _TCHAR* argv[])
{
    CvCapture *capture = 0;
    IplImage  *frame = 0;
    int       key = 0;

    /* initialize camera */
    capture = cvCaptureFromCAM( 0 );

    /* always check */
    if ( !capture ) {
        printf("Cannot open initialize webcam!\n");
        return 1;
    }

    /* create a window for the video */
    cvNamedWindow( "result", CV_WINDOW_AUTOSIZE );

    while( key != 'q' ) {
        /* get a frame */
        frame = cvQueryFrame( capture );

        /* always check */
        if( !frame ) break;

        /* display current frame */
        cvShowImage( "result", frame );

        /* exit if user press 'q' */
        key = cvWaitKey( 1 );
    }

    /* free memory */
    cvDestroyWindow( "result" );
    cvReleaseCapture( &capture );

    return 0;
}

这是因为您已经将 windows 7 系统变量 PATH 设置到 MinGw/bin 并编译 opencv bin 目录。 因此,当您从文件夹运行程序时,系统会自动从其 PATH 中获取所需的二进制文件,并且程序可以正确运行。

我不知道为什么,但 Eclipse 不直接从系统环境 PATH 变量中获取它。 所以我们必须自己设置。

     go to Preferences > C/C++ (Expand it) > Environment > Add:

     "Name:PATH"
      "Value:C:\MinGW\bin;C:\opencv_MinGW\bin"

其中 opencv_MinGW 是我编译 opencv 的文件夹

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM