Qt Installation and Setup in Windows with OpenCV ||Embedded Object Detection Project (Part 1)

Qt Installation and Setup in Windows with OpenCV || Qt with OpenCV - Embedded Object Detection Project using Hikvision Industrial Camera (Part 1)

Readme

I am documenting my experience in Qt development and hope that this article will be helpful to developers who are interested in learning and applying Qt. Don’t forget to click the “Follow” button to stay updated with our future posts. Let’s get startttttttttttted!

Introduction to Qt

Qt is a cross-platform application development framework that can run on different operating systems such as Windows, macOS, Linux, Android, and iOS.

Another important feature of Qt is its powerful and flexible GUI (Graphical User Interface) functionality.

Setting up Qt Environment with OpenCV for Windows

Downloading and Installing Qt

I am using an integrated development environment with Visual Studio because it allows me to use Microsoft Visual C++ (MSVC) compiler for Windows program development.

Make sure to install a compiler version that matches your Qt version.

在这里插入图片描述

Here’s the download reference:Setting up Visual Studio + Qt Development Environment
My version: Qt 5.12, which also matches MSVC2015.
在这里插入图片描述

Installing and Configuring OpenCV

Obtain the installation package

compiled version of OpenCV 4.5:

BaiduNetdisk Resources
Enter Code:gfql

Configuring Qt Project to Use OpenCV Library
//Remember to change the path to the local path of your own opencv.
INCLUDEPATH += \
       D:\opencv\build\include\opencv2  \
       D:\opencv\build\include\opencv \
       D:\opencv\build\include \

LIBS += \
       D:\opencv\build\x64\vc14\lib\opencv_world452d.lib \
       D:\opencv\build\x64\vc14\lib\opencv_world452.lib
Executing the Executable File
Method 1: Configuring Environment Variables
D:\opencv\build\bin
D:\opencv\build\x64\vc15\bin
D:\opencv\build\x64\vc15\lib
Method 2: Copying Application Extension Files

Put the following documents under the debug/release directory of your project. 在这里插入图片描述

Where are these files?

opencv\build\x64\vc15\bin

What are these files?

They are dynamic link library files for the OPENCV library.

Why the debug/release directory ?

The debug/release directories are used to store the respective versions of the OpenCV library’s dynamic link library (DLL) files. To ensure that the application runs correctly, it is necessary to copy the required DLL files to the same directory as the executable file of the application.

The path to the debug directory depends on whether you have chosen shadow build.
Apparently, I didn’t choose and my version is debug.
在这里插入图片描述

Shadow build means the build process and generated build artifacts are kept separate from the source code directory.

Example Code

Replace “path_to_image” with the actual path to your image file.
Windows path: D://document//image//44.jpg
Linux path: /home/orin/document/image/44.jpg

#include <QApplication>
#include <opencv2/opencv.hpp>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    // Create OpenCV window
    cv::namedWindow("Image", cv::WINDOW_NORMAL);

    // Load image
    cv::Mat image = cv::imread("path_to_your_image.jpg");

    // Display the image
    cv::imshow("Image", image);

    // 等待键盘输入,以保持窗口打开
    cv::waitKey(0);

    return a.exec();
}

the Issue of the UI Interface Not Updating

Delete all the generated files and Keep only the source files:

This includes any build directories, object files, and executable files that were generated during the compilation process.
The source files typically have extensions like .cpp, .h, .ui (for Qt UI files).

.

Conclusion

In this blog post, we have introduced the Qt framework and discussed its capabilities for cross-platform application development. We have also provided an overview of the installation and setup process for integrating Qt with OpenCV.

In the next part of this series, we will dive deeper into the implementation of the embedded object detection project using the Hikvision industrial camera. Stay tuned!

Don’t forget to click the “Follow” button to stay updated with our future posts. Thank you!

  • 18
    点赞
  • 15
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值