Commit e625d864 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

added C= support; modified threading logic in threshold

parent 1516a616
...@@ -132,6 +132,7 @@ OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON ...@@ -132,6 +132,7 @@ OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON
OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS) ) OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF IF APPLE ) OCV_OPTION(WITH_QUICKTIME "Use QuickTime for Video I/O insted of QTKit" OFF IF APPLE )
OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS) ) OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS) )
OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF WIN32 )
OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) ) OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) )
OCV_OPTION(WITH_UNICAP "Include Unicap support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) ) OCV_OPTION(WITH_UNICAP "Include Unicap support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) ) OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
...@@ -746,6 +747,10 @@ if(DEFINED WITH_TBB) ...@@ -746,6 +747,10 @@ if(DEFINED WITH_TBB)
status(" Use TBB:" HAVE_TBB THEN "YES (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})" ELSE NO) status(" Use TBB:" HAVE_TBB THEN "YES (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})" ELSE NO)
endif(DEFINED WITH_TBB) endif(DEFINED WITH_TBB)
if(DEFINED WITH_CSTRIPES)
status(" Use C=:" HAVE_CSTRIPES THEN YES ELSE NO)
endif(DEFINED WITH_CSTRIPES)
if(DEFINED WITH_CUDA) if(DEFINED WITH_CUDA)
status(" Use Cuda:" HAVE_CUDA THEN "YES (ver ${CUDA_VERSION_STRING})" ELSE NO) status(" Use Cuda:" HAVE_CUDA THEN "YES (ver ${CUDA_VERSION_STRING})" ELSE NO)
endif(DEFINED WITH_CUDA) endif(DEFINED WITH_CUDA)
......
if(WIN32)
find_path( CSTRIPES_LIB_DIR
NAMES "С=.lib"
DOC "The path to C= lib and dll")
if(CSTRIPES_LIB_DIR)
ocv_include_directories("${CSTRIPES_LIB_DIR}/..")
link_directories("${CSTRIPES_LIB_DIR}")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} "С=")
set(HAVE_CSTRIPES 1)
endif()
endif()
...@@ -7,6 +7,11 @@ if(WITH_TBB) ...@@ -7,6 +7,11 @@ if(WITH_TBB)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectTBB.cmake") include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectTBB.cmake")
endif(WITH_TBB) endif(WITH_TBB)
# --- C= ---
if(WITH_CSTRIPES)
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCStripes.cmake")
endif(WITH_CSTRIPES)
# --- IPP --- # --- IPP ---
ocv_clear_vars(IPP_FOUND) ocv_clear_vars(IPP_FOUND)
if(WITH_IPP) if(WITH_IPP)
......
...@@ -166,6 +166,9 @@ ...@@ -166,6 +166,9 @@
/* Intel Threading Building Blocks */ /* Intel Threading Building Blocks */
#cmakedefine HAVE_TBB #cmakedefine HAVE_TBB
/* C= */
#cmakedefine HAVE_CSTRIPES
/* Eigen Matrix & Linear Algebra Library */ /* Eigen Matrix & Linear Algebra Library */
#cmakedefine HAVE_EIGEN #cmakedefine HAVE_EIGEN
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include "precomp.hpp" #include "precomp.hpp"
#if !defined HAVE_TBB && !defined HAVE_OPENMP && !defined HAVE_GCD && !defined HAVE_CONCURRENCY #if !defined HAVE_TBB && !defined HAVE_OPENMP && !defined HAVE_GCD && !defined HAVE_CONCURRENCY && !defined HAVE_CSTRIPES
#ifdef __APPLE__ #ifdef __APPLE__
#define HAVE_GCD #define HAVE_GCD
#elif defined _MSC_VER && _MSC_VER >= 1600 #elif defined _MSC_VER && _MSC_VER >= 1600
...@@ -66,7 +66,10 @@ ...@@ -66,7 +66,10 @@
#else #else
#undef HAVE_TBB #undef HAVE_TBB
#endif // end TBB version #endif // end TBB version
#endif // HAVE_CONCURRENCY #elif defined HAVE_CSTRIPES
#include "C=.h"
#undef shared
#endif
/* /*
HAVE_TBB - using TBB HAVE_TBB - using TBB
...@@ -137,11 +140,22 @@ namespace cv ...@@ -137,11 +140,22 @@ namespace cv
for (int i = range.start; i < range.end; ++i) for (int i = range.start; i < range.end; ++i)
body(Range(i, i + 1)); body(Range(i, i + 1));
#elif defined (HAVE_GCD) #elif defined HAVE_GCD
dispatch_queue_t concurrent_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0); dispatch_queue_t concurrent_queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
dispatch_apply_f(range.end - range.start, concurrent_queue, &const_cast<ParallelLoopBody&>(body), block_function); dispatch_apply_f(range.end - range.start, concurrent_queue, &const_cast<ParallelLoopBody&>(body), block_function);
#elif defined HAVE_CSTRIPES
parallel()
{
int offset = range.start;
int len = range.end - offset;
Range r(offset + CPX_RANGE_START(len), offset + CPX_RANGE_END(len));
body(r);
barrier();
}
#else #else
body(range); body(range);
......
...@@ -730,11 +730,6 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m ...@@ -730,11 +730,6 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
_dst.create( src.size(), src.type() ); _dst.create( src.size(), src.type() );
Mat dst = _dst.getMat(); Mat dst = _dst.getMat();
int nStripes = 1;
#if defined HAVE_TBB && defined ANDROID
nStripes = 4;
#endif
if( src.depth() == CV_8U ) if( src.depth() == CV_8U )
{ {
int ithresh = cvFloor(thresh); int ithresh = cvFloor(thresh);
...@@ -794,7 +789,9 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m ...@@ -794,7 +789,9 @@ double cv::threshold( InputArray _src, OutputArray _dst, double thresh, double m
else else
CV_Error( CV_StsUnsupportedFormat, "" ); CV_Error( CV_StsUnsupportedFormat, "" );
parallel_for_(Range(0, nStripes), size_t nStripes = (src.total() + (1<<15)) >> 16;
nStripes = MAX(MIN(nStripes, (size_t)4), (size_t)1);
parallel_for_(Range(0, (int)nStripes),
ThresholdRunner(src, dst, nStripes, thresh, maxval, type)); ThresholdRunner(src, dst, nStripes, thresh, maxval, type));
return thresh; return thresh;
} }
......
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