首页 > 其他分享 >opencv官网例程(4.7.0版本)运行示例

opencv官网例程(4.7.0版本)运行示例

时间:2023-01-18 14:58:53浏览次数:149  
标签:4.7 target 示例 例程 executable libraries OpenCV add cpp

使用官网 https://opencv.org/releases/ 下载4.7版本
下载好后添加环境变量到安装路径下

以及在系统变量中添加OpenCV_DIR(也可以用set的方式从Cmakelist里添加)

打开我们下载后的路径,将example_cmake里的CMakeLists.txt和Makefile复制出来到samples/cpp的路径下

修改复制后的Cmakelist文件

官方示例
# Declare the executable target built from your sources
add_executable(opencv_example example.cpp)

# Link your application with OpenCV libraries
target_link_libraries(opencv_example PRIVATE ${OpenCV_LIBS})
替换成
4.7版本,cpp名称已全部修改
add_executable(facedetect facedetect.cpp)
target_link_libraries(facedetect ${OpenCV_LIBS})

add_executable(facial_features facial_features.cpp)
target_link_libraries(facial_features ${OpenCV_LIBS})


add_executable(falsecolor falsecolor.cpp)
target_link_libraries(falsecolor ${OpenCV_LIBS})


add_executable(fback fback.cpp)
target_link_libraries(fback ${OpenCV_LIBS})

add_executable(ffilldemo ffilldemo.cpp)
target_link_libraries(ffilldemo ${OpenCV_LIBS})

add_executable(filestorage filestorage.cpp)
target_link_libraries(filestorage ${OpenCV_LIBS})

add_executable(fitellipse fitellipse.cpp)
target_link_libraries(fitellipse ${OpenCV_LIBS})

add_executable(flann_search_dataset flann_search_dataset.cpp)
target_link_libraries(flann_search_dataset ${OpenCV_LIBS})

add_executable(grabcut grabcut.cpp)
target_link_libraries(grabcut ${OpenCV_LIBS})

add_executable(image_alignment image_alignment.cpp)
target_link_libraries(image_alignment ${OpenCV_LIBS})


add_executable(imagelist_creator imagelist_creator.cpp)
target_link_libraries(imagelist_creator ${OpenCV_LIBS})

add_executable(imagelist_reader imagelist_reader.cpp)
target_link_libraries(imagelist_reader ${OpenCV_LIBS})

add_executable(imgcodecs_jpeg imgcodecs_jpeg.cpp)
target_link_libraries(imgcodecs_jpeg ${OpenCV_LIBS})

add_executable(inpaint inpaint.cpp)
target_link_libraries(inpaint ${OpenCV_LIBS})

add_executable(intelligent_scissors intelligent_scissors.cpp)
target_link_libraries(intelligent_scissors ${OpenCV_LIBS})

add_executable(intersectExample intersectExample.cpp)
target_link_libraries(intersectExample ${OpenCV_LIBS})

add_executable(kalman kalman.cpp)
target_link_libraries(kalman ${OpenCV_LIBS})

add_executable(kmeans kmeans.cpp)
target_link_libraries(kmeans ${OpenCV_LIBS})

add_executable(laplace laplace.cpp)
target_link_libraries(laplace ${OpenCV_LIBS})

add_executable(letter_recog letter_recog.cpp)
target_link_libraries(letter_recog ${OpenCV_LIBS})

add_executable(lkdemo lkdemo.cpp)
target_link_libraries(lkdemo ${OpenCV_LIBS})

add_executable(logistic_regression logistic_regression.cpp)
target_link_libraries(logistic_regression ${OpenCV_LIBS})

add_executable(lsd_lines lsd_lines.cpp)
target_link_libraries(lsd_lines ${OpenCV_LIBS})

add_executable(mask_tmpl mask_tmpl.cpp)
target_link_libraries(mask_tmpl ${OpenCV_LIBS})

add_executable(matchmethod_orb_akaze_brisk matchmethod_orb_akaze_brisk.cpp)
target_link_libraries(matchmethod_orb_akaze_brisk ${OpenCV_LIBS})

add_executable(minarea minarea.cpp)
target_link_libraries(minarea ${OpenCV_LIBS})

add_executable(morphology2 morphology2.cpp)
target_link_libraries(morphology2 ${OpenCV_LIBS})

add_executable(neural_network neural_network.cpp)
target_link_libraries(neural_network ${OpenCV_LIBS})

add_executable(npr_demo npr_demo.cpp)
target_link_libraries(npr_demo ${OpenCV_LIBS})

add_executable(opencv_version opencv_version.cpp)
target_link_libraries(opencv_version ${OpenCV_LIBS})

add_executable(pca pca.cpp)
target_link_libraries(pca ${OpenCV_LIBS})

add_executable(peopledetect peopledetect.cpp)
target_link_libraries(peopledetect ${OpenCV_LIBS})

add_executable(phase_corr phase_corr.cpp)
target_link_libraries(phase_corr ${OpenCV_LIBS})

add_executable(points_classifier points_classifier.cpp)
target_link_libraries(points_classifier ${OpenCV_LIBS})

add_executable(polar_transforms polar_transforms.cpp)
target_link_libraries(polar_transforms ${OpenCV_LIBS})

add_executable(qrcode qrcode.cpp)
target_link_libraries(qrcode ${OpenCV_LIBS})

add_executable(segment_objects segment_objects.cpp)
target_link_libraries(segment_objects ${OpenCV_LIBS})

add_executable(select3dobj select3dobj.cpp)
target_link_libraries(select3dobj ${OpenCV_LIBS})

add_executable(simd_basic simd_basic.cpp)
target_link_libraries(simd_basic ${OpenCV_LIBS})

add_executable(smiledetect smiledetect.cpp)
target_link_libraries(smiledetect ${OpenCV_LIBS})

add_executable(squares squares.cpp)
target_link_libraries(squares ${OpenCV_LIBS})

add_executable(stereo_calib stereo_calib.cpp)
target_link_libraries(stereo_calib ${OpenCV_LIBS})

add_executable(stereo_match stereo_match.cpp)
target_link_libraries(stereo_match ${OpenCV_LIBS})

add_executable(stitching stitching.cpp)
target_link_libraries(stitching ${OpenCV_LIBS})

add_executable(stitching_detailed stitching_detailed.cpp)
target_link_libraries(stitching_detailed ${OpenCV_LIBS})

add_executable(train_HOG train_HOG.cpp)
target_link_libraries(train_HOG ${OpenCV_LIBS})

add_executable(train_svmsgd train_svmsgd.cpp)
target_link_libraries(train_svmsgd ${OpenCV_LIBS})

add_executable(travelsalesman travelsalesman.cpp)
target_link_libraries(travelsalesman ${OpenCV_LIBS})

add_executable(tree_engine tree_engine.cpp)
target_link_libraries(tree_engine ${OpenCV_LIBS})

add_executable(videocapture_basic videocapture_basic.cpp)
target_link_libraries(videocapture_basic ${OpenCV_LIBS})

add_executable(videocapture_audio videocapture_audio.cpp)
target_link_libraries(videocapture_audio ${OpenCV_LIBS})

add_executable(videocapture_audio_combination videocapture_audio_combination.cpp)
target_link_libraries(videocapture_audio_combination ${OpenCV_LIBS})

add_executable(videocapture_camera videocapture_camera.cpp)
target_link_libraries(videocapture_camera ${OpenCV_LIBS})

add_executable(videocapture_gphoto2_autofocus videocapture_gphoto2_autofocus.cpp)
target_link_libraries(videocapture_gphoto2_autofocus ${OpenCV_LIBS})

add_executable(videocapture_gstreamer_pipeline videocapture_gstreamer_pipeline.cpp)
target_link_libraries(videocapture_gstreamer_pipeline ${OpenCV_LIBS})

