QT5.2+vs2012+opencv2.4.7环境配置
如果你安装的是使用Microsoft Visual Studio编译器的Qt(例如我安装的这个Qt,安装包文件名为:qt-windows-opensource-5.2.0- msvc 2012-x86-offline.exe),则不需要网传的对OpenCV进行编译的这个麻烦过程,直接利用VS的预编译文件即可。 需要注意的一点是Q
如果你安装的是使用Microsoft Visual Studio编译器的Qt(例如我安装的这个Qt,安装包文件名为:qt-windows-opensource-5.2.0-msvc2012-x86-offline.exe),则不需要网传的对OpenCV进行编译的这个麻烦过程,直接利用VS的预编译文件即可。
需要注意的一点是Qt不支持Visual Studio Express版。另外你最好先在Visual Studio下完成OpenCV简单demo的编译(参看我之前的博文),确保OpenCV环境设置正确。
使用Qt Creator这个IDE而不是VS的好处在于Qt Creator能够非常方便地调用所有Qt的组件,而且更加轻量级、启动也很快速,开发跨平台应用时也更加方便(主流平台下都有Qt Creator,而只有Windows才有Visual Studio)。
Qt程序的项目配置文件保存在.pro文件里,类似于VS2012中所配置的,Qt也没有“全局”的INCLUDE和LIB(库)路径的修改功能,而是通过对pro文件的改动来配置编译时需要包含的路径和库文件。
在Qt Creator里,新建一个项目,Qt控制台应用就可以了。然后在“编辑”面板里打开项目的pro文件,如下图所示:
添加下面几行:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
|
路径使用斜杠(/)而不是反斜杠(\),INCLUDEPATH是项目编译时会包含的头文件目录,后面加上的是OpenCV预编译文件的include(这里的路径和我之前那篇Visual Studio 2012配置OpenCV环境的是一样的),LIBS则是编译时需要链接的文件,-L后紧跟的是目录,-l后则紧跟对应的动态链接,和VS中不太一样的是不用写出完整的文件名(没有后面的.lib后缀),和VS2012中类似的则是这里通过CONFIG来确认编译类型是debug还是release来使用debug链接或release链接。前面用win32则保证这些链接仅在Windows下编译时被链接器链接。
前面几行的末尾的反斜杠是用来把一行内容分成多行写(类似C++的语法),这样做的目的主要是清晰易读,不必写一行超长的语句。
pro文件修改完成后保存,回到main.cpp文件里,一个简单的OpenCV demo内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
它会载入D:/demo.png这个图片文件,你可能需要进行一些改动以便让该demo顺利运行。另外之前改动了pro文件,但是Qt Creator很可能认为项目配置没有变化,因此不会自动重新运行qmake,需要手动运行一次以免出现“LNK 2019”链接错误或者找不到包含目录的错误。“构建->执行qmake”,然后再“构建->重新构建项目”。以后没有改动pro的话,就不需要执行qmake了,直接点左侧面板上那个榔头(Ctrl+B)构建项目就可以了,绿色三角形(Ctrl+R)运行程序,绿色三角形带虫子(F5)调试程序。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











Title: How to correctly configure Git in PyCharm In modern software development, the version control system is a very important tool, and Git, as one of the popular version control systems, provides developers with powerful functions and flexible operations. As a powerful Python integrated development environment, PyCharm comes with support for Git, allowing developers to manage code versions more conveniently. This article will introduce how to correctly configure Git in PyCharm to facilitate better development during the development process.

Title: The working principle and configuration method of GDM in Linux systems In Linux operating systems, GDM (GNOMEDisplayManager) is a common display manager used to control graphical user interface (GUI) login and user session management. This article will introduce the working principle and configuration method of GDM, as well as provide specific code examples. 1. Working principle of GDM GDM is the display manager in the GNOME desktop environment. It is responsible for starting the X server and providing the login interface. The user enters

PyCharm is a powerful integrated development environment (IDE), and PyTorch is a popular open source framework in the field of deep learning. In the field of machine learning and deep learning, using PyCharm and PyTorch for development can greatly improve development efficiency and code quality. This article will introduce in detail how to install and configure PyTorch in PyCharm, and attach specific code examples to help readers better utilize the powerful functions of these two. Step 1: Install PyCharm and Python

Understanding Linux Bashrc: Function, Configuration and Usage In Linux systems, Bashrc (BourneAgainShellruncommands) is a very important configuration file, which contains various commands and settings that are automatically run when the system starts. The Bashrc file is usually located in the user's home directory and is a hidden file. Its function is to customize the Bashshell environment for the user. 1. Bashrc function setting environment

How to configure a workgroup in Win11 A workgroup is a way to connect multiple computers in a local area network, which allows files, printers, and other resources to be shared between computers. In Win11 system, configuring a workgroup is very simple, just follow the steps below. Step 1: Open the "Settings" application. First, click the "Start" button of the Win11 system, and then select the "Settings" application in the pop-up menu. You can also use the shortcut "Win+I" to open "Settings". Step 2: Select "System" In the Settings app, you will see multiple options. Please click the "System" option to enter the system settings page. Step 3: Select "About" In the "System" settings page, you will see multiple sub-options. Please click

Title: How to configure and install FTPS in Linux system, specific code examples are required. In Linux system, FTPS is a secure file transfer protocol. Compared with FTP, FTPS encrypts the transmitted data through TLS/SSL protocol, which improves Security of data transmission. In this article, we will introduce how to configure and install FTPS in a Linux system and provide specific code examples. Step 1: Install vsftpd Open the terminal and enter the following command to install vsftpd: sudo

MyBatisGenerator is a code generation tool officially provided by MyBatis, which can help developers quickly generate JavaBeans, Mapper interfaces and XML mapping files that conform to the database table structure. In the process of using MyBatisGenerator for code generation, the setting of configuration parameters is crucial. This article will start from the perspective of configuration parameters and deeply explore the functions of MyBatisGenerator.

DRBD (DistributedReplicatedBlockDevice) is an open source solution for achieving data redundancy and high availability. Here is the tutorial to install and configure DRBD on CentOS7 system: Install DRBD: Open a terminal and log in to the CentOS7 system as administrator. Run the following command to install the DRBD package: sudoyuminstalldrbd Configure DRBD: Edit the DRBD configuration file (usually located in the /etc/drbd.d directory) to configure the settings for DRBD resources. For example, you can define the IP addresses, ports, and devices of the primary node and backup node. Make sure there is a network connection between the primary node and the backup node.
