C ++ Eclipse OpenCV:.exe文件和二进制文件已生成,但未显示任何图像 [英] C++ Eclipse OpenCV : .exe file and binaries generated, but no image displayed

查看:65
本文介绍了C ++ Eclipse OpenCV:.exe文件和二进制文件已生成,但未显示任何图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码(OpenCV文档中的第一个DisplayImage.cpp代码)

Here's my code (the first DisplayImage.cpp code in the OpenCV documentation)

/*
 * DisplayImage.cpp
 *
 *  Created on: Dec 25, 2011
 *      Author: Arcturus */       
 #include <iostream>    
 #include <opencv2\opencv.hpp>

using namespace cv;

using namespace std;

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

    Mat image;

    image = imread(argv[1], 1);

    if(argc!=2 || !image.data){

        cout<<"no image data";

        return -1;
    }

    namedWindow("Display Image", CV_WINDOW_AUTOSIZE);

    imshow("Display Image", image);

    waitKey(10000);

    return 0;
}

构建完整的可执行文件,并生成二进制文件。

Build complete, executable generated, binaries generated.

我在DisplayImage Debug文件夹中有我的图像-blackbuck.bmp-。要运行代码,请转到运行>运行配置。选择DisplayImage Debug exe文件,键入blackbuck.bmp(也使用绝对路径尝试了它)并运行它。

I have my image - blackbuck.bmp- in the DisplayImage Debug folder. To run the code, I go to Run> Run Configurations. Select the DisplayImage Debug exe file, key in blackbuck.bmp (also tried it with absolute path) and run it.

在控制台顶部,我收到消息:DisplayImage Debug。而且它根本不显示图像。

On the top of the console, I get the message : DisplayImage Debug. And it displays no image at all. What could be wrong here?

我正在使用CDT在Eclipse上运行它。

I am running it on Eclipse, using CDT.

谢谢您的时间!

编辑:问题已解决!!!我必须将所有dll文件从库文件夹复制到生成可执行文件的文件夹中。我仍然不明白为什么。毕竟,链接器已经在链接包含所有dll的库文件夹。如果有人可以解释这一点,它将对以后的调试有很大的帮助。谢谢karl和mevotron的宝贵时间:)

Problem solved!!! I had to copy all the dll files from the library folder to the folder in which my executable file was being generated. I still do not understand why, though. After all, the linker was already linking the library folder containing all the dlls. If someone could explain this, it would be of great help for future debugging. Thank you karl and mevotron for your time :)

编辑2:从msdn网站:
使用DLL的潜在缺点是应用程序不可用自包含的;这取决于是否存在单独的DLL模块;如果进程需要在进程启动时找不到的DLL并向用户提供错误消息,则系统使用加载时动态链接终止进程。在这种情况下,可以使用运行时动态链接来终止进程,但是缺少的DLL导出的功能对该程序不可用。

EDIT 2: From the msdn website: "A potential disadvantage to using DLLs is that the application is not self-contained; it depends on the existence of a separate DLL module. The system terminates processes using load-time dynamic linking if they require a DLL that is not found at process startup and gives an error message to the user. The system does not terminate a process using run-time dynamic linking in this situation, but functions exported by the missing DLL are not available to the program."

我认为这回答了我的问题。也许这意味着eclipse使用加载时动态链接。

I think this answers my question. Perhaps this means eclipse uses load-time dynamic linking.

推荐答案

您如何使用MinGW编译OpenCV(即,您的 BUILD_TYPE SSE * 选项在CMake配置期间设置为)?我问的原因是,在使用MinGW构建版本时,SSE优化存在一个已知的错误,该错误会导致 highgui 操作崩溃。看到我的其他答案这里

How did you compile OpenCV with MinGW (i.e., what were your BUILD_TYPE and SSE* options set to during the CMake configuration)? The reason I ask, is that there is a known bug with SSE optimizations that will cause highgui operations to crash when using MinGW built versions. See my other SO answer here.

这篇关于C ++ Eclipse OpenCV:.exe文件和二进制文件已生成,但未显示任何图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