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!文章来源:https://www.toymoban.com/news/detail-832806.html
Don’t forget to click the “Follow” button to stay updated with our future posts. Thank you!文章来源地址https://www.toymoban.com/news/detail-832806.html
到了这里,关于Qt Installation and Setup in Windows with OpenCV ||Embedded Object Detection Project (Part 1)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!