GPU samples with NVIDIA specific API excluded from build if CUDA disabled.

pull/3604/head
Alexander Smorkalov 10 years ago
parent b0c5f49170
commit 3425c90b66
  1. 33
      samples/gpu/CMakeLists.txt
  2. 21
      samples/gpu/cascadeclassifier_nvidia_api.cpp
  3. 14
      samples/gpu/opticalflow_nvidia_api.cpp

@ -69,11 +69,27 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
endif() endif()
ENDMACRO() ENDMACRO()
# remove all matching elements from the list
MACRO(list_filterout lst regex)
foreach(item ${${lst}})
if(item MATCHES "${regex}")
list(REMOVE_ITEM ${lst} "${item}")
endif()
endforeach()
ENDMACRO()
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
if(NOT WITH_OPENGL) if(NOT HAVE_OPENGL)
list(REMOVE_ITEM all_samples "opengl.cpp") list(REMOVE_ITEM all_samples "opengl.cpp")
endif(NOT WITH_OPENGL) endif()
if(NOT HAVE_CUDA)
list(REMOVE_ITEM all_samples "opticalflow_nvidia_api.cpp")
list(REMOVE_ITEM all_samples "cascadeclassifier_nvidia_api.cpp")
list(REMOVE_ITEM all_samples "driver_api_multi.cpp")
list(REMOVE_ITEM all_samples "driver_api_stereo_multi.cpp")
endif()
foreach(sample_filename ${all_samples}) foreach(sample_filename ${all_samples})
get_filename_component(sample ${sample_filename} NAME_WE) get_filename_component(sample ${sample_filename} NAME_WE)
@ -86,9 +102,16 @@ endif()
if (OCV_DEPENDENCIES_FOUND AND INSTALL_C_EXAMPLES AND NOT WIN32) if (OCV_DEPENDENCIES_FOUND AND INSTALL_C_EXAMPLES AND NOT WIN32)
file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd ) file(GLOB install_list *.c *.cpp *.jpg *.png *.data makefile.* build_all.sh *.dsp *.cmd )
if(NOT WITH_OPENGL) message(" install_list: ${install_list}")
list(REMOVE_ITEM all_samples "opengl.cpp") if(NOT HAVE_OPENGL)
endif(NOT WITH_OPENGL) list_filterout(install_list ".*opengl.cpp")
endif()
if(NOT HAVE_CUDA)
list_filterout(install_list ".*opticalflow_nvidia_api.cpp")
list_filterout(install_list ".*cascadeclassifier_nvidia_api.cpp")
list_filterout(install_list ".*driver_api_multi.cpp")
list_filterout(install_list ".*driver_api_stereo_multi.cpp")
endif()
install(FILES ${install_list} install(FILES ${install_list}
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples) PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)

@ -2,39 +2,24 @@
#pragma warning( disable : 4201 4408 4127 4100) #pragma warning( disable : 4201 4408 4127 4100)
#endif #endif
#include "cvconfig.h"
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include <cstdio> #include <cstdio>
#include "opencv2/gpu/gpu.hpp" #include "opencv2/gpu/gpu.hpp"
#include "opencv2/highgui/highgui.hpp" #include "opencv2/highgui/highgui.hpp"
#ifdef HAVE_CUDA
#include "NCVHaarObjectDetection.hpp" #include "NCVHaarObjectDetection.hpp"
#endif
using namespace std; using namespace std;
using namespace cv; using namespace cv;
#if !defined(HAVE_CUDA) || defined(__arm__)
int main( int, const char** )
{
#if !defined(HAVE_CUDA)
std::cout << "CUDA support is required (CMake key 'WITH_CUDA' must be true)." << std::endl;
#endif
#if defined(__arm__) #if defined(__arm__)
int main()
{
std::cout << "Unsupported for ARM CUDA library." << std::endl; std::cout << "Unsupported for ARM CUDA library." << std::endl;
#endif
return 0; return 0;
} }
#else #else
const Size2i preferredVideoFrameSize(640, 480); const Size2i preferredVideoFrameSize(640, 480);
const string wndTitle = "NVIDIA Computer Vision :: Haar Classifiers Cascade"; const string wndTitle = "NVIDIA Computer Vision :: Haar Classifiers Cascade";
@ -386,4 +371,4 @@ int main(int argc, const char** argv)
return 0; return 0;
} }
#endif //!defined(HAVE_CUDA) #endif

@ -9,26 +9,14 @@
#include <ctime> #include <ctime>
#include <ctype.h> #include <ctype.h>
#include "cvconfig.h"
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>
#include "opencv2/gpu/gpu.hpp" #include "opencv2/gpu/gpu.hpp"
#include "opencv2/highgui/highgui.hpp" #include "opencv2/highgui/highgui.hpp"
#ifdef HAVE_CUDA
#include "NPP_staging/NPP_staging.hpp" #include "NPP_staging/NPP_staging.hpp"
#include "NCVBroxOpticalFlow.hpp" #include "NCVBroxOpticalFlow.hpp"
#endif
#if !defined(HAVE_CUDA)
int main( int, const char** )
{
std::cout << "Please compile the library with CUDA support" << std::endl;
return -1;
}
#else
//using std::tr1::shared_ptr;
using cv::Ptr; using cv::Ptr;
#define PARAM_LEFT "--left" #define PARAM_LEFT "--left"
@ -649,5 +637,3 @@ int main(int argc, char **argv)
return 0; return 0;
} }
#endif

Loading…
Cancel
Save