简体   繁体   English

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

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

I am a beginner for Eclipse.我是 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. 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. But then I realize that Eclipse does not pop up a command prompt as VS2010 does while debugging.但是后来我意识到 Eclipse 并没有像 VS2010 在调试时那样弹出命令提示符。 And moreover Eclipse's debug mode is just stuck in there and refuse to output anything.而且 Eclipse 的调试模式只是卡在那里并拒绝 output 任何东西。 But if the code doesn't involve the OpenCV things it works again.但如果代码不涉及 OpenCV 事情,它会再次起作用。

Below is the code I use for testing.下面是我用于测试的代码。 It captures images from webcam and output it to the screen.它从网络摄像头和 output 将图像捕获到屏幕上。 The infinite loop (until you press 'q') makes sure it constantly grabs new inputs from the camera.无限循环(直到你按下'q')确保它不断地从相机中获取新的输入。

I browsed through the workspace and run the exe just compiled and it worked flawlessly.我浏览了工作区并运行了刚刚编译的 exe,它运行完美。 So I don't think there's anything wrong in the code (it's an example code anyway所以我不认为代码有什么问题(无论如何这是一个示例代码

In brief, can I just pop up a command prompt window in debug mode?简而言之,我可以在调试模式下弹出命令提示符 window 吗? And why is Eclipse console stuck when the code involves some OpenCV functions?当代码涉及一些 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;
}

This is because you have already set the windows 7 system variable PATH to your MinGw/bin and compiled opencv bin directories.这是因为您已经将 windows 7 系统变量 PATH 设置到 MinGw/bin 并编译 opencv bin 目录。 So when you run the program from your folder your system automatically take the required binaries from its PATH and the program runs correctly.因此,当您从文件夹运行程序时,系统会自动从其 PATH 中获取所需的二进制文件,并且程序可以正确运行。

I don't know why but Eclipse does not take it directly from the system environment PATH variable.我不知道为什么,但 Eclipse 不直接从系统环境 PATH 变量中获取它。 So we have to set it ourself.所以我们必须自己设置。

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

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

where opencv_MinGW is the folder where I compiled my opencv其中 opencv_MinGW 是我编译 opencv 的文件夹

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

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