• windows10 vs2019 版本:cmake将 opencv_contrib-4.5.5 扩展模块编译添加到 opencv-4.5.5 正式版中


    ******  opencv-4.5.5 和 opencv_contrib-4.5.5 区别

    opencv-4.5.5:包含常用的稳定的视觉与图像的算法模块。

    opencv_contrib-4.5.5:收录一些具有专利的算法(如SURF)以及一些还没有稳定的算法模块(如ARUCO)。

    环境准备:window10+vs2019+opencv-4.5.5+opencv_contrib-4.5.5+cmake

    vs2019下载地址:https://www.onlinedown.net/soft/1226702.htm

    opencv 主页:https://github.com/opencv

    opencv-4.5.5源码下载:https://github.com/opencv/opencv/releases

     opencv_contrib源码下载:https://github.com/opencv/opencv_contrib/tree/4.5.5

     cmake下载:https://cmake.org/download/

    下载的文件目录如下:

    一.  准备文件

    1. 双击 cmake-3.24.0-rc2-windows-x86_64 安装cmake,并将安装路径:C:\Program Files\CMake\bin 添加到系统变量中

     2. 解压 opencv_contrib-4.5.5.zip 和  opencv-4.5.5.zip 到当前文件夹,并创建一个新的文件夹opencv-build 用来存放两者编译合并后的文件

     二.  编译opencv和opencv_contrib

    1. 打开cmake ,填写opencv-4.5.5 路径以及 opencv-build 路径

    2. 点击Configure 按钮,弹出对话框,选择所安装visual studio 版本(vs2019),选择use default native compilers ,点击finish 开始编译(编译的时候尽量连接稳定的网络)

     **** 会出现很多红色的话,就再点击一次Configure

     成功后,显示configuring done

    3. 开始添加 opencv_contrib-4.5.5 ,并配置

    1)在搜索框搜索OPENCV_EXTRA_MODULES_PATH ,并点击右侧选取opencv_contrib-4.5.5路径;

    2)在搜索框搜索OPENCV_ENABLE_NONFREE(如果没有选中,那么类似SIFT这种已经被申请专利的方法就无法使用),并打上对号

     3)在搜索框搜索 BUILD_opencv_world(不配置无法使用world 库), 并打上对号

     4)点击 Configure ,如果显示红色,再次点击Configure,显示全白色后,点击Generate,成功后,显示configuring done Generating done

     4. vs2019 编译

    1)点击cmake 对话框中的Open Project

     2)点击生成->批生成

     3) 勾选 ALL BUILD  以及INSTALL 两组,点击右侧生成并持续等待生成完成

     4)  生成完成后 opencv-build 文件夹下会产生install的文件夹,就是添加了opencv_contrib 扩展模块后的 opencv 库

      三.  配置opencv 环境变量,并将opencv 添加到vs2019中使用(将opencv-build移到了D盘

    1)将opencv-build 添加到系统变量中:D:\ProgramData\opencv-build\install\x64\vc16\bin

    2)打开vs2019 新建-项目-空项目,切换成release x64 (也可以选择所有配置,即为所有项目都添加opencv 链接),点击项目-属性 

    3)点击VC++目录,编辑包含目录和库目录

    包含目录:

    D:\ProgramData\opencv-build\install\include\

    D:\ProgramData\opencv-build\install\include\opencv2

     库目录:D:\ProgramData\opencv-build\install\x64\vc16\lib 

     4)在链接器-输入,编辑附加依赖项

    路径:D:\ProgramData\opencv-build\install\x64\vc16\lib

    如果是Release x64 就填入opencv_xxx.lib 

    1. opencv_aruco455.lib
    2. opencv_barcode455.lib
    3. opencv_bgsegm455.lib
    4. opencv_bioinspired455.lib
    5. opencv_calib3d455.lib
    6. opencv_ccalib455.lib
    7. opencv_core455.lib
    8. opencv_datasets455.lib
    9. opencv_dnn455.lib
    10. opencv_dnn_objdetect455.lib
    11. opencv_dnn_superres455.lib
    12. opencv_dpm455.lib
    13. opencv_face455.lib
    14. opencv_features2d455.lib
    15. opencv_flann455.lib
    16. opencv_fuzzy455.lib
    17. opencv_gapi455.lib
    18. opencv_hfs455.lib
    19. opencv_highgui455.lib
    20. opencv_imgcodecs455.lib
    21. opencv_imgproc455.lib
    22. opencv_img_hash455.lib
    23. opencv_intensity_transform455.lib
    24. opencv_line_descriptor455.lib
    25. opencv_mcc455.lib
    26. opencv_ml455.lib
    27. opencv_objdetect455.lib
    28. opencv_optflow455.lib
    29. opencv_phase_unwrapping455.lib
    30. opencv_photo455.lib
    31. opencv_plot455.lib
    32. opencv_quality455.lib
    33. opencv_rapid455.lib
    34. opencv_reg455.lib
    35. opencv_rgbd455.lib
    36. opencv_saliency455.lib
    37. opencv_shape455.lib
    38. opencv_stereo455.lib
    39. opencv_stitching455.lib
    40. opencv_structured_light455.lib
    41. opencv_superres455.lib
    42. opencv_surface_matching455.lib
    43. opencv_text455.lib
    44. opencv_tracking455.lib
    45. opencv_video455.lib
    46. opencv_videoio455.lib
    47. opencv_videostab455.lib
    48. opencv_wechat_qrcode455.lib
    49. opencv_xfeatures2d455.lib
    50. opencv_ximgproc455.lib
    51. opencv_xobjdetect455.lib
    52. opencv_xphoto455.lib

     如果是Debug x64 就填入opencv_xxxd.lib

    1. opencv_aruco455d.lib
    2. opencv_barcode455d.lib
    3. opencv_bgsegm455d.lib
    4. opencv_bioinspired455d.lib
    5. opencv_calib3d455d.lib
    6. opencv_ccalib455d.lib
    7. opencv_core455d.lib
    8. opencv_datasets455d.lib
    9. opencv_dnn455d.lib
    10. opencv_dnn_objdetect455d.lib
    11. opencv_dnn_superres455d.lib
    12. opencv_dpm455d.lib
    13. opencv_face455d.lib
    14. opencv_features2d455d.lib
    15. opencv_flann455d.lib
    16. opencv_fuzzy455d.lib
    17. opencv_gapi455d.lib
    18. opencv_hfs455d.lib
    19. opencv_highgui455d.lib
    20. opencv_imgcodecs455d.lib
    21. opencv_imgproc455d.lib
    22. opencv_img_hash455d.lib
    23. opencv_intensity_transform455d.lib
    24. opencv_line_descriptor455d.lib
    25. opencv_mcc455d.lib
    26. opencv_ml455d.lib
    27. opencv_objdetect455d.lib
    28. opencv_optflow455d.lib
    29. opencv_phase_unwrapping455d.lib
    30. opencv_photo455d.lib
    31. opencv_plot455d.lib
    32. opencv_quality455d.lib
    33. opencv_rapid455d.lib
    34. opencv_reg455d.lib
    35. opencv_rgbd455d.lib
    36. opencv_saliency455d.lib
    37. opencv_shape455d.lib
    38. opencv_stereo455d.lib
    39. opencv_stitching455d.lib
    40. opencv_structured_light455d.lib
    41. opencv_superres455d.lib
    42. opencv_surface_matching455d.lib
    43. opencv_text455d.lib
    44. opencv_tracking455d.lib
    45. opencv_video455d.lib
    46. opencv_videoio455d.lib
    47. opencv_videostab455d.lib
    48. opencv_wechat_qrcode455d.lib
    49. opencv_xfeatures2d455d.lib
    50. opencv_ximgproc455d.lib
    51. opencv_xobjdetect455d.lib
    52. opencv_xphoto455d.lib

     5)在项目中,添加opencv 头文件

    1. #include <opencv2/core/utility.hpp>
    2. #include <opencv2/aruco.hpp>
    3. #include <opencv2/imgproc.hpp>
    4. #include <opencv2/highgui.hpp>
    5. #include <opencv2/calib3d.hpp>

    如果没有红色波浪线,ctrl +鼠标点击,可以跳转,说明添加成功。

    6)检测是否加入 opencv_contrib-4.5.5扩展模块(该模块还有aruco 算法),下面code 如果可以正常运行,则添加正确

    1. #include <opencv2/highgui.hpp>
    2. #include <opencv2/aruco.hpp>
    3. using namespace cv;
    4. int main(int argc, char *argv[]) {
    5. Mat markerImage;
    6. Ptr<cv::aruco::Dictionary> dictionary = aruco::getPredefinedDictionary(cv::aruco::DICT_6X6_250);
    7. aruco::drawMarker(dictionary, 33, 200, markerImage, 1);
    8. imwrite("marker33.png", markerImage);
    9. }

  • 相关阅读:
    LLM大模型4位量化实战【GPTQ】
    轻松掌握组件启动之Redis集群扩展秘籍:轻松扩容与缩容,释放高性能潜能
    安装TensorRT
    二十一、动态内存管理
    PaddlePaddle飞浆搭建和机器学习文字识别
    【深入理解TcaplusDB技术】如何实现Tmonitor单机安装
    C++深度优先搜索(DFS)算法的应用:树中可以形成回文的路径数
    MongoDB基础之数据库,集合,文档
    [附源码]java毕业设计医院疫情疾控管理系统
    c++继承
  • 原文地址:https://blog.csdn.net/Chhjnavy/article/details/125553589