一.Opencv安装
-
官网下载Opencv安装包
- 双击下载的软件进行解压
3. 系统环境变量添加
二.Qt搭建opencv开发环境
-
创建一个新的Qt项目(Non-Qt Project)
-
打开创建好的项目中的CMakeLists.txt,添加如下代码
# opencv set(OpenCV_DIR "C:\\Program Files\\opencv454\\build") set(OpenCV_INCLUDE_DIRS ${OpenCV_DIR}\\include) set(OpenCV_LIB_DIRS ${OpenCV_DIR}\\x64\\vc15\\lib) set(OpenCV_Debug_LIBS "opencv_world454d.lib") set(OpenCV_Release_LIBS "opencv_world454.lib") include_directories(${OpenCV_INCLUDE_DIRS}) link_directories(${OpenCV_LIB_DIRS}) target_link_libraries(${PROJECT_NAME} PUBLIC ${OpenCV_Debug_LIBS}) target_link_libraries(${PROJECT_NAME} PUBLIC ${OpenCV_Release_LIBS})
-
main.cpp中添加以下代码文章来源:https://www.toymoban.com/news/detail-611588.html
#include <iostream> #include <opencv2/opencv.hpp> using namespace std; int main() { cv::Mat img = cv::Mat::zeros(cv::Size(512, 512), CV_8UC3); cv::putText(img, "Hello OpenCV", cv::Point(128, 256), 5, 2, cv::Scalar(0, 0, 255), 3, 8); cv::imshow("img", img); cv::waitKey(0); return 0; }
-
点击运行,显示图像则说明环境搭建成功
文章来源地址https://www.toymoban.com/news/detail-611588.html
到了这里,关于Opencv Win10+Qt+Cmake 开发环境搭建的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!