gpt4 book ai didi

windows - 如何让OpenCV在Windows下工作?

转载 作者:可可西里 更新时间:2023-11-01 11:38:06 24 4
gpt4 key购买 nike

我无法在 Windows 下启动 OpenCV 应用程序。

给定以下简单的 OpenCV 程序:

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

#include "cv.h"
#include "highgui.h"

char imagename[100] = "sudoku.jpg";

IplImage* img;

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

cvNamedWindow("Example4", CV_WINDOW_AUTOSIZE);
IplImage* img = cvLoadImage(imagename);

cvShowImage("Example4", img);
cvWaitKey(0);
cvDestroyWindow("Example4");
return (0);
}

我可以编译并开始使用预编译的 OpenCV 库版本 2.2,引用的图像出现在窗口中。 (编译确实使用 netbeans 和 cygwin 或自己的 5 行 makefile 和 minGW 工作)。然后我想在 OpenCV 中使用 C++ 函数调用但是编译没有工作所以基于 this answer我决定按照 this installation guide 重新编译 OpenCV和 this getting started guide .

使用 minGW 和 CMake 编译 OpenCV 毫无怨言。我没有使用任何可选包进行 opencv 编译。

不幸的是,没有程序可以启动,因为只出现一个灰色窗口,之后应用程序崩溃,Windows 给出以下错误消息:

Problem signature:
Problem Event Name: APPCRASH
Application Name: main.exe
Application Version: 0.0.0.0
Application Timestamp: 4de3a2d9
Fault Module Name: libopencv_highgui220.dll
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 4dcd07e6
Exception Code: c0000005
Exception Offset: 0002def4
OS Version: 6.1.7600.2.0.0.256.4
Locale ID: 1033
Additional Information 1: 0a9e
Additional Information 2: 0a9e372d3b4ad19135b953a78882e789
Additional Information 3: 0a9e
Additional Information 4: 0a9e372d3b4ad19135b953a78882e789

可能是什么问题?

我尝试使用我自己的 Makefile 和 Cmake-gui 从 Netbeans 进行编译,并且执行程序的创建没有问题。我在 PATH 中包含了 opencv bin 目录,以使提到的 libopencv_highgui220.dll 可见。

更新:

按照前面的步骤,我在 Windows XP Professional 上得到了完全相同的结果:opencv 和项目构建正常,但运行挂起。这台机器上没有其他 C、C++、编译器和 IDE 可能会干扰我的 opencv 编译。

最佳答案

我已经发布了 same question在 opencv 论坛上,我得到了答案。

问题是我使用 lib 或 bin opencv 目录进行链接和 PATH。使用安装指南,我发现我必须使用 lib 目录作为 PATH 的链接和 bin 目录。 lib 中的 dll.a 和 bin 中的 dll 的组合用法对我来说是新的。

所以我关注了CodeBlocks+MinGW guid e一步步解决问题,而且当我使用之前构建的未使用 CodeBlocks 的 MinGW opencv 时,C 或 C++ 代码运行正常。

关于windows - 如何让OpenCV在Windows下工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6210584/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com