mirror of
https://github.com/opencv/opencv.git
synced 2025-06-10 19:24:07 +08:00
cmake: refactored scripts with samples building:
- allow installing samples sources on all platforms even if BUILD_EXAMPLES is disabled, fixed minor issues in sources installation process - use 'example_<group>_<name>' scheme for target and binary file naming - use single function for sample executable creation
This commit is contained in:
parent
633b0e56a5
commit
2200e13c71
@ -420,7 +420,7 @@ else()
|
|||||||
ocv_update(OPENCV_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}lib${LIB_SUFFIX}")
|
ocv_update(OPENCV_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}lib${LIB_SUFFIX}")
|
||||||
endif()
|
endif()
|
||||||
ocv_update(OPENCV_3P_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}")
|
ocv_update(OPENCV_3P_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}")
|
||||||
ocv_update(OPENCV_SAMPLES_SRC_INSTALL_PATH samples/native)
|
ocv_update(OPENCV_SAMPLES_SRC_INSTALL_PATH samples)
|
||||||
ocv_update(OPENCV_JAR_INSTALL_PATH java)
|
ocv_update(OPENCV_JAR_INSTALL_PATH java)
|
||||||
ocv_update(OPENCV_OTHER_INSTALL_PATH etc)
|
ocv_update(OPENCV_OTHER_INSTALL_PATH etc)
|
||||||
ocv_update(OPENCV_CONFIG_INSTALL_PATH ".")
|
ocv_update(OPENCV_CONFIG_INSTALL_PATH ".")
|
||||||
@ -804,7 +804,7 @@ if(BUILD_opencv_apps)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# examples
|
# examples
|
||||||
if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES)
|
if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES OR INSTALL_C_EXAMPLES)
|
||||||
add_subdirectory(samples)
|
add_subdirectory(samples)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -1221,9 +1221,13 @@ function(ocv_add_samples)
|
|||||||
ocv_debug_message("ocv_add_samples(" ${ARGN} ")")
|
ocv_debug_message("ocv_add_samples(" ${ARGN} ")")
|
||||||
|
|
||||||
set(samples_path "${CMAKE_CURRENT_SOURCE_DIR}/samples")
|
set(samples_path "${CMAKE_CURRENT_SOURCE_DIR}/samples")
|
||||||
|
if(NOT EXISTS "${samples_path}")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
string(REGEX REPLACE "^opencv_" "" module_id ${the_module})
|
string(REGEX REPLACE "^opencv_" "" module_id ${the_module})
|
||||||
|
|
||||||
if(BUILD_EXAMPLES AND EXISTS "${samples_path}")
|
if(BUILD_EXAMPLES)
|
||||||
set(samples_deps ${the_module} ${OPENCV_MODULE_${the_module}_DEPS} opencv_imgcodecs opencv_videoio opencv_highgui ${ARGN})
|
set(samples_deps ${the_module} ${OPENCV_MODULE_${the_module}_DEPS} opencv_imgcodecs opencv_videoio opencv_highgui ${ARGN})
|
||||||
ocv_check_dependencies(${samples_deps})
|
ocv_check_dependencies(${samples_deps})
|
||||||
|
|
||||||
@ -1237,15 +1241,14 @@ function(ocv_add_samples)
|
|||||||
ocv_add_executable(${the_target} "${source}")
|
ocv_add_executable(${the_target} "${source}")
|
||||||
ocv_target_include_modules(${the_target} ${samples_deps})
|
ocv_target_include_modules(${the_target} ${samples_deps})
|
||||||
ocv_target_link_libraries(${the_target} LINK_PRIVATE ${samples_deps})
|
ocv_target_link_libraries(${the_target} LINK_PRIVATE ${samples_deps})
|
||||||
set_target_properties(${the_target} PROPERTIES PROJECT_LABEL "(sample) ${name}")
|
|
||||||
|
|
||||||
set_target_properties(${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};Sample")
|
|
||||||
set_source_files_properties("${source}"
|
|
||||||
PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};Sample")
|
|
||||||
|
|
||||||
|
set_target_properties(${the_target} PROPERTIES
|
||||||
|
PROJECT_LABEL "(sample) ${name}"
|
||||||
|
LABELS "${OPENCV_MODULE_${the_module}_LABEL};Sample")
|
||||||
|
set_source_files_properties("${source}" PROPERTIES
|
||||||
|
LABELS "${OPENCV_MODULE_${the_module}_LABEL};Sample")
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
if(ENABLE_SOLUTION_FOLDERS)
|
||||||
set_target_properties(${the_target} PROPERTIES
|
set_target_properties(${the_target} PROPERTIES
|
||||||
OUTPUT_NAME "${module_id}-example-${name}"
|
|
||||||
FOLDER "samples/${module_id}")
|
FOLDER "samples/${module_id}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -1256,7 +1259,7 @@ function(ocv_add_samples)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(INSTALL_C_EXAMPLES AND NOT WIN32 AND EXISTS "${samples_path}")
|
if(INSTALL_C_EXAMPLES)
|
||||||
file(GLOB DEPLOY_FILES_AND_DIRS "${samples_path}/*")
|
file(GLOB DEPLOY_FILES_AND_DIRS "${samples_path}/*")
|
||||||
foreach(ITEM ${DEPLOY_FILES_AND_DIRS})
|
foreach(ITEM ${DEPLOY_FILES_AND_DIRS})
|
||||||
IF( IS_DIRECTORY "${ITEM}" )
|
IF( IS_DIRECTORY "${ITEM}" )
|
||||||
@ -1266,10 +1269,10 @@ function(ocv_add_samples)
|
|||||||
ENDIF()
|
ENDIF()
|
||||||
endforeach()
|
endforeach()
|
||||||
install(FILES ${sample_files}
|
install(FILES ${sample_files}
|
||||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${module_id}
|
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${module_id}"
|
||||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
COMPONENT samples)
|
||||||
install(DIRECTORY ${sample_dirs}
|
install(DIRECTORY ${sample_dirs}
|
||||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${module_id}
|
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${module_id}"
|
||||||
USE_SOURCE_PERMISSIONS COMPONENT samples)
|
COMPONENT samples)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
@ -1,58 +1,95 @@
|
|||||||
# Detect if we want to build samples with library binaries or not
|
# Utility function: adds sample executable target with name "example_<group>_<file_name>"
|
||||||
|
# Usage:
|
||||||
|
# ocv_define_sample(<output target> <relative filename> <group>)
|
||||||
|
function(ocv_define_sample out_target source sub)
|
||||||
|
get_filename_component(name "${source}" NAME_WE)
|
||||||
|
set(the_target "example_${sub}_${name}")
|
||||||
|
add_executable(${the_target} "${source}")
|
||||||
|
set_target_properties(${the_target} PROPERTIES PROJECT_LABEL "(sample) ${name}")
|
||||||
|
if(ENABLE_SOLUTION_FOLDERS)
|
||||||
|
set_target_properties(${the_target} PROPERTIES FOLDER "samples/${sub}")
|
||||||
|
endif()
|
||||||
|
if(WIN32 AND MSVC AND NOT BUILD_SHARED_LIBS)
|
||||||
|
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
||||||
|
endif()
|
||||||
|
if(WIN32)
|
||||||
|
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${sub}" COMPONENT samples)
|
||||||
|
endif()
|
||||||
|
set(${out_target} ${the_target} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
|
if(NOT CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_LIST_DIR)
|
||||||
|
#===================================================================================================
|
||||||
#
|
#
|
||||||
# BUILD CASE 1: Build samples with library sources
|
# Build as part of OpenCV
|
||||||
#
|
#
|
||||||
|
#===================================================================================================
|
||||||
|
|
||||||
|
function(ocv_install_example_src relpath)
|
||||||
# ----------------------------------------------------------------------------
|
if(INSTALL_C_EXAMPLES)
|
||||||
# CMake file for samples. See root CMakeLists.txt
|
file(GLOB files ${ARGN})
|
||||||
#
|
install(FILES ${files}
|
||||||
# ----------------------------------------------------------------------------
|
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${relpath}"
|
||||||
|
COMPONENT samples)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
add_subdirectory(cpp)
|
add_subdirectory(cpp)
|
||||||
add_subdirectory(java/tutorial_code)
|
add_subdirectory(java/tutorial_code)
|
||||||
add_subdirectory(dnn)
|
add_subdirectory(dnn)
|
||||||
add_subdirectory(gpu)
|
add_subdirectory(gpu)
|
||||||
add_subdirectory(tapi)
|
add_subdirectory(tapi)
|
||||||
|
add_subdirectory(opencl)
|
||||||
if(WIN32 AND HAVE_DIRECTX)
|
if(WIN32 AND HAVE_DIRECTX)
|
||||||
add_subdirectory(directx)
|
add_subdirectory(directx)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if((NOT ANDROID) AND HAVE_OPENGL)
|
if((NOT ANDROID) AND HAVE_OPENGL)
|
||||||
add_subdirectory(opengl)
|
add_subdirectory(opengl)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAVE_OPENVX)
|
if(HAVE_OPENVX)
|
||||||
add_subdirectory(openvx)
|
add_subdirectory(openvx)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(UNIX AND NOT ANDROID AND (HAVE_VA OR HAVE_VA_INTEL))
|
if(UNIX AND NOT ANDROID AND (HAVE_VA OR HAVE_VA_INTEL))
|
||||||
add_subdirectory(va_intel)
|
add_subdirectory(va_intel)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ANDROID AND BUILD_ANDROID_EXAMPLES)
|
if(ANDROID AND BUILD_ANDROID_EXAMPLES)
|
||||||
add_subdirectory(android)
|
add_subdirectory(android)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(INSTALL_PYTHON_EXAMPLES)
|
if(INSTALL_PYTHON_EXAMPLES)
|
||||||
add_subdirectory(python)
|
add_subdirectory(python)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
#
|
ocv_install_example_src("." CMakeLists.txt)
|
||||||
# END OF BUILD CASE 1: Build samples with library sources
|
if(INSTALL_C_EXAMPLES)
|
||||||
#
|
install(DIRECTORY data
|
||||||
|
DESTINATION "${OPENCV_SAMPLES_SRC_INSTALL_PATH}/data"
|
||||||
|
COMPONENT samples)
|
||||||
|
endif()
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
#===================================================================================================
|
||||||
#
|
#
|
||||||
# BUILD CASE 2: Build samples with library binaries
|
# Standalone mode
|
||||||
#
|
#
|
||||||
|
#===================================================================================================
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8)
|
||||||
|
|
||||||
project(samples C CXX)
|
project(samples C CXX)
|
||||||
option(BUILD_EXAMPLES "Build samples" ON)
|
option(BUILD_EXAMPLES "Build samples" ON)
|
||||||
|
|
||||||
find_package(OpenCV REQUIRED)
|
# Assuming following installation folder structure (default for UNIX):
|
||||||
|
# <install_root>/share/
|
||||||
|
# └── OpenCV/ <-- OPENCV_CONFIG_INSTALL_PATH
|
||||||
|
# ├── OpenCVConfig.cmake <-- file to be found by find_package
|
||||||
|
# ├── ...
|
||||||
|
# ├── samples/ <-- OPENCV_SAMPLES_SRC_INSTALL_PATH
|
||||||
|
# │ ├── CMakeLists.txt <-- this file
|
||||||
|
# │ ├── cpp/
|
||||||
|
find_package(OpenCV REQUIRED PATHS "..")
|
||||||
|
|
||||||
|
function(ocv_install_example_src)
|
||||||
|
# not used in this branch
|
||||||
|
endfunction()
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
if(NOT ENABLE_BUILD_HARDENING)
|
if(NOT ENABLE_BUILD_HARDENING)
|
||||||
@ -80,16 +117,15 @@ if(MSVC)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_subdirectory(cpp)
|
add_subdirectory(cpp)
|
||||||
add_subdirectory(dnn)
|
|
||||||
# FIXIT: can't use cvconfig.h in samples: add_subdirectory(gpu)
|
|
||||||
|
|
||||||
add_subdirectory(opencl)
|
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
add_subdirectory(directx)
|
add_subdirectory(directx)
|
||||||
endif()
|
endif()
|
||||||
|
add_subdirectory(dnn)
|
||||||
|
# add_subdirectory(gpu)
|
||||||
|
add_subdirectory(opencl)
|
||||||
|
# add_subdirectory(opengl)
|
||||||
|
# add_subdirectory(openvx)
|
||||||
|
add_subdirectory(tapi)
|
||||||
|
# add_subdirectory(va_intel)
|
||||||
|
|
||||||
#
|
|
||||||
# END OF BUILD CASE 2: Build samples with library binaries
|
|
||||||
#
|
|
||||||
endif()
|
endif()
|
||||||
|
@ -1,117 +1,65 @@
|
|||||||
# ----------------------------------------------------------------------------
|
ocv_install_example_src(cpp *.cpp *.hpp CMakeLists.txt)
|
||||||
# CMake file for C samples. See root 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 opencv_videostab opencv_shape ${OPENCV_MODULES_PUBLIC} ${OpenCV_LIB_COMPONENTS})
|
|
||||||
|
|
||||||
|
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
|
||||||
|
opencv_videostab
|
||||||
|
opencv_shape
|
||||||
|
${OPENCV_MODULES_PUBLIC}
|
||||||
|
${OpenCV_LIB_COMPONENTS})
|
||||||
ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
ocv_check_dependencies(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
|
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
|
||||||
project(cpp_samples)
|
project(cpp_samples)
|
||||||
|
|
||||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/include")#for opencv.hpp
|
|
||||||
ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
if(HAVE_opencv_cudaoptflow)
|
|
||||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaoptflow/include")
|
|
||||||
endif()
|
|
||||||
if(HAVE_opencv_cudaimgproc)
|
|
||||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaimgproc/include")
|
|
||||||
endif()
|
|
||||||
if(HAVE_opencv_cudaarithm)
|
|
||||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaarithm/include")
|
|
||||||
endif()
|
|
||||||
if(HAVE_opencv_cudafilters)
|
|
||||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudafilters/include")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-missing-declarations")
|
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function -Wno-missing-declarations")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# ---------------------------------------------
|
|
||||||
# Define executable targets
|
|
||||||
# ---------------------------------------------
|
|
||||||
MACRO(OPENCV_DEFINE_CPP_EXAMPLE name srcs)
|
|
||||||
|
|
||||||
if("${srcs}" MATCHES "tutorial_code")
|
|
||||||
set(sample_kind tutorial)
|
|
||||||
set(sample_KIND TUTORIAL)
|
|
||||||
set(sample_subfolder "tutorials")
|
|
||||||
else()
|
|
||||||
set(sample_kind example)
|
|
||||||
set(sample_KIND EXAMPLE)
|
|
||||||
set(sample_subfolder "cpp")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(the_target "${sample_kind}_${name}")
|
|
||||||
add_executable(${the_target} ${srcs})
|
|
||||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
|
||||||
|
|
||||||
if("${srcs}" MATCHES "gpu/")
|
|
||||||
ocv_target_link_libraries(${the_target} opencv_cudaarithm opencv_cudafilters)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if("${srcs}" MATCHES "viz/" AND VTK_USE_FILE)
|
|
||||||
include(${VTK_USE_FILE})
|
|
||||||
ocv_target_link_libraries(${the_target} ${VTK_LIBRARIES})
|
|
||||||
add_definitions(-DUSE_VTK)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(${the_target} PROPERTIES
|
|
||||||
OUTPUT_NAME "cpp-${sample_kind}-${name}"
|
|
||||||
PROJECT_LABEL "(${sample_KIND}) ${name}")
|
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples/${sample_subfolder}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
if (MSVC AND NOT BUILD_SHARED_LIBS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
|
||||||
endif()
|
|
||||||
install(TARGETS ${the_target}
|
|
||||||
RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${sample_subfolder}" COMPONENT samples)
|
|
||||||
endif()
|
|
||||||
ENDMACRO()
|
|
||||||
|
|
||||||
file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||||
|
|
||||||
if(NOT HAVE_OPENGL)
|
if(NOT HAVE_OPENGL)
|
||||||
ocv_list_filterout(cpp_samples Qt_sample)
|
ocv_list_filterout(cpp_samples Qt_sample)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT HAVE_opencv_cudaarithm OR NOT HAVE_opencv_cudafilters)
|
if(NOT HAVE_opencv_cudaarithm OR NOT HAVE_opencv_cudafilters)
|
||||||
ocv_list_filterout(cpp_samples "/gpu/")
|
ocv_list_filterout(cpp_samples "/gpu/")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT TARGET opencv_viz)
|
if(NOT TARGET opencv_viz)
|
||||||
ocv_list_filterout(cpp_samples "/viz/")
|
ocv_list_filterout(cpp_samples "/viz/")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT HAVE_IPP_A)
|
if(NOT HAVE_IPP_A)
|
||||||
ocv_list_filterout(cpp_samples "/ippasync/")
|
ocv_list_filterout(cpp_samples "/ippasync/")
|
||||||
endif()
|
endif()
|
||||||
|
ocv_list_filterout(cpp_samples "real_time_pose_estimation/")
|
||||||
foreach(sample_filename ${cpp_samples})
|
foreach(sample_filename ${cpp_samples})
|
||||||
if(NOT "${sample_filename}" MATCHES "real_time_pose_estimation/")
|
if(sample_filename MATCHES "viz/" AND VTK_USE_FILE)
|
||||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
include(${VTK_USE_FILE})
|
||||||
OPENCV_DEFINE_CPP_EXAMPLE(${sample} ${sample_filename})
|
endif()
|
||||||
|
set(package "cpp")
|
||||||
|
if(sample_filename MATCHES "tutorial_code")
|
||||||
|
set(package "tutorial")
|
||||||
|
endif()
|
||||||
|
ocv_define_sample(tgt ${sample_filename} ${package})
|
||||||
|
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
||||||
|
if(sample_filename MATCHES "gpu/" AND HAVE_opencv_cudaarithm AND HAVE_opencv_cuda_filters)
|
||||||
|
ocv_target_link_libraries(${tgt} opencv_cudaarithm opencv_cudafilters)
|
||||||
|
endif()
|
||||||
|
if(sample_filename MATCHES "viz/" AND VTK_USE_FILE)
|
||||||
|
ocv_target_link_libraries(${tgt} ${VTK_LIBRARIES})
|
||||||
|
target_compile_definitions(${tgt} PRIVATE -DUSE_VTK)
|
||||||
|
endif()
|
||||||
|
if(HAVE_OPENGL AND sample_filename MATCHES "detect_mser")
|
||||||
|
target_compile_definitions(${tgt} PRIVATE HAVE_OPENGL)
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt")
|
include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt" OPTIONAL)
|
||||||
endif()
|
|
||||||
|
|
||||||
if(INSTALL_C_EXAMPLES AND NOT WIN32)
|
|
||||||
file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
|
|
||||||
install(FILES ${C_SAMPLES}
|
|
||||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/cpp
|
|
||||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
|
||||||
endif()
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
set(sample_dir ${CMAKE_CURRENT_SOURCE_DIR}/tutorial_code/calib3d/real_time_pose_estimation/src/)
|
set(sample_dir ${CMAKE_CURRENT_SOURCE_DIR}/tutorial_code/calib3d/real_time_pose_estimation/src/)
|
||||||
set(target cpp-tutorial-)
|
set(target example_tutorial_)
|
||||||
|
|
||||||
set(sample_pnplib
|
set(sample_pnplib
|
||||||
${sample_dir}CsvReader.cpp
|
${sample_dir}CsvReader.cpp
|
||||||
@ -12,6 +12,8 @@ set(sample_pnplib
|
|||||||
${sample_dir}RobustMatcher.cpp
|
${sample_dir}RobustMatcher.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
add_executable( ${target}pnp_registration ${sample_dir}main_registration.cpp ${sample_pnplib} )
|
add_executable( ${target}pnp_registration ${sample_dir}main_registration.cpp ${sample_pnplib} )
|
||||||
add_executable( ${target}pnp_detection ${sample_dir}main_detection.cpp ${sample_pnplib} )
|
add_executable( ${target}pnp_detection ${sample_dir}main_detection.cpp ${sample_pnplib} )
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#include <opencv2/opencv.hpp>
|
#include <opencv2/core.hpp>
|
||||||
|
#include <opencv2/imgproc.hpp>
|
||||||
|
|
||||||
using namespace cv;
|
using namespace cv;
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -1,45 +1,21 @@
|
|||||||
SET(OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui)
|
ocv_install_example_src(directx *.cpp *.hpp CMakeLists.txt)
|
||||||
|
|
||||||
|
set(OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS
|
||||||
|
opencv_core
|
||||||
|
opencv_imgproc
|
||||||
|
opencv_imgcodecs
|
||||||
|
opencv_videoio
|
||||||
|
opencv_highgui)
|
||||||
ocv_check_dependencies(${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
ocv_check_dependencies(${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||||
set(project "directx")
|
return()
|
||||||
string(TOUPPER "${project}" project_upper)
|
|
||||||
|
|
||||||
project("${project}_samples")
|
|
||||||
|
|
||||||
ocv_include_modules_recurse(${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
|
||||||
|
|
||||||
# ---------------------------------------------
|
|
||||||
# Define executable targets
|
|
||||||
# ---------------------------------------------
|
|
||||||
MACRO(OPENCV_DEFINE_DIRECTX_EXAMPLE name srcs)
|
|
||||||
set(the_target "example_${project}_${name}")
|
|
||||||
add_executable(${the_target} ${srcs})
|
|
||||||
|
|
||||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
|
||||||
|
|
||||||
set_target_properties(${the_target} PROPERTIES
|
|
||||||
OUTPUT_NAME "${project}-example-${name}"
|
|
||||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
project("directx_samples")
|
||||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
ocv_include_modules_recurse(${tgt} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
||||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
|
||||||
endif()
|
|
||||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT samples)
|
|
||||||
endif()
|
|
||||||
ENDMACRO()
|
|
||||||
|
|
||||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||||
|
|
||||||
foreach(sample_filename ${all_samples})
|
foreach(sample_filename ${all_samples})
|
||||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
ocv_define_sample(tgt ${sample_filename} directx)
|
||||||
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
|
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
|
||||||
OPENCV_DEFINE_DIRECTX_EXAMPLE(${sample} ${sample_srcs})
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
|
||||||
|
@ -1,21 +1,23 @@
|
|||||||
SET(OPENCV_DNN_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_dnn
|
ocv_install_example_src(dnn *.cpp *.hpp CMakeLists.txt)
|
||||||
opencv_imgcodecs opencv_videoio opencv_highgui
|
|
||||||
${OpenCV_LIB_COMPONENTS})
|
|
||||||
|
|
||||||
|
set(OPENCV_DNN_SAMPLES_REQUIRED_DEPS
|
||||||
|
opencv_core
|
||||||
|
opencv_imgproc
|
||||||
|
opencv_dnn
|
||||||
|
opencv_imgcodecs
|
||||||
|
opencv_videoio
|
||||||
|
opencv_highgui)
|
||||||
ocv_check_dependencies(${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
|
ocv_check_dependencies(${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
|
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
return()
|
||||||
project(dnn_samples)
|
endif()
|
||||||
|
|
||||||
# Model branch name: dnn_samples_face_detector_20170830
|
# Model branch name: dnn_samples_face_detector_20170830
|
||||||
set(DNN_FACE_DETECTOR_MODEL_COMMIT "b2bfc75f6aea5b1f834ff0f0b865a7c18ff1459f")
|
set(DNN_FACE_DETECTOR_MODEL_COMMIT "b2bfc75f6aea5b1f834ff0f0b865a7c18ff1459f")
|
||||||
set(DNN_FACE_DETECTOR_MODEL_HASH "afbb6037fd180e8d2acb3b58ca737b9e")
|
set(DNN_FACE_DETECTOR_MODEL_HASH "afbb6037fd180e8d2acb3b58ca737b9e")
|
||||||
|
|
||||||
set(DNN_FACE_DETECTOR_MODEL_NAME "res10_300x300_ssd_iter_140000.caffemodel")
|
set(DNN_FACE_DETECTOR_MODEL_NAME "res10_300x300_ssd_iter_140000.caffemodel")
|
||||||
|
|
||||||
set(DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR "${CMAKE_CURRENT_LIST_DIR}/face_detector")
|
set(DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR "${CMAKE_CURRENT_LIST_DIR}/face_detector")
|
||||||
|
|
||||||
if(COMMAND ocv_download)
|
if(COMMAND ocv_download)
|
||||||
ocv_download(FILENAME ${DNN_FACE_DETECTOR_MODEL_NAME}
|
ocv_download(FILENAME ${DNN_FACE_DETECTOR_MODEL_NAME}
|
||||||
HASH ${DNN_FACE_DETECTOR_MODEL_HASH}
|
HASH ${DNN_FACE_DETECTOR_MODEL_HASH}
|
||||||
@ -28,49 +30,10 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
|||||||
RELATIVE_URL
|
RELATIVE_URL
|
||||||
STATUS res)
|
STATUS res)
|
||||||
endif()
|
endif()
|
||||||
|
project(dnn_samples)
|
||||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/include")
|
|
||||||
ocv_include_modules_recurse(${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
|
ocv_include_modules_recurse(${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
# ---------------------------------------------
|
|
||||||
# Define executable targets
|
|
||||||
# ---------------------------------------------
|
|
||||||
MACRO(OPENCV_DEFINE_DNN_EXAMPLE name srcs)
|
|
||||||
set(sample_kind example_dnn)
|
|
||||||
set(sample_subfolder "dnn")
|
|
||||||
|
|
||||||
set(the_target "${sample_kind}_${name}")
|
|
||||||
add_executable(${the_target} ${srcs})
|
|
||||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
|
|
||||||
|
|
||||||
set_target_properties(${the_target} PROPERTIES
|
|
||||||
OUTPUT_NAME "${sample_kind}-${name}"
|
|
||||||
PROJECT_LABEL "(${sample_KIND}) ${name}")
|
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples/${sample_subfolder}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
if (MSVC AND NOT BUILD_SHARED_LIBS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
|
||||||
endif()
|
|
||||||
install(TARGETS ${the_target}
|
|
||||||
RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${sample_subfolder}" COMPONENT samples)
|
|
||||||
endif()
|
|
||||||
ENDMACRO()
|
|
||||||
|
|
||||||
file(GLOB_RECURSE dnn_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
file(GLOB_RECURSE dnn_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||||
|
|
||||||
foreach(sample_filename ${dnn_samples})
|
foreach(sample_filename ${dnn_samples})
|
||||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
ocv_define_sample(tgt ${sample_filename} dnn)
|
||||||
OPENCV_DEFINE_DNN_EXAMPLE(${sample} ${sample_filename})
|
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
|
||||||
|
|
||||||
if(INSTALL_C_EXAMPLES AND NOT WIN32)
|
|
||||||
file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
|
|
||||||
install(FILES ${C_SAMPLES}
|
|
||||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/dnn
|
|
||||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
|
||||||
endif()
|
|
||||||
|
@ -1,97 +1,60 @@
|
|||||||
SET(OPENCV_CUDA_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui
|
ocv_install_example_src(gpu *.cpp *.hpp CMakeLists.txt)
|
||||||
opencv_ml opencv_video opencv_objdetect opencv_features2d
|
|
||||||
opencv_calib3d opencv_superres
|
|
||||||
opencv_cudaarithm opencv_cudafilters opencv_cudawarping opencv_cudaimgproc
|
|
||||||
opencv_cudafeatures2d opencv_cudaoptflow opencv_cudabgsegm
|
|
||||||
opencv_cudastereo opencv_cudalegacy opencv_cudaobjdetect)
|
|
||||||
|
|
||||||
|
set(OPENCV_CUDA_SAMPLES_REQUIRED_DEPS
|
||||||
|
opencv_core
|
||||||
|
opencv_flann
|
||||||
|
opencv_imgproc
|
||||||
|
opencv_imgcodecs
|
||||||
|
opencv_videoio
|
||||||
|
opencv_highgui
|
||||||
|
opencv_ml
|
||||||
|
opencv_video
|
||||||
|
opencv_objdetect
|
||||||
|
opencv_features2d
|
||||||
|
opencv_calib3d
|
||||||
|
opencv_superres
|
||||||
|
opencv_cudaarithm
|
||||||
|
opencv_cudafilters
|
||||||
|
opencv_cudawarping
|
||||||
|
opencv_cudaimgproc
|
||||||
|
opencv_cudafeatures2d
|
||||||
|
opencv_cudaoptflow
|
||||||
|
opencv_cudabgsegm
|
||||||
|
opencv_cudastereo
|
||||||
|
opencv_cudalegacy
|
||||||
|
opencv_cudaobjdetect)
|
||||||
ocv_check_dependencies(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
|
ocv_check_dependencies(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||||
set(project "gpu")
|
return()
|
||||||
string(TOUPPER "${project}" project_upper)
|
endif()
|
||||||
|
|
||||||
project("${project}_samples")
|
|
||||||
|
|
||||||
|
project(gpu_samples)
|
||||||
ocv_include_modules_recurse(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
|
ocv_include_modules_recurse(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
if(HAVE_opencv_xfeatures2d)
|
if(HAVE_opencv_xfeatures2d)
|
||||||
ocv_include_modules_recurse(opencv_xfeatures2d)
|
ocv_include_modules_recurse(opencv_xfeatures2d)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAVE_opencv_cudacodec)
|
if(HAVE_opencv_cudacodec)
|
||||||
ocv_include_modules_recurse(opencv_cudacodec)
|
ocv_include_modules_recurse(opencv_cudacodec)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAVE_CUDA)
|
if(HAVE_CUDA)
|
||||||
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
|
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
||||||
endif()
|
endif()
|
||||||
|
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||||
# ---------------------------------------------
|
if(NOT HAVE_OPENGL)
|
||||||
# Define executable targets
|
ocv_list_filterout(all_samples "opengl")
|
||||||
# ---------------------------------------------
|
|
||||||
MACRO(OPENCV_DEFINE_CUDA_EXAMPLE name srcs)
|
|
||||||
set(the_target "example_${project}_${name}")
|
|
||||||
add_executable(${the_target} ${srcs})
|
|
||||||
|
|
||||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
|
|
||||||
|
|
||||||
if(HAVE_CUDA AND NOT ANDROID)
|
|
||||||
ocv_target_link_libraries(${the_target} ${CUDA_CUDA_LIBRARY})
|
|
||||||
endif()
|
endif()
|
||||||
|
foreach(sample_filename ${all_samples})
|
||||||
|
ocv_define_sample(tgt ${sample_filename} gpu)
|
||||||
|
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
|
||||||
if(HAVE_opencv_xfeatures2d)
|
if(HAVE_opencv_xfeatures2d)
|
||||||
ocv_target_link_libraries(${the_target} opencv_xfeatures2d)
|
ocv_target_link_libraries(${tgt} opencv_xfeatures2d)
|
||||||
endif()
|
endif()
|
||||||
if(HAVE_opencv_cudacodec)
|
if(HAVE_opencv_cudacodec)
|
||||||
ocv_target_link_libraries(${the_target} opencv_cudacodec)
|
ocv_target_link_libraries(${tgt} opencv_cudacodec)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAVE_opencv_ocl)
|
|
||||||
ocv_target_link_libraries(${the_target} opencv_ocl)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set_target_properties(${the_target} PROPERTIES
|
|
||||||
OUTPUT_NAME "${project}-example-${name}"
|
|
||||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
|
||||||
endif()
|
|
||||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT samples)
|
|
||||||
endif()
|
|
||||||
ENDMACRO()
|
|
||||||
|
|
||||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
|
||||||
|
|
||||||
if(NOT HAVE_OPENGL)
|
|
||||||
list(REMOVE_ITEM all_samples "opengl.cpp")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(sample_filename ${all_samples})
|
|
||||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
|
||||||
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
|
|
||||||
OPENCV_DEFINE_CUDA_EXAMPLE(${sample} ${sample_srcs})
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
include("performance/CMakeLists.txt" OPTIONAL)
|
||||||
include("performance/CMakeLists.txt")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(INSTALL_C_EXAMPLES AND NOT WIN32)
|
|
||||||
file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
|
|
||||||
if(NOT HAVE_OPENGL)
|
|
||||||
list(REMOVE_ITEM install_list "opengl.cpp")
|
|
||||||
endif()
|
|
||||||
install(FILES ${install_list}
|
|
||||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu
|
|
||||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
|
||||||
endif()
|
|
||||||
|
@ -34,10 +34,4 @@ if(WIN32)
|
|||||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/gpu" COMPONENT samples)
|
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/gpu" COMPONENT samples)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(INSTALL_C_EXAMPLES AND NOT WIN32)
|
ocv_install_example_src("gpu/performance" performance/*.cpp performance/*.h)
|
||||||
file(GLOB CUDA_FILES performance/*.cpp performance/*.h)
|
|
||||||
install(FILES ${CUDA_FILES}
|
|
||||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu/performance
|
|
||||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
|
|
||||||
COMPONENT samples)
|
|
||||||
endif()
|
|
||||||
|
@ -1,22 +1,23 @@
|
|||||||
# cmake 3.1 needed for find_package(OpenCL)
|
ocv_install_example_src(opencl *.cpp *.hpp CMakeLists.txt)
|
||||||
|
|
||||||
|
# cmake 3.1 needed for find_package(OpenCL)
|
||||||
if(CMAKE_VERSION VERSION_LESS "3.1")
|
if(CMAKE_VERSION VERSION_LESS "3.1")
|
||||||
message(STATUS "OpenCL samples require CMakes 3.1+")
|
message(STATUS "OpenCL samples require CMakes 3.1+")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(
|
set(OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS
|
||||||
OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS
|
|
||||||
opencv_core
|
opencv_core
|
||||||
opencv_imgproc
|
opencv_imgproc
|
||||||
opencv_video
|
opencv_video
|
||||||
opencv_imgcodecs
|
opencv_imgcodecs
|
||||||
opencv_videoio
|
opencv_videoio
|
||||||
opencv_highgui)
|
opencv_highgui)
|
||||||
|
|
||||||
ocv_check_dependencies(${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS})
|
ocv_check_dependencies(${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(OpenCL 1.2 QUIET)
|
find_package(OpenCL 1.2 QUIET)
|
||||||
if(NOT OpenCL_FOUND)
|
if(NOT OpenCL_FOUND)
|
||||||
@ -24,49 +25,14 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
|||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(project "opencl")
|
project(opencl_samples)
|
||||||
string(TOUPPER "${project}" project_upper)
|
|
||||||
|
|
||||||
project("${project}_samples")
|
|
||||||
|
|
||||||
ocv_include_modules_recurse(${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS})
|
ocv_include_modules_recurse(${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS})
|
||||||
|
ocv_include_directories(${OpenCL_INCLUDE_DIR})
|
||||||
include_directories(${OpenCL_INCLUDE_DIR})
|
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||||
|
foreach(sample_filename ${all_samples})
|
||||||
# ---------------------------------------------
|
ocv_define_sample(tgt ${sample_filename} opencl)
|
||||||
# Define executable targets
|
ocv_target_link_libraries(${tgt}
|
||||||
# ---------------------------------------------
|
|
||||||
MACRO(OPENCV_DEFINE_OPENCL_EXAMPLE name srcs)
|
|
||||||
set(the_target "example_${project}_${name}")
|
|
||||||
add_executable(${the_target} ${srcs})
|
|
||||||
|
|
||||||
ocv_target_link_libraries(
|
|
||||||
${the_target}
|
|
||||||
${OPENCV_LINKER_LIBS}
|
${OPENCV_LINKER_LIBS}
|
||||||
${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS}
|
${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS}
|
||||||
${OpenCL_LIBRARY})
|
${OpenCL_LIBRARY})
|
||||||
|
|
||||||
set_target_properties(${the_target} PROPERTIES
|
|
||||||
OUTPUT_NAME "${project}-example-${name}"
|
|
||||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
|
||||||
endif()
|
|
||||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT main)
|
|
||||||
endif()
|
|
||||||
ENDMACRO()
|
|
||||||
|
|
||||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
|
||||||
|
|
||||||
foreach(sample_filename ${all_samples})
|
|
||||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
|
||||||
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
|
|
||||||
OPENCV_DEFINE_OPENCL_EXAMPLE(${sample} ${sample_srcs})
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
|
||||||
|
@ -12,50 +12,23 @@ if(UNIX)
|
|||||||
set(SAMPLE_LINKER_DEPS "${X11_LIBRARIES}")
|
set(SAMPLE_LINKER_DEPS "${X11_LIBRARIES}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
SET(OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS
|
||||||
|
opencv_core
|
||||||
SET(OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui)
|
opencv_imgproc
|
||||||
|
opencv_imgcodecs
|
||||||
|
opencv_videoio
|
||||||
|
opencv_highgui)
|
||||||
ocv_check_dependencies(${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS})
|
ocv_check_dependencies(${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
||||||
set(project "opengl")
|
project(opengl_samples)
|
||||||
string(TOUPPER "${project}" project_upper)
|
|
||||||
|
|
||||||
project("${project}_samples")
|
|
||||||
|
|
||||||
ocv_include_modules_recurse(${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS})
|
ocv_include_modules_recurse(${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
# ---------------------------------------------
|
|
||||||
# Define executable targets
|
|
||||||
# ---------------------------------------------
|
|
||||||
MACRO(OPENCV_DEFINE_OPENGL_EXAMPLE name srcs)
|
|
||||||
set(the_target "example_${project}_${name}")
|
|
||||||
add_executable(${the_target} ${srcs})
|
|
||||||
|
|
||||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS} ${SAMPLE_LINKER_DEPS})
|
|
||||||
|
|
||||||
set_target_properties(${the_target} PROPERTIES
|
|
||||||
OUTPUT_NAME "${project}-example-${name}"
|
|
||||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
|
||||||
endif()
|
|
||||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT samples)
|
|
||||||
endif()
|
|
||||||
ENDMACRO()
|
|
||||||
|
|
||||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||||
|
|
||||||
foreach(sample_filename ${all_samples})
|
foreach(sample_filename ${all_samples})
|
||||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
ocv_define_sample(tgt ${sample_filename} opengl)
|
||||||
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
|
ocv_target_link_libraries(${tgt}
|
||||||
OPENCV_DEFINE_OPENGL_EXAMPLE(${sample} ${sample_srcs})
|
${OPENCV_LINKER_LIBS} ${OPENCV_OPENGL_SAMPLES_REQUIRED_DEPS} ${SAMPLE_LINKER_DEPS})
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
ocv_install_example_src(opengl *.cpp *.hpp CMakeLists.txt)
|
||||||
|
@ -1,37 +1,25 @@
|
|||||||
|
ocv_install_example_src(cpp *.cpp *.hpp CMakeLists.txt)
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.8.9)
|
cmake_minimum_required(VERSION 2.8.9)
|
||||||
|
|
||||||
set(OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui)
|
set(OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS
|
||||||
|
opencv_core
|
||||||
|
opencv_imgproc
|
||||||
|
opencv_imgcodecs
|
||||||
|
opencv_videoio
|
||||||
|
opencv_highgui)
|
||||||
ocv_check_dependencies(${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS})
|
ocv_check_dependencies(${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS})
|
||||||
|
|
||||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||||
set(group "openvx")
|
return()
|
||||||
set(name_wrapped "interop")
|
endif()
|
||||||
set(name_orig "interop_orig")
|
|
||||||
set(name_video "interop_video")
|
|
||||||
|
|
||||||
project("${group}_sample")
|
|
||||||
|
|
||||||
|
project(openvx_samples)
|
||||||
ocv_include_modules_recurse(${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS})
|
ocv_include_modules_recurse(${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS})
|
||||||
|
|
||||||
add_definitions(-DIVX_USE_OPENCV)
|
add_definitions(-DIVX_USE_OPENCV)
|
||||||
add_definitions(-DIVX_HIDE_INFO_WARNINGS)
|
add_definitions(-DIVX_HIDE_INFO_WARNINGS)
|
||||||
|
file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||||
file(GLOB srcs_wrapped wrappers.cpp *.hpp)
|
foreach(sample_filename ${cpp_samples})
|
||||||
file(GLOB srcs_orig no_wrappers.cpp *.hpp)
|
ocv_define_sample(tgt ${sample_filename} openvx)
|
||||||
file(GLOB srcs_video wrappers_video.cpp *.hpp)
|
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS})
|
||||||
|
endforeach()
|
||||||
MACRO(OPENVX_DEFINE_SAMPLE name srcs)
|
|
||||||
set(target "example_${group}_${name}")
|
|
||||||
add_executable(${target} ${srcs})
|
|
||||||
ocv_target_link_libraries(${target} ${OPENCV_LINKER_LIBS} ${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS} ${OPENVX_LIBRARIES})
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
|
||||||
set_target_properties(${target} PROPERTIES FOLDER "samples//${group}")
|
|
||||||
endif()
|
|
||||||
ENDMACRO()
|
|
||||||
|
|
||||||
OPENVX_DEFINE_SAMPLE(${name_wrapped} ${srcs_wrapped})
|
|
||||||
OPENVX_DEFINE_SAMPLE(${name_orig} ${srcs_orig})
|
|
||||||
OPENVX_DEFINE_SAMPLE(${name_video} ${srcs_video})
|
|
||||||
|
|
||||||
endif()
|
|
||||||
|
@ -1,52 +1,26 @@
|
|||||||
SET(OPENCV_TAPI_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_video opencv_imgcodecs opencv_videoio opencv_highgui opencv_objdetect opencv_features2d opencv_calib3d opencv_flann)
|
ocv_install_example_src(tapi *.cpp *.hpp CMakeLists.txt)
|
||||||
|
|
||||||
|
set(OPENCV_TAPI_SAMPLES_REQUIRED_DEPS
|
||||||
|
opencv_core
|
||||||
|
opencv_imgproc
|
||||||
|
opencv_video
|
||||||
|
opencv_imgcodecs
|
||||||
|
opencv_videoio
|
||||||
|
opencv_highgui
|
||||||
|
opencv_objdetect
|
||||||
|
opencv_features2d
|
||||||
|
opencv_calib3d
|
||||||
|
opencv_flann)
|
||||||
ocv_check_dependencies(${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
|
ocv_check_dependencies(${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||||
set(project "tapi")
|
return()
|
||||||
string(TOUPPER "${project}" project_upper)
|
endif()
|
||||||
|
|
||||||
project("${project}_samples")
|
|
||||||
|
|
||||||
|
project(tapi_samples)
|
||||||
ocv_include_modules_recurse(${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
|
ocv_include_modules_recurse(${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
# ---------------------------------------------
|
|
||||||
# Define executable targets
|
|
||||||
# ---------------------------------------------
|
|
||||||
MACRO(OPENCV_DEFINE_TAPI_EXAMPLE name srcs)
|
|
||||||
set(the_target "example_${project}_${name}")
|
|
||||||
add_executable(${the_target} ${srcs})
|
|
||||||
|
|
||||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
|
|
||||||
|
|
||||||
set_target_properties(${the_target} PROPERTIES
|
|
||||||
OUTPUT_NAME "${project}-example-${name}"
|
|
||||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
if(MSVC AND NOT BUILD_SHARED_LIBS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
|
|
||||||
endif()
|
|
||||||
install(TARGETS ${the_target} RUNTIME DESTINATION "${OPENCV_SAMPLES_BIN_INSTALL_PATH}/${project}" COMPONENT samples)
|
|
||||||
endif()
|
|
||||||
ENDMACRO()
|
|
||||||
|
|
||||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||||
|
|
||||||
foreach(sample_filename ${all_samples})
|
foreach(sample_filename ${all_samples})
|
||||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
ocv_define_sample(tgt ${sample_filename} tapi)
|
||||||
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
|
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
|
||||||
OPENCV_DEFINE_TAPI_EXAMPLE(${sample} ${sample_srcs})
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
|
||||||
|
|
||||||
if(INSTALL_C_EXAMPLES AND NOT WIN32)
|
|
||||||
file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
|
|
||||||
install(FILES ${install_list}
|
|
||||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/tapi
|
|
||||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
|
||||||
endif()
|
|
||||||
|
@ -1,38 +1,21 @@
|
|||||||
SET(OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui)
|
ocv_install_example_src(opencl *.cpp *.inc CMakeLists.txt)
|
||||||
|
|
||||||
|
set(OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS
|
||||||
|
opencv_core
|
||||||
|
opencv_imgproc
|
||||||
|
opencv_imgcodecs
|
||||||
|
opencv_videoio
|
||||||
|
opencv_highgui)
|
||||||
ocv_check_dependencies(${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS})
|
ocv_check_dependencies(${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
|
if(NOT BUILD_EXAMPLES OR NOT OCV_DEPENDENCIES_FOUND)
|
||||||
set(project "va_intel")
|
return()
|
||||||
string(TOUPPER "${project}" project_upper)
|
endif()
|
||||||
|
|
||||||
project("${project}_samples")
|
|
||||||
|
|
||||||
|
project(va_intel_samples)
|
||||||
ocv_include_modules_recurse(${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS})
|
ocv_include_modules_recurse(${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS})
|
||||||
|
|
||||||
# ---------------------------------------------
|
|
||||||
# Define executable targets
|
|
||||||
# ---------------------------------------------
|
|
||||||
MACRO(OPENCV_DEFINE_VA_INTEL_EXAMPLE name srcs)
|
|
||||||
set(the_target "example_${project}_${name}")
|
|
||||||
add_executable(${the_target} ${srcs})
|
|
||||||
|
|
||||||
ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS} ${VA_LIBRARIES} ${VA_INTEL_LIBRARIES})
|
|
||||||
|
|
||||||
set_target_properties(${the_target} PROPERTIES
|
|
||||||
OUTPUT_NAME "${project}-example-${name}"
|
|
||||||
PROJECT_LABEL "(EXAMPLE_${project_upper}) ${name}")
|
|
||||||
|
|
||||||
if(ENABLE_SOLUTION_FOLDERS)
|
|
||||||
set_target_properties(${the_target} PROPERTIES FOLDER "samples//${project}")
|
|
||||||
endif()
|
|
||||||
ENDMACRO()
|
|
||||||
|
|
||||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||||
|
|
||||||
foreach(sample_filename ${all_samples})
|
foreach(sample_filename ${all_samples})
|
||||||
get_filename_component(sample ${sample_filename} NAME_WE)
|
ocv_define_sample(tgt ${sample_filename} va_intel)
|
||||||
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*)
|
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS})
|
||||||
OPENCV_DEFINE_VA_INTEL_EXAMPLE(${sample} ${sample_srcs})
|
|
||||||
endforeach()
|
endforeach()
|
||||||
endif()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user