2018-02-09 18:30:04 +08:00
|
|
|
ocv_install_example_src(cpp *.cpp *.hpp CMakeLists.txt)
|
|
|
|
|
|
|
|
set(OPENCV_CPP_SAMPLES_REQUIRED_DEPS
|
|
|
|
opencv_core
|
|
|
|
opencv_imgproc
|
|
|
|
opencv_flann
|
|
|
|
opencv_imgcodecs
|
|
|
|
opencv_videoio
|
|
|
|
opencv_highgui
|
|
|
|
opencv_ml
|
|
|
|
opencv_video
|
|
|
|
opencv_objdetect
|
|
|
|
opencv_photo
|
|
|
|
opencv_features2d
|
|
|
|
opencv_calib3d
|
|
|
|
opencv_stitching
|
2020-11-01 20:29:56 +08:00
|
|
|
opencv_dnn
|
2018-02-09 18:30:04 +08:00
|
|
|
${OPENCV_MODULES_PUBLIC}
|
|
|
|
${OpenCV_LIB_COMPONENTS})
|
2012-02-03 19:26:49 +08:00
|
|
|
ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
2010-05-12 01:44:00 +08:00
|
|
|
|
2018-02-09 18:30:04 +08:00
|
|
|
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
|
|
|
return()
|
|
|
|
endif()
|
2012-02-03 19:26:49 +08:00
|
|
|
|
2020-12-16 08:53:52 +08:00
|
|
|
set(DEPS_example_snippet_imgproc_segmentation opencv_core opencv_imgproc)
|
|
|
|
set(DEPS_example_cpp_intelligent_scissors opencv_core opencv_imgproc opencv_imgcodecs opencv_highgui)
|
|
|
|
|
2018-02-09 18:30:04 +08:00
|
|
|
project(cpp_samples)
|
|
|
|
ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
|
|
|
file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
|
|
|
if(NOT HAVE_opencv_cudaarithm OR NOT HAVE_opencv_cudafilters)
|
|
|
|
ocv_list_filterout(cpp_samples "/gpu/")
|
|
|
|
endif()
|
|
|
|
ocv_list_filterout(cpp_samples "real_time_pose_estimation/")
|
2021-01-21 19:03:17 +08:00
|
|
|
ocv_list_filterout(cpp_samples "parallel_backend/")
|
2018-02-09 18:30:04 +08:00
|
|
|
foreach(sample_filename ${cpp_samples})
|
|
|
|
set(package "cpp")
|
2020-12-16 08:53:52 +08:00
|
|
|
if(sample_filename MATCHES "tutorial_code/snippet")
|
|
|
|
set(package "snippet")
|
|
|
|
elseif(sample_filename MATCHES "tutorial_code")
|
2018-02-09 18:30:04 +08:00
|
|
|
set(package "tutorial")
|
2013-06-04 17:32:35 +08:00
|
|
|
endif()
|
2018-02-09 18:30:04 +08:00
|
|
|
ocv_define_sample(tgt ${sample_filename} ${package})
|
2020-12-16 08:53:52 +08:00
|
|
|
set(deps ${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
|
|
|
if(DEFINED DEPS_${tgt})
|
|
|
|
set(deps ${DEPS_${tgt}})
|
|
|
|
endif()
|
|
|
|
ocv_target_link_libraries(${tgt} PRIVATE ${OPENCV_LINKER_LIBS} ${deps})
|
2018-02-12 23:39:32 +08:00
|
|
|
if(sample_filename MATCHES "/gpu/" AND HAVE_opencv_cudaarithm AND HAVE_opencv_cuda_filters)
|
2019-12-13 22:52:40 +08:00
|
|
|
ocv_target_link_libraries(${tgt} PRIVATE opencv_cudaarithm opencv_cudafilters)
|
2013-06-04 17:32:35 +08:00
|
|
|
endif()
|
2018-02-12 23:39:32 +08:00
|
|
|
if(sample_filename MATCHES "/viz/")
|
2019-12-13 22:52:40 +08:00
|
|
|
ocv_target_link_libraries(${tgt} PRIVATE ${VTK_LIBRARIES})
|
2018-02-09 18:30:04 +08:00
|
|
|
target_compile_definitions(${tgt} PRIVATE -DUSE_VTK)
|
2012-02-03 19:26:49 +08:00
|
|
|
endif()
|
2018-02-09 18:30:04 +08:00
|
|
|
if(HAVE_OPENGL AND sample_filename MATCHES "detect_mser")
|
|
|
|
target_compile_definitions(${tgt} PRIVATE HAVE_OPENGL)
|
2012-02-03 19:26:49 +08:00
|
|
|
endif()
|
2019-07-18 15:25:59 +08:00
|
|
|
if(sample_filename MATCHES "simd_")
|
2019-12-26 19:45:03 +08:00
|
|
|
# disabled intentionally - demonstration purposes only
|
2019-07-18 15:25:59 +08:00
|
|
|
#target_include_directories(${tgt} PRIVATE "${CMAKE_CURRENT_LIST_DIR}")
|
|
|
|
#target_compile_definitions(${tgt} PRIVATE OPENCV_SIMD_CONFIG_HEADER=opencv_simd_config_custom.hpp)
|
|
|
|
#target_compile_definitions(${tgt} PRIVATE OPENCV_SIMD_CONFIG_INCLUDE_DIR=1)
|
|
|
|
#target_compile_options(${tgt} PRIVATE -mavx2)
|
|
|
|
endif()
|
2018-02-09 18:30:04 +08:00
|
|
|
endforeach()
|
2012-06-29 01:23:50 +08:00
|
|
|
|
2018-02-09 18:30:04 +08:00
|
|
|
include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt" OPTIONAL)
|
2021-01-21 19:03:17 +08:00
|
|
|
|
|
|
|
# Standalone samples only
|
|
|
|
if(OpenCV_FOUND AND NOT CMAKE_VERSION VERSION_LESS "3.1")
|
|
|
|
add_subdirectory("example_cmake")
|
|
|
|
endif()
|
|
|
|
if(OpenCV_FOUND AND NOT CMAKE_VERSION VERSION_LESS "3.9")
|
|
|
|
add_subdirectory("tutorial_code/core/parallel_backend")
|
|
|
|
endif()
|