Commit a91a11e5 authored by Alexander Alekhin's avatar Alexander Alekhin

Merge pull request #10818 from mshabunin:install-samples-src

parents 2423cddb c6309278
...@@ -420,7 +420,7 @@ else() ...@@ -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) ...@@ -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()
......
...@@ -43,3 +43,11 @@ if(BUILD_DOCS) ...@@ -43,3 +43,11 @@ if(BUILD_DOCS)
add_custom_target(install_docs DEPENDS opencv_docs add_custom_target(install_docs DEPENDS opencv_docs
COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=docs -P "${CMAKE_BINARY_DIR}/cmake_install.cmake") COMMAND "${CMAKE_COMMAND}" -DCMAKE_INSTALL_COMPONENT=docs -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
endif() endif()
# Samples
if(BUILD_EXAMPLES)
add_custom_target(opencv_samples)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(opencv_samples PROPERTIES FOLDER "extra")
endif()
endif()
...@@ -1221,9 +1221,13 @@ function(ocv_add_samples) ...@@ -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,17 +1241,23 @@ function(ocv_add_samples) ...@@ -1237,17 +1241,23 @@ 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()
# Add single target to build all samples for the module: 'make opencv_samples_bioinspired'
set(parent_target opencv_samples_${module_id})
if(NOT TARGET ${parent_target})
add_custom_target(${parent_target})
add_dependencies(opencv_samples ${parent_target})
endif()
add_dependencies(${parent_target} ${the_target})
if(WIN32) if(WIN32)
install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${module_id}" COMPONENT samples) install(TARGETS ${the_target} RUNTIME DESTINATION "samples/${module_id}" COMPONENT samples)
...@@ -1256,8 +1266,8 @@ function(ocv_add_samples) ...@@ -1256,8 +1266,8 @@ 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}" )
LIST( APPEND sample_dirs "${ITEM}" ) LIST( APPEND sample_dirs "${ITEM}" )
...@@ -1266,10 +1276,10 @@ function(ocv_add_samples) ...@@ -1266,10 +1276,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()
...@@ -56,53 +56,42 @@ using namespace cv::cuda; ...@@ -56,53 +56,42 @@ using namespace cv::cuda;
namespace namespace
{ {
#ifndef HAVE_OPENGL #ifndef HAVE_OPENGL
inline void throw_no_ogl() { CV_Error(cv::Error::OpenGlNotSupported, "The library is compiled without OpenGL support"); } inline static void throw_no_ogl() { CV_Error(cv::Error::OpenGlNotSupported, "The library is compiled without OpenGL support"); }
#else #elif defined _DEBUG
inline void throw_no_ogl() { CV_Error(cv::Error::OpenGlApiCallError, "OpenGL context doesn't exist"); } inline static bool checkError(const char* file, const int line, const char* func = 0)
{
bool checkError(const char* file, const int line, const char* func = 0) GLenum err = gl::GetError();
if (err != gl::NO_ERROR_)
{ {
GLenum err = gl::GetError(); const char* msg;
switch (err)
if (err != gl::NO_ERROR_)
{ {
const char* msg; case gl::INVALID_ENUM:
msg = "An unacceptable value is specified for an enumerated argument";
switch (err) break;
{ case gl::INVALID_VALUE:
case gl::INVALID_ENUM: msg = "A numeric argument is out of range";
msg = "An unacceptable value is specified for an enumerated argument"; break;
break; case gl::INVALID_OPERATION:
msg = "The specified operation is not allowed in the current state";
case gl::INVALID_VALUE: break;
msg = "A numeric argument is out of range"; case gl::OUT_OF_MEMORY:
break; msg = "There is not enough memory left to execute the command";
break;
case gl::INVALID_OPERATION: default:
msg = "The specified operation is not allowed in the current state"; msg = "Unknown error";
break; };
cvError(CV_OpenGlApiCallError, func, msg, file, line);
case gl::OUT_OF_MEMORY: return false;
msg = "There is not enough memory left to execute the command";
break;
default:
msg = "Unknown error";
};
cvError(CV_OpenGlApiCallError, func, msg, file, line);
return false;
}
return true;
} }
#endif return true;
}
#define CV_CheckGlError() CV_DbgAssert( (checkError(__FILE__, __LINE__, CV_Func)) ) #endif // HAVE_OPENGL
} // namespace } // namespace
#define CV_CheckGlError() CV_DbgAssert( (checkError(__FILE__, __LINE__, CV_Func)) )
#ifdef HAVE_OPENGL #ifdef HAVE_OPENGL
namespace namespace
{ {
......
# 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()
# Add single target to build all samples in the group: 'make opencv_samples_cpp'
set(parent_target opencv_samples_${sub})
if(NOT TARGET ${parent_target})
add_custom_target(${parent_target})
if(TARGET opencv_samples)
add_dependencies(opencv_samples ${parent_target})
endif()
endif()
add_dependencies(${parent_target} ${the_target})
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
#
# ----------------------------------------------------------------------------
# CMake file for samples. See root CMakeLists.txt
# #
# ---------------------------------------------------------------------------- #===================================================================================================
function(ocv_install_example_src relpath)
if(INSTALL_C_EXAMPLES)
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_data)
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 +126,15 @@ if(MSVC) ...@@ -80,16 +126,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()
# ---------------------------------------------------------------------------- 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
SET(OPENCV_CPP_SAMPLES_REQUIRED_DEPS opencv_core opencv_imgproc opencv_flann opencv_flann
opencv_imgcodecs opencv_videoio opencv_highgui opencv_ml opencv_video opencv_imgcodecs
opencv_objdetect opencv_photo opencv_features2d opencv_calib3d opencv_videoio
opencv_stitching opencv_videostab opencv_shape ${OPENCV_MODULES_PUBLIC} ${OpenCV_LIB_COMPONENTS}) 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_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS})
file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
ocv_include_directories("${OpenCV_SOURCE_DIR}/include")#for opencv.hpp if(NOT HAVE_OPENGL)
ocv_include_modules_recurse(${OPENCV_CPP_SAMPLES_REQUIRED_DEPS}) ocv_list_filterout(cpp_samples Qt_sample)
endif()
if(HAVE_opencv_cudaoptflow) if(NOT HAVE_opencv_cudaarithm OR NOT HAVE_opencv_cudafilters)
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaoptflow/include") ocv_list_filterout(cpp_samples "/gpu/")
endif()
if(NOT VTK_USE_FILE)
ocv_list_filterout(cpp_samples "/viz/")
endif()
if(NOT HAVE_IPP_A)
ocv_list_filterout(cpp_samples "/ippasync/")
endif()
ocv_list_filterout(cpp_samples "real_time_pose_estimation/")
foreach(sample_filename ${cpp_samples})
if(sample_filename MATCHES "/viz/")
include(${VTK_USE_FILE})
endif() endif()
if(HAVE_opencv_cudaimgproc) set(package "cpp")
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaimgproc/include") if(sample_filename MATCHES "tutorial_code")
set(package "tutorial")
endif() endif()
if(HAVE_opencv_cudaarithm) ocv_define_sample(tgt ${sample_filename} ${package})
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudaarithm/include") 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() endif()
if(HAVE_opencv_cudafilters) if(sample_filename MATCHES "/viz/")
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/cudafilters/include") ocv_target_link_libraries(${tgt} ${VTK_LIBRARIES})
target_compile_definitions(${tgt} PRIVATE -DUSE_VTK)
endif() endif()
if(HAVE_OPENGL AND sample_filename MATCHES "detect_mser")
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS) target_compile_definitions(${tgt} PRIVATE HAVE_OPENGL)
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() endif()
endforeach()
# --------------------------------------------- include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt" OPTIONAL)
# 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)
if(NOT HAVE_OPENGL)
ocv_list_filterout(cpp_samples Qt_sample)
endif()
if(NOT HAVE_opencv_cudaarithm OR NOT HAVE_opencv_cudafilters)
ocv_list_filterout(cpp_samples "/gpu/")
endif()
if(NOT TARGET opencv_viz)
ocv_list_filterout(cpp_samples "/viz/")
endif()
if(NOT HAVE_IPP_A)
ocv_list_filterout(cpp_samples "/ippasync/")
endif()
foreach(sample_filename ${cpp_samples})
if(NOT "${sample_filename}" MATCHES "real_time_pose_estimation/")
get_filename_component(sample ${sample_filename} NAME_WE)
OPENCV_DEFINE_CPP_EXAMPLE(${sample} ${sample_filename})
endif()
endforeach()
include("tutorial_code/calib3d/real_time_pose_estimation/CMakeLists.txt")
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()
/* OpenCV Application Tracing support demo. */ /* OpenCV Application Tracing support demo. */
#include <iostream> #include <iostream>
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/core/utils/trace.hpp> #include <opencv2/core/utils/trace.hpp>
using namespace cv; using namespace cv;
......
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
using namespace std; using namespace std;
using namespace cv; using namespace cv;
......
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/features2d.hpp>
#include <vector> #include <vector>
#include <map> #include <map>
#include <iostream> #include <iostream>
......
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/features2d.hpp>
#include "opencv2/core/opengl.hpp" #include "opencv2/core/opengl.hpp"
#include "opencv2/cvconfig.h"
#include <vector> #include <vector>
#include <map> #include <map>
......
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/features2d.hpp>
#include <opencv2/highgui.hpp>
#include <vector> #include <vector>
#include <iostream> #include <iostream>
......
#include <opencv2/opencv.hpp> #include "opencv2/core.hpp"
#include "opencv2/video/tracking.hpp" #include "opencv2/video/tracking.hpp"
#include "opencv2/imgproc/imgproc.hpp" #include "opencv2/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp" #include "opencv2/highgui.hpp"
#include "opencv2/ml.hpp"
using namespace cv; using namespace cv;
using namespace cv::ml; using namespace cv::ml;
......
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/ml.hpp>
using namespace cv; using namespace cv;
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
* @author OpenCV team * @author OpenCV team
*/ */
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
void show_wait_destroy(const char* winname, cv::Mat img); void show_wait_destroy(const char* winname, cv::Mat img);
......
...@@ -4,7 +4,9 @@ ...@@ -4,7 +4,9 @@
* @author OpenCV Team * @author OpenCV Team
*/ */
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
......
...@@ -245,11 +245,6 @@ static inline void read(const FileNode& node, Settings& x, const Settings& defau ...@@ -245,11 +245,6 @@ static inline void read(const FileNode& node, Settings& x, const Settings& defau
x.read(node); x.read(node);
} }
static inline void write(FileStorage& fs, const String&, const Settings& s )
{
s.write(fs);
}
enum { DETECTION = 0, CAPTURING = 1, CALIBRATED = 2 }; enum { DETECTION = 0, CAPTURING = 1, CALIBRATED = 2 };
bool runCalibrationAndSave(Settings& s, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs, bool runCalibrationAndSave(Settings& s, Size imageSize, Mat& cameraMatrix, Mat& distCoeffs,
......
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 ...@@ -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} )
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
#include <iostream> #include <iostream>
#include <fstream> #include <fstream>
#include <opencv2/core/core.hpp> #include <opencv2/core.hpp>
#include "Utils.h" #include "Utils.h"
using namespace std; using namespace std;
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#define MODELREGISTRATION_H_ #define MODELREGISTRATION_H_
#include <iostream> #include <iostream>
#include <opencv2/core/core.hpp> #include <opencv2/core.hpp>
class ModelRegistration class ModelRegistration
{ {
......
#include <opencv2/features2d.hpp> #include <opencv2/features2d.hpp>
#include <opencv2/videoio.hpp> #include <opencv2/videoio.hpp>
#include <opencv2/opencv.hpp> #include <opencv2/imgproc.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/highgui.hpp> //for imshow #include <opencv2/highgui.hpp> //for imshow
#include <vector> #include <vector>
#include <iostream> #include <iostream>
......
#include <iostream> #include <iostream>
#include <opencv2/opencv_modules.hpp> #include <opencv2/opencv_modules.hpp>
#ifdef HAVE_OPENCV_ARUCO #ifdef HAVE_OPENCV_ARUCO
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/aruco.hpp> #include <opencv2/aruco.hpp>
using namespace std; using namespace std;
......
#include <iostream> #include <iostream>
#include <opencv2/opencv_modules.hpp> #include <opencv2/opencv_modules.hpp>
#ifdef HAVE_OPENCV_ARUCO #ifdef HAVE_OPENCV_ARUCO
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/aruco.hpp> #include <opencv2/aruco.hpp>
using namespace std; using namespace std;
......
#include <iostream> #include <iostream>
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/stitching.hpp>
using namespace std; using namespace std;
using namespace cv; using namespace cv;
......
#include <iostream> #include <iostream>
#include <opencv2/opencv_modules.hpp> #include <opencv2/opencv_modules.hpp>
#ifdef HAVE_OPENCV_ARUCO #ifdef HAVE_OPENCV_ARUCO
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/aruco.hpp> #include <opencv2/aruco.hpp>
using namespace std; using namespace std;
...@@ -17,32 +20,6 @@ Scalar randomColor( RNG& rng ) ...@@ -17,32 +20,6 @@ Scalar randomColor( RNG& rng )
return Scalar( icolor & 255, (icolor >> 8) & 255, (icolor >> 16) & 255 ); return Scalar( icolor & 255, (icolor >> 8) & 255, (icolor >> 16) & 255 );
} }
void calcChessboardCorners(Size boardSize, float squareSize, vector<Point3f>& corners, Pattern patternType = CHESSBOARD)
{
corners.resize(0);
switch (patternType)
{
case CHESSBOARD:
case CIRCLES_GRID:
for( int i = 0; i < boardSize.height; i++ )
for( int j = 0; j < boardSize.width; j++ )
corners.push_back(Point3f(float(j*squareSize),
float(i*squareSize), 0));
break;
case ASYMMETRIC_CIRCLES_GRID:
for( int i = 0; i < boardSize.height; i++ )
for( int j = 0; j < boardSize.width; j++ )
corners.push_back(Point3f(float((2*j + i % 2)*squareSize),
float(i*squareSize), 0));
break;
default:
CV_Error(Error::StsBadArg, "Unknown pattern type\n");
}
}
void perspectiveCorrection(const string &img1Path, const string &img2Path, const Size &patternSize, RNG &rng) void perspectiveCorrection(const string &img1Path, const string &img2Path, const Size &patternSize, RNG &rng)
{ {
Mat img1 = imread(img1Path); Mat img1 = imread(img1Path);
......
#include <iostream> #include <iostream>
#include <opencv2/opencv_modules.hpp> #include <opencv2/opencv_modules.hpp>
#ifdef HAVE_OPENCV_ARUCO #ifdef HAVE_OPENCV_ARUCO
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/aruco.hpp> #include <opencv2/aruco.hpp>
using namespace std; using namespace std;
......
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/features2d.hpp>
using namespace std; using namespace std;
using namespace cv; using namespace cv;
......
#include <opencv2/opencv.hpp> #include <opencv2/imgcodecs.hpp>
using namespace cv; using namespace cv;
using namespace std; using namespace std;
......
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
using namespace cv; using namespace cv;
using namespace std; using namespace std;
......
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <iostream> #include <iostream>
using namespace std; using namespace std;
...@@ -6,6 +8,8 @@ using namespace cv; ...@@ -6,6 +8,8 @@ using namespace cv;
#ifdef HAVE_OPENCV_VIZ #ifdef HAVE_OPENCV_VIZ
#include <opencv2/viz.hpp>
const String keys = const String keys =
"{Aide h usage ? help | | print this message }" "{Aide h usage ? help | | print this message }"
"{@arg1 | | Full path to color imag (3 channels)}" "{@arg1 | | Full path to color imag (3 channels)}"
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
#ifdef HAVE_OPENCV_XFEATURES2D #ifdef HAVE_OPENCV_XFEATURES2D
#include <opencv2/core.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/features2d.hpp> #include <opencv2/features2d.hpp>
#include <opencv2/xfeatures2d.hpp> #include <opencv2/xfeatures2d.hpp>
#include <opencv2/imgcodecs.hpp> #include <opencv2/imgcodecs.hpp>
#include <opencv2/opencv.hpp>
#include <vector> #include <vector>
// If you find this code useful, please add a reference to the following paper in your work: // If you find this code useful, please add a reference to the following paper in your work:
......
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
@date Aug 24, 2016 @date Aug 24, 2016
*/ */
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <iostream> #include <iostream>
#include <stdio.h> #include <stdio.h>
...@@ -49,4 +51,4 @@ int main(int, char**) ...@@ -49,4 +51,4 @@ int main(int, char**)
} }
// the camera will be deinitialized automatically in VideoCapture destructor // the camera will be deinitialized automatically in VideoCapture destructor
return 0; return 0;
} }
\ No newline at end of file
...@@ -5,7 +5,9 @@ ...@@ -5,7 +5,9 @@
@date Aug 24, 2016 @date Aug 24, 2016
*/ */
#include <opencv2/opencv.hpp> #include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <iostream> #include <iostream>
#include <stdio.h> #include <stdio.h>
...@@ -62,4 +64,4 @@ int main(int, char**) ...@@ -62,4 +64,4 @@ int main(int, char**)
} }
// the videofile will be closed and released automatically in VideoWriter destructor // the videofile will be closed and released automatically in VideoWriter destructor
return 0; return 0;
} }
\ No newline at end of file
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()
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)
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_DIRECTX_EXAMPLE(${sample} ${sample_srcs})
endforeach()
endif() endif()
project("directx_samples")
ocv_include_modules_recurse(${tgt} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
foreach(sample_filename ${all_samples})
ocv_define_sample(tgt ${sample_filename} directx)
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS})
endforeach()
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)
# Model branch name: dnn_samples_face_detector_20170830
set(DNN_FACE_DETECTOR_MODEL_COMMIT "b2bfc75f6aea5b1f834ff0f0b865a7c18ff1459f")
set(DNN_FACE_DETECTOR_MODEL_HASH "afbb6037fd180e8d2acb3b58ca737b9e")
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")
if(COMMAND ocv_download)
ocv_download(FILENAME ${DNN_FACE_DETECTOR_MODEL_NAME}
HASH ${DNN_FACE_DETECTOR_MODEL_HASH}
URL
"$ENV{OPENCV_DNN_MODELS_URL}"
"${OPENCV_DNN_MODELS_URL}"
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${DNN_FACE_DETECTOR_MODEL_COMMIT}/"
DESTINATION_DIR ${DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR}
ID DNN_FACE_DETECTOR
RELATIVE_URL
STATUS res)
endif()
ocv_include_directories("${OpenCV_SOURCE_DIR}/include")
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)
foreach(sample_filename ${dnn_samples})
get_filename_component(sample ${sample_filename} NAME_WE)
OPENCV_DEFINE_DNN_EXAMPLE(${sample} ${sample_filename})
endforeach()
endif() endif()
if(INSTALL_C_EXAMPLES AND NOT WIN32) # Model branch name: dnn_samples_face_detector_20170830
file(GLOB C_SAMPLES *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd ) set(DNN_FACE_DETECTOR_MODEL_COMMIT "b2bfc75f6aea5b1f834ff0f0b865a7c18ff1459f")
install(FILES ${C_SAMPLES} set(DNN_FACE_DETECTOR_MODEL_HASH "afbb6037fd180e8d2acb3b58ca737b9e")
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/dnn set(DNN_FACE_DETECTOR_MODEL_NAME "res10_300x300_ssd_iter_140000.caffemodel")
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples) set(DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR "${CMAKE_CURRENT_LIST_DIR}/face_detector")
if(COMMAND ocv_download)
ocv_download(FILENAME ${DNN_FACE_DETECTOR_MODEL_NAME}
HASH ${DNN_FACE_DETECTOR_MODEL_HASH}
URL
"$ENV{OPENCV_DNN_MODELS_URL}"
"${OPENCV_DNN_MODELS_URL}"
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${DNN_FACE_DETECTOR_MODEL_COMMIT}/"
DESTINATION_DIR ${DNN_FACE_DETECTOR_MODEL_DOWNLOAD_DIR}
ID DNN_FACE_DETECTOR
RELATIVE_URL
STATUS res)
endif() endif()
project(dnn_samples)
ocv_include_modules_recurse(${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
file(GLOB_RECURSE dnn_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
foreach(sample_filename ${dnn_samples})
ocv_define_sample(tgt ${sample_filename} dnn)
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_DNN_SAMPLES_REQUIRED_DEPS})
endforeach()
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 set(OPENCV_CUDA_SAMPLES_REQUIRED_DEPS
opencv_cudaarithm opencv_cudafilters opencv_cudawarping opencv_cudaimgproc opencv_core
opencv_cudafeatures2d opencv_cudaoptflow opencv_cudabgsegm opencv_flann
opencv_cudastereo opencv_cudalegacy opencv_cudaobjdetect) 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")
ocv_include_modules_recurse(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
project(gpu_samples)
ocv_include_modules_recurse(${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS})
if(HAVE_opencv_xfeatures2d)
ocv_include_modules_recurse(opencv_xfeatures2d)
endif()
if(HAVE_opencv_cudacodec)
ocv_include_modules_recurse(opencv_cudacodec)
endif()
if(HAVE_CUDA)
ocv_include_directories(${CUDA_INCLUDE_DIRS})
endif()
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
endif()
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
if(NOT HAVE_OPENGL)
ocv_list_filterout(all_samples "opengl")
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_include_modules_recurse(opencv_xfeatures2d) ocv_target_link_libraries(${tgt} opencv_xfeatures2d)
endif() endif()
if(HAVE_opencv_cudacodec) if(HAVE_opencv_cudacodec)
ocv_include_modules_recurse(opencv_cudacodec) ocv_target_link_libraries(${tgt} opencv_cudacodec)
endif()
if(HAVE_CUDA)
ocv_include_directories(${CUDA_INCLUDE_DIRS})
endif() endif()
endforeach()
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS) include("performance/CMakeLists.txt" OPTIONAL)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
endif()
# ---------------------------------------------
# Define executable targets
# ---------------------------------------------
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()
if(HAVE_opencv_xfeatures2d)
ocv_target_link_libraries(${the_target} opencv_xfeatures2d)
endif()
if(HAVE_opencv_cudacodec)
ocv_target_link_libraries(${the_target} opencv_cudacodec)
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()
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) ...@@ -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()
# 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()
find_package(OpenCL 1.2 QUIET) endif()
if(NOT OpenCL_FOUND)
message(STATUS "OpenCL samples are skipped: OpenCL SDK is required")
return()
endif()
set(project "opencl")
string(TOUPPER "${project}" project_upper)
project("${project}_samples")
ocv_include_modules_recurse(${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS})
include_directories(${OpenCL_INCLUDE_DIR})
# ---------------------------------------------
# Define executable targets
# ---------------------------------------------
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_OPENCL_SAMPLES_REQUIRED_DEPS}
${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}) find_package(OpenCL 1.2 QUIET)
get_filename_component(sample ${sample_filename} NAME_WE) if(NOT OpenCL_FOUND)
file(GLOB sample_srcs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${sample}.*) message(STATUS "OpenCL samples are skipped: OpenCL SDK is required")
OPENCV_DEFINE_OPENCL_EXAMPLE(${sample} ${sample_srcs}) return()
endforeach()
endif() endif()
project(opencl_samples)
ocv_include_modules_recurse(${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS})
ocv_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)
ocv_target_link_libraries(${tgt}
${OPENCV_LINKER_LIBS}
${OPENCV_OPENCL_SAMPLES_REQUIRED_DEPS}
${OpenCL_LIBRARY})
endforeach()
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#define CL_USE_DEPRECATED_OPENCL_2_0_APIS // eliminate build warning #define CL_USE_DEPRECATED_OPENCL_2_0_APIS // eliminate build warning
#if __APPLE__ #ifdef __APPLE__
#include <OpenCL/cl.h> #include <OpenCL/cl.h>
#else #else
#include <CL/cl.h> #include <CL/cl.h>
......
...@@ -12,50 +12,23 @@ if(UNIX) ...@@ -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)
cmake_minimum_required(VERSION 2.8.9) ocv_install_example_src(cpp *.cpp *.hpp CMakeLists.txt)
set(OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio opencv_highgui) cmake_minimum_required(VERSION 2.8.9)
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")
set(name_orig "interop_orig")
set(name_video "interop_video")
project("${group}_sample")
ocv_include_modules_recurse(${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS})
add_definitions(-DIVX_USE_OPENCV)
add_definitions(-DIVX_HIDE_INFO_WARNINGS)
file(GLOB srcs_wrapped wrappers.cpp *.hpp)
file(GLOB srcs_orig no_wrappers.cpp *.hpp)
file(GLOB srcs_video wrappers_video.cpp *.hpp)
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() endif()
project(openvx_samples)
ocv_include_modules_recurse(${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS})
add_definitions(-DIVX_USE_OPENCV)
add_definitions(-DIVX_HIDE_INFO_WARNINGS)
file(GLOB_RECURSE cpp_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
foreach(sample_filename ${cpp_samples})
ocv_define_sample(tgt ${sample_filename} openvx)
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_OPENVX_SAMPLE_REQUIRED_DEPS})
endforeach()
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)
project("${project}_samples")
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)
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_TAPI_EXAMPLE(${sample} ${sample_srcs})
endforeach()
endif() endif()
if(INSTALL_C_EXAMPLES AND NOT WIN32) project(tapi_samples)
file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd ) ocv_include_modules_recurse(${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
install(FILES ${install_list} file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/tapi foreach(sample_filename ${all_samples})
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples) ocv_define_sample(tgt ${sample_filename} tapi)
endif() ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS})
endforeach()
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)
project("${project}_samples")
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)
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_VA_INTEL_EXAMPLE(${sample} ${sample_srcs})
endforeach()
endif() endif()
project(va_intel_samples)
ocv_include_modules_recurse(${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS})
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
foreach(sample_filename ${all_samples})
ocv_define_sample(tgt ${sample_filename} va_intel)
ocv_target_link_libraries(${tgt} ${OPENCV_LINKER_LIBS} ${OPENCV_VA_INTEL_SAMPLES_REQUIRED_DEPS})
endforeach()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment