From 8184535de15a339e541e478b76f5a3bc4a88e0ef Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Wed, 29 Jun 2016 16:35:48 +0300 Subject: [PATCH] samples: repair viz tutorial --- modules/core/include/opencv2/core/types.hpp | 12 ++++++++++++ samples/cpp/CMakeLists.txt | 13 +++++++++---- samples/cpp/tutorial_code/viz/creating_widgets.cpp | 9 +++++++++ samples/cpp/tutorial_code/viz/launching_viz.cpp | 2 +- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/modules/core/include/opencv2/core/types.hpp b/modules/core/include/opencv2/core/types.hpp index e166556af7..2feedfcca8 100644 --- a/modules/core/include/opencv2/core/types.hpp +++ b/modules/core/include/opencv2/core/types.hpp @@ -231,7 +231,11 @@ public: //! conversion to another data type template operator Point3_<_Tp2>() const; //! conversion to cv::Vec<> +#if OPENCV_ABI_COMPATIBILITY > 300 + template operator Vec<_Tp2, 3>() const; +#else operator Vec<_Tp, 3>() const; +#endif //! dot product _Tp dot(const Point3_& pt) const; @@ -1326,11 +1330,19 @@ Point3_<_Tp>::operator Point3_<_Tp2>() const return Point3_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(z)); } +#if OPENCV_ABI_COMPATIBILITY > 300 +template template inline +Point3_<_Tp>::operator Vec<_Tp2, 3>() const +{ + return Vec<_Tp2, 3>(x, y, z); +} +#else template inline Point3_<_Tp>::operator Vec<_Tp, 3>() const { return Vec<_Tp, 3>(x, y, z); } +#endif template inline Point3_<_Tp>& Point3_<_Tp>::operator = (const Point3_& pt) diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index d93d0196a2..c75a5c73e2 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -31,7 +31,8 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) endif() 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 -Wno-missing-declarations") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function -Wno-missing-declarations") endif() # --------------------------------------------- @@ -57,8 +58,10 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) ocv_target_link_libraries(${the_target} opencv_cudaarithm opencv_cudafilters) endif() - if(HAVE_opencv_ocl) - ocv_target_link_libraries(${the_target} opencv_ocl) + 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 @@ -88,7 +91,9 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) ocv_list_filterout(cpp_samples "/gpu/") endif() - ocv_list_filterout(cpp_samples "viz") + if(NOT TARGET opencv_viz) + ocv_list_filterout(cpp_samples "/viz/") + endif() if(NOT HAVE_IPP_A) ocv_list_filterout(cpp_samples "/ippasync/") diff --git a/samples/cpp/tutorial_code/viz/creating_widgets.cpp b/samples/cpp/tutorial_code/viz/creating_widgets.cpp index 63f572e56b..f26c93ee66 100644 --- a/samples/cpp/tutorial_code/viz/creating_widgets.cpp +++ b/samples/cpp/tutorial_code/viz/creating_widgets.cpp @@ -4,6 +4,14 @@ * @author Ozan Cagri Tonkal */ +#ifndef USE_VTK +#include +int main() +{ + std::cout << "This sample requires direct compilation with VTK. Stop" << std::endl; + return 0; +} +#else #include #include #include @@ -111,3 +119,4 @@ int main() return 0; } +#endif diff --git a/samples/cpp/tutorial_code/viz/launching_viz.cpp b/samples/cpp/tutorial_code/viz/launching_viz.cpp index d19967e4b0..9c636ebaf2 100644 --- a/samples/cpp/tutorial_code/viz/launching_viz.cpp +++ b/samples/cpp/tutorial_code/viz/launching_viz.cpp @@ -41,7 +41,7 @@ int main() cout << "First event loop is over" << endl; /// Access window via its name - viz::Viz3d sameWindow = viz::get("Viz Demo"); + viz::Viz3d sameWindow = viz::getWindowByName("Viz Demo"); /// Start event loop sameWindow.spin();