集成 QT 和 OpenCV?

发布于 2024-10-30 19:02:27 字数 616 浏览 1 评论 0原文

我尝试将 QT 和 OpenCV 与以下 .pro 集成,但仍然收到有关链接的错误。

######################################################################
# Automatically generated by qmake (2.01a) Wed Apr 6 17:34:22 2011
######################################################################

TEMPLATE = app
TARGET = 
DEPENDPATH += .
INCLUDEPATH += .
QT+=opengl
# Input
HEADERS += glwidget.h mainwindow.h ui_info.h ui_information.h
FORMS += mainwindow.ui
SOURCES += glwidget.cpp main.cpp mainwindow.cpp
RESOURCES += res.qrc

INCLUDEPATH += /usr/local/include/opencv 
LIBS += /Library/Frameworks/OpenCV/lib

知道我能做什么吗?

I tried integrating QT and OpenCV with the following .pro but I still get errors about linking.

######################################################################
# Automatically generated by qmake (2.01a) Wed Apr 6 17:34:22 2011
######################################################################

TEMPLATE = app
TARGET = 
DEPENDPATH += .
INCLUDEPATH += .
QT+=opengl
# Input
HEADERS += glwidget.h mainwindow.h ui_info.h ui_information.h
FORMS += mainwindow.ui
SOURCES += glwidget.cpp main.cpp mainwindow.cpp
RESOURCES += res.qrc

INCLUDEPATH += /usr/local/include/opencv 
LIBS += /Library/Frameworks/OpenCV/lib

any idea what I can do?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蓝眼睛不忧郁 2024-11-06 19:02:27

如果您在此配置中缺少库名称,请指定库名称,如下所示:

LIBS += -L/usr/local/lib -lcv -lhighgui

库名称可能会随 OpenCV 版本的不同而变化,因此您必须查看 OpenCV 文档。
更简单的方法是通过在项目 .pro 文件中将 INCLUDEPATH 和 LIBS 替换为以下内容来使用 pkg-config:

CONFIG += link_pkgconfig
PKGCONFIG += opencv

you are missing library name in this configuration, specify the libs names as following:

LIBS += -L/usr/local/lib -lcv -lhighgui

Library names can change with versions of OpenCV, so you have to look at OpenCV documentation.
A simpler method will be to use pkg-config by replacing INCLUDEPATH and LIBS with the following in your project .pro file:

CONFIG += link_pkgconfig
PKGCONFIG += opencv
陌若浮生 2024-11-06 19:02:27

我终于找到了解决方案。我已经移动了我的博客,我很快就会再次发布。如果您需要的话请私信我,我会发给您!

I Finally found a solution. I Have moved my blog I will post again soon. If you need it just msg me and I will send to you!

热风软妹 2024-11-06 19:02:27

尝试将库的文件名添加到路径中。 LIBS += /Library/Frameworks/OpenCV/lib/opencv.lib

try to add the filename of the lib to the path. LIBS += /Library/Frameworks/OpenCV/lib/opencv.lib

彩扇题诗 2024-11-06 19:02:27

链接外部库(如 OpenCV)的最简单、最可靠的方法是使用 Qt Creator 中的“添加库”向导。

下面列出的步骤可在 Qt5 文档中找到: [ http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html][1] 在“添加库”部分下。

  1. 右键单击位于创建器左侧“项目窗格”中的项目文件...并选择“添加库...”
  2. 按照向导的说明进行操作

让我从此处添加一些特殊性...

  1. 选择“ 对于“库文件”
  2. ,导航到 opencv_worldXXX.lib 文件(或 opencv_worldXXXd.lib 文件,您会注意到,通过仅指定其中一个或另一个,向导会出现一个自动包含另一个的复选框)[ex 。 ...\opencv\build\x64\vc12\lib\opncv_world.lib]
  3. 对于“包含文件夹”,导航到构建中的“包含”文件夹。 [例如。 ...\opencv\build\include]
  4. 选择您的操作系统、动态/静态库(以合适的为准)
  5. 点击“下一步”,“清理”,然后“运行”!

The EASIEST and most SURE way to link an external library like OpenCV is to use the "Add Library" wizard inside Qt Creator.

The steps listed below are found in the Qt5 documentation: [http://doc.qt.io/qtcreator/creator-project-qmake-libraries.html][1] under the "To Add Library" section.

  1. Right click on the project file located in the 'project pane' on the left side of the creator... and select "Add Library..."
  2. Follow the instructions of the wizard

Let me add some specificity from here...

  1. Select "External Library"
  2. For the "Library File" navigate to your opencv_worldXXX.lib file (or opencv_worldXXXd.lib file, you will notice that by specifying only one or the other the wizard has a checkbox which includes the other automatically) [ex. ...\opencv\build\x64\vc12\lib\opncv_world.lib]
  3. For the "Include Folder" navigate to the "include" folder within the build. [ex. ...\opencv\build\include]
  4. Select your operating system, dynamic/static library (whichever is appropriate)
  5. Hit NEXT, CLEAN UP, and RUN!
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文