Qt Installation and Setup in Linux with OpenCV || Qt with OpenCV - Embedded Object Detection Project using Hikvision Industrial Camera (Part 2)
Readme
Hi! This is my second post on Qt development about how to set up Qt with opencv in Linux System, compared with the last blog talking about Windows environment. Thanks for ur support and don’t forget to click the “Follow” button to keep up with the project !! Enjoyyyyyyy!
Qt Installation and Setup in Linux with OpenCV
Installing and Configuring OpenCV
Download :
Choose the source code of the opencv 4.5.5 (recommend )
If you encounter difficulties accessing the official OpenCV website which may require VPN
you can visit the Mirrored Site
Install and Configure :
To install and configure OpenCV, you can follow the steps outlined in the Reference article.
Configuring Qt Project to Use OpenCV Library
INCLUDEPATH += /home/orin/opencv/opencv-4.5.5\
/home/orin/opencv/opencv-4.5.5/include\
/home/orin/opencv/opencv-4.5.5/include/opencv2
LIBS += /home/orin/opencv/build/lib/libopencv_highgui.so \
/home/orin/opencv/build/lib/libopencv_highgui.so.405 \
/home/orin/opencv/build/lib/libopencv_core.so \
/home/orin/opencv/build/lib/libopencv_imgproc.so \
/home/orin/opencv/build/lib/libopencv_imgcodecs.so
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文章来源:https://www.toymoban.com/news/detail-826653.html
#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();
}
Problems still to be solved
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main() {
cv::Mat image = cv::Mat::zeros(400, 400, CV_8UC3);
// 创建一个矩形框
cv::Rect boundingRect(100, 100, 200, 200);
// 在图像上绘制矩形
cv::rectangle(image, boundingRect, cv::Scalar(0, 255, 0), 109);
// 显示图像
cv::imshow("Rectangle Test", image);
cv::waitKey(0);
}
In the image titled ‘Rectangle Test’ (shown in the link), it can be observed that there is no rectangle present. Despite my efforts, I have been unable to resolve this issue thus far. If you possess knowledge regarding the cause of the problem or have a potential solution, please reach out to me via private message. I would be grateful for your assistance, and I am looking forward to updating the blog post with your name credited for providing the solution.文章来源地址https://www.toymoban.com/news/detail-826653.html
到了这里,关于Qt Installation and Setup in Linux with OpenCV||Embedded Object Detection Project (Part 2)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!