From 840088e0213d5c5fd610d68b3da5a2fbf2e841db Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 30 Dec 2014 15:52:23 +0300 Subject: [PATCH] Get rid of cvconfig.h in Latent SVM samples. Use common OpenCV parallel framework instead of direct TBB calls. --- samples/c/CMakeLists.txt | 2 +- samples/c/latentsvmdetect.cpp | 24 +----------------------- samples/cpp/CMakeLists.txt | 2 +- samples/cpp/latentsvm_multidetect.cpp | 8 -------- samples/gpu/CMakeLists.txt | 2 +- samples/ocl/CMakeLists.txt | 2 +- 6 files changed, 5 insertions(+), 35 deletions(-) diff --git a/samples/c/CMakeLists.txt b/samples/c/CMakeLists.txt index 6d374e7443..0a74c12041 100644 --- a/samples/c/CMakeLists.txt +++ b/samples/c/CMakeLists.txt @@ -51,7 +51,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) endforeach() endif() -if (INSTALL_C_EXAMPLES AND NOT WIN32) +if (OCV_DEPENDENCIES_FOUND AND 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}/c diff --git a/samples/c/latentsvmdetect.cpp b/samples/c/latentsvmdetect.cpp index e74b227a62..92e237a24a 100644 --- a/samples/c/latentsvmdetect.cpp +++ b/samples/c/latentsvmdetect.cpp @@ -2,13 +2,6 @@ #include "opencv2/highgui/highgui.hpp" #include -#ifdef HAVE_CVCONFIG_H -#include -#endif -#ifdef HAVE_TBB -#include "tbb/task_scheduler_init.h" -#endif - using namespace cv; static void help() @@ -31,28 +24,13 @@ static void detect_and_draw_objects( IplImage* image, CvLatentSvmDetector* detec CvSeq* detections = 0; int i = 0; int64 start = 0, finish = 0; -#ifdef HAVE_TBB - tbb::task_scheduler_init init(tbb::task_scheduler_init::deferred); - if (numThreads > 0) - { - init.initialize(numThreads); - printf("Number of threads %i\n", numThreads); - } - else - { - printf("Number of threads is not correct for TBB version"); - return; - } -#endif + cv::setNumThreads(numThreads); start = cvGetTickCount(); detections = cvLatentSvmDetectObjects(image, detector, storage, 0.5f, numThreads); finish = cvGetTickCount(); printf("detection time = %.3f\n", (float)(finish - start) / (float)(cvGetTickFrequency() * 1000000.0)); -#ifdef HAVE_TBB - init.terminate(); -#endif for( i = 0; i < detections->total; i++ ) { CvObjectDetection detection = *(CvObjectDetection*)cvGetSeqElem( detections, i ); diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index 1f55ed90f3..ece136552a 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -90,7 +90,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) endforeach() endif() -if (INSTALL_C_EXAMPLES AND NOT WIN32) +if (OCV_DEPENDENCIES_FOUND AND 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 diff --git a/samples/cpp/latentsvm_multidetect.cpp b/samples/cpp/latentsvm_multidetect.cpp index 37297e23de..de368eab5d 100644 --- a/samples/cpp/latentsvm_multidetect.cpp +++ b/samples/cpp/latentsvm_multidetect.cpp @@ -9,14 +9,6 @@ #include #endif -#ifdef HAVE_CVCONFIG_H -#include -#endif - -#ifdef HAVE_TBB -#include "tbb/task_scheduler_init.h" -#endif - using namespace std; using namespace cv; diff --git a/samples/gpu/CMakeLists.txt b/samples/gpu/CMakeLists.txt index d25c3a6b5d..17d114b33b 100644 --- a/samples/gpu/CMakeLists.txt +++ b/samples/gpu/CMakeLists.txt @@ -80,7 +80,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) include("performance/CMakeLists.txt") endif() -if (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 ) install(FILES ${install_list} DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/gpu diff --git a/samples/ocl/CMakeLists.txt b/samples/ocl/CMakeLists.txt index 7fc20fd356..373774e376 100644 --- a/samples/ocl/CMakeLists.txt +++ b/samples/ocl/CMakeLists.txt @@ -51,7 +51,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) endforeach() endif() -if (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 ) install(FILES ${install_list} DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/ocl