add_executable(videocapture_image_sequence videocapture_image_sequence.cpp)
target_link_libraries(videocapture_image_sequence ${OpenCV_LIBS})

add_executable(videocapture_microphone videocapture_microphone.cpp)
target_link_libraries(videocapture_microphone ${OpenCV_LIBS})

add_executable(videocapture_obsensor videocapture_obsensor.cpp)
target_link_libraries(videocapture_obsensor ${OpenCV_LIBS})

add_executable(videocapture_openni videocapture_openni.cpp)
target_link_libraries(videocapture_openni ${OpenCV_LIBS})

add_executable(videocapture_realsense videocapture_realsense.cpp)
target_link_libraries(videocapture_realsense ${OpenCV_LIBS})

add_executable(videocapture_starter videocapture_starter.cpp)
target_link_libraries(videocapture_starter ${OpenCV_LIBS})

add_executable(videowriter_basic videowriter_basic.cpp)
target_link_libraries(videowriter_basic ${OpenCV_LIBS})

add_executable(warpPerspective_demo warpPerspective_demo.cpp)
target_link_libraries(warpPerspective_demo ${OpenCV_LIBS})

add_executable(watershed watershed.cpp)
target_link_libraries(watershed ${OpenCV_LIBS})

add_executable(3calibration 3calibration.cpp)
target_link_libraries(3calibration ${OpenCV_LIBS})

add_executable(application_trace application_trace.cpp)
target_link_libraries(application_trace ${OpenCV_LIBS})


add_executable(asift asift.cpp)
target_link_libraries(asift ${OpenCV_LIBS})

add_executable(audio_spectrogram audio_spectrogram.cpp)
target_link_libraries(audio_spectrogram ${OpenCV_LIBS})

add_executable(bgfg_segm bgfg_segm.cpp)
target_link_libraries(bgfg_segm ${OpenCV_LIBS})

add_executable(calibration calibration.cpp)
target_link_libraries(calibration ${OpenCV_LIBS})

add_executable(camshiftdemo camshiftdemo.cpp)
target_link_libraries(camshiftdemo ${OpenCV_LIBS})

add_executable(cloning_demo cloning_demo.cpp)
target_link_libraries(cloning_demo ${OpenCV_LIBS})

add_executable(cloning_gui cloning_gui.cpp)
target_link_libraries(cloning_gui ${OpenCV_LIBS})

add_executable(connected_components connected_components.cpp)
target_link_libraries(connected_components ${OpenCV_LIBS})

add_executable(contours2 contours2.cpp)
target_link_libraries(contours2 ${OpenCV_LIBS})

add_executable(convexhull convexhull.cpp)
target_link_libraries(convexhull ${OpenCV_LIBS})

add_executable(cout_mat cout_mat.cpp)
target_link_libraries(cout_mat ${OpenCV_LIBS})

add_executable(create_mask create_mask.cpp)
target_link_libraries(create_mask ${OpenCV_LIBS})


add_executable(dbt_face_detection dbt_face_detection.cpp)
target_link_libraries(dbt_face_detection ${OpenCV_LIBS})

add_executable(delaunay2 delaunay2.cpp)
target_link_libraries(delaunay2 ${OpenCV_LIBS})

add_executable(demhist demhist.cpp)
target_link_libraries(demhist ${OpenCV_LIBS})

add_executable(detect_blob detect_blob.cpp)
target_link_libraries(detect_blob ${OpenCV_LIBS})


add_executable(detect_mser detect_mser.cpp)
target_link_libraries(detect_mser ${OpenCV_LIBS})

add_executable(dft dft.cpp)
target_link_libraries(dft ${OpenCV_LIBS})

add_executable(digits_lenet digits_lenet.cpp)
target_link_libraries(digits_lenet ${OpenCV_LIBS})

add_executable(digits_svm digits_svm.cpp)
target_link_libraries(digits_svm ${OpenCV_LIBS})

add_executable(dis_opticalflow dis_opticalflow.cpp)
target_link_libraries(dis_opticalflow ${OpenCV_LIBS})

add_executable(drawing drawing.cpp)
target_link_libraries(drawing ${OpenCV_LIBS})

add_executable(distrans distrans.cpp)
target_link_libraries(distrans ${OpenCV_LIBS})

add_executable(edge edge.cpp)
target_link_libraries(edge ${OpenCV_LIBS})


add_executable(ela ela.cpp)
target_link_libraries(ela ${OpenCV_LIBS})

add_executable(em em.cpp)
target_link_libraries(em ${OpenCV_LIBS})

add_executable(essential_mat_reconstr essential_mat_reconstr.cpp)
target_link_libraries(essential_mat_reconstr ${OpenCV_LIBS})

到此,就可以直接使用vs2022打开cmakelist生成全部示例的exe了

但是由于cpp都是使用的相对路径,所以需要把samples\data下的图片,全部复制到使用vs生成exe的路径下samples\cpp\out\build\x64-Debug(默认设置如下)
到此配置全部结束,可以正常运行所有官网示例
题外话:当然新建一个c++空项目加载cpp过来打开也是可以的,但是切换时候很不方便,就这样

标签:4.7,target,示例,例程,executable,libraries,OpenCV,add,cpp
From: https://www.cnblogs.com/dengzhekaihua/p/17059777.html

相关文章

  • Constructor注入(具有相关对象)示例
    在此示例中,我们使用 map 作为具有Answer和User的答案。在这里,我们将键和值对都用作对象。答案具有自己的信息,例如answerId,答案和postedDate,用户具有自己的信息,例如userId......
  • Constructor注入和Map示例
    Constructor注入和Map示例在此示例中,我们使用 map 作为具有已发布用户名答案的答案。在这里,我们将键和值对都用作字符串。像前面的示例一样,它是论坛的示例,其中 一个问......
  • Constructor注入以及示例
    我们可以在Spring框架中通过构造函数注入集合值。 constructor-arg 元素内可以使用三个元素。可以是:ListSetMap每个集合可以具有基于字符串和基于非字符串的值。在......
  • 依赖项构造方法注入示例
    我们可以通过构造函数注入依赖项。 <bean>的 <constructor-arg>子元素用于构造函数注入。在这里,我们要注入原始和基于字符串的值从属对象(包含对象)集合值等注入原始值......
  • Python tkinter 示例
    运行结果如下:    codefromtkinterimport*fromtkinterimportmessageboxasmbimportjsonclassQuiz:def__init__(self):self.qno=0......
  • vector与list使用用法代码示例
    今天在分析amr解码时,发现用到了vector和list。考虑到这两种容器类使用的场景很多,想把他们的使用方法分享给读者。所以我单独抽离一部分单独编译,具体代码如下:#include<std......
  • Spring 示例
    在这里,我们将学习创建第一个spring应用程序的简单步骤。要运行此应用程序,我们不使用任何IDE。我们只是在使用命令提示符。让我们看看创建spring应用程序的简单步骤创建J......
  • MyBatis详细使用示例
    MyBatis的查询查询一个实体类对象<!--UsergetUserById(@Param("id")intid);--><selectid="getUserById"resultType="User">select*fromt_userwhe......
  • 【Java】Java连接Mysql数据库的demo示例
    【Java】Java连接Mysql数据库的demo示例1.安装mysql数据库2.下载java-mysql-connector.jar包3.完成java配置4.写java代码运行测试1.安装mysql数据库这里不多重复,我主要讲......
  • (转)Golang - new和make的使用和区别(示例详解)
    原文:https://www.cnblogs.com/beatleC/p/16081832.html前言:Go语言中new和make是内置函数,主要用来创建分配类型内存(相同点:堆上),其功能相似,却有本质区别。引入:变量的声明v......