How do you set up OpenCV with QT in OSX?

橙三吉。 提交于 2019-12-23 05:26:07

问题


I want to use the new C++ OpenCV interface to create Qt applications in Qt Creator on OS X Snow Leopard. How can I do this? Good explanations of this are very hard to come by online.


回答1:


I actually did this, and it was fairly easy. You can download QtSDK from the qt-website as a dmg, installing that is just click-and-play.

After this I used MacPorts, MacPorts is a package-manager (like aptitude, portage, pacman, etc) for osx. http://www.macports.org/, download it, and again: click-and-play.

To use MacPorts, you first need tools like make and gcc/g++ to work. These are included in the package xcode (which is in the apple store). Of course, these tools are as important as a cpu to a developer. You would want them in the first place.

After installing xcode, make/g++/gcc are on your system, yet they are not in your path. In a terminal, the commands won't exist. To fix this, open the xcode ide (If I am allowed to call it an ide, am I?). Then goto XCode (lop left screen)-> Preferences -> Downloads. There you can install the 'Command Line Tools', do this.

Then make should be there. Use a terminal to verify. Just typing make will probably message you 'make: * No targets specified and no makefile found. Stop.', but not 'command not found'.

Then, to install opencv I installed MacPorts, type 'sudo port install opencv', wait a while and if all went well, you should have opencv. It is installed in /opt/local. Therefore you might need to add these to your .pro-file:

CONFIG += MYHOTOSXMACHINE

MYHOTOSXMACHINE {
    INCLUDEPATH += /opt/local/include/
    LIBS += -L/opt/local/lib/
}

So, there you go. Good luck!

PS: I not new to the whole linux/gnu/posix thing, yet I am new to osx. So if there is a cleaner way to do this, feel free to comment.



来源:https://stackoverflow.com/questions/7403455/how-do-you-set-up-opencv-with-qt-in-osx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!