Skip to content

Commit 0428dce

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 60354e3 + f9fbd29 commit 0428dce

File tree

19 files changed

+1152
-1467
lines changed

19 files changed

+1152
-1467
lines changed

doc/tutorials/imgproc/anisotropic_image_segmentation/anisotropic_image_segmentation.markdown

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ J_{12} & J_{22}
3737
where \f$J_{11} = M[Z_{x}^{2}]\f$, \f$J_{22} = M[Z_{y}^{2}]\f$, \f$J_{12} = M[Z_{x}Z_{y}]\f$ - components of the tensor, \f$M[]\f$ is a symbol of mathematical expectation (we can consider this operation as averaging in a window w), \f$Z_{x}\f$ and \f$Z_{y}\f$ are partial derivatives of an image \f$Z\f$ with respect to \f$x\f$ and \f$y\f$.
3838

3939
The eigenvalues of the tensor can be found in the below formula:
40-
\f[\lambda_{1,2} = J_{11} + J_{22} \pm \sqrt{(J_{11} - J_{22})^{2} + 4J_{12}^{2}}\f]
40+
\f[\lambda_{1,2} = \frac{1}{2} \left [ J_{11} + J_{22} \pm \sqrt{(J_{11} - J_{22})^{2} + 4J_{12}^{2}} \right ] \f]
4141
where \f$\lambda_1\f$ - largest eigenvalue, \f$\lambda_2\f$ - smallest eigenvalue.
4242

4343
### How to estimate orientation and coherency of an anisotropic image by gradient structure tensor?

modules/core/src/ocl.cpp

Lines changed: 9 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@
4040
//M*/
4141

4242
#include "precomp.hpp"
43+
44+
#ifndef HAVE_OPENCL
45+
#include "ocl_disabled.impl.hpp"
46+
#else // HAVE_OPENCL
47+
4348
#include <list>
4449
#include <map>
4550
#include <deque>
@@ -106,23 +111,7 @@
106111
#include "opencv2/core/opencl/runtime/opencl_clamdblas.hpp"
107112
#include "opencv2/core/opencl/runtime/opencl_clamdfft.hpp"
108113

109-
#ifdef HAVE_OPENCL
110114
#include "opencv2/core/opencl/runtime/opencl_core.hpp"
111-
#else
112-
#if defined(_MSC_VER)
113-
#pragma warning(push)
114-
#pragma warning(disable : 4100)
115-
#pragma warning(disable : 4702)
116-
#elif defined(__clang__)
117-
#pragma clang diagnostic push
118-
#pragma clang diagnostic ignored "-Wunused-parameter"
119-
#elif defined(__GNUC__)
120-
#pragma GCC diagnostic push
121-
#pragma GCC diagnostic ignored "-Wunused-parameter"
122-
#endif
123-
// TODO FIXIT: This file can't be build without OPENCL
124-
#include "ocl_deprecated.hpp"
125-
#endif // HAVE_OPENCL
126115

127116
#ifdef HAVE_OPENCL_SVM
128117
#include "opencv2/core/opencl/runtime/opencl_svm_20.hpp"
@@ -147,31 +136,6 @@ cv::utils::AllocatorStatisticsInterface& getOpenCLAllocatorStatistics()
147136
return opencl_allocator_stats;
148137
}
149138

150-
#ifndef HAVE_OPENCL
151-
#define CV_OPENCL_NO_SUPPORT() CV_Error(cv::Error::OpenCLApiCallError, "OpenCV build without OpenCL support")
152-
namespace {
153-
struct DummyImpl
154-
{
155-
DummyImpl() { CV_OPENCL_NO_SUPPORT(); }
156-
~DummyImpl() { /* do not throw in desctructors */ }
157-
IMPLEMENT_REFCOUNTABLE();
158-
};
159-
} // namespace
160-
161-
// TODO Replace to empty body (without HAVE_OPENCL)
162-
#define CV_OCL_TRACE_CHECK_RESULT(status, message) /* nothing */
163-
#define CV_OCL_API_ERROR_MSG(check_result, msg) cv::String()
164-
#define CV_OCL_CHECK_RESULT(check_result, msg) (void)check_result
165-
#define CV_OCL_CHECK_(expr, check_result) expr; (void)check_result
166-
#define CV_OCL_CHECK(expr) do { cl_int __cl_result = (expr); CV_OCL_CHECK_RESULT(__cl_result, #expr); } while (0)
167-
#define CV_OCL_DBG_CHECK_RESULT(check_result, msg) (void)check_result
168-
#define CV_OCL_DBG_CHECK_(expr, check_result) expr; (void)check_result
169-
#define CV_OCL_DBG_CHECK(expr) do { cl_int __cl_result = (expr); CV_OCL_CHECK_RESULT(__cl_result, #expr); } while (0)
170-
171-
static const bool CV_OPENCL_DISABLE_BUFFER_RECT_OPERATIONS = false;
172-
173-
#else // HAVE_OPENCL
174-
175139
#ifndef _DEBUG
176140
static bool isRaiseError()
177141
{
@@ -270,7 +234,6 @@ static const String getBuildExtraOptions()
270234
static const bool CV_OPENCL_ENABLE_MEM_USE_HOST_PTR = utils::getConfigurationParameterBool("OPENCV_OPENCL_ENABLE_MEM_USE_HOST_PTR", true);
271235
static const size_t CV_OPENCL_ALIGNMENT_MEM_USE_HOST_PTR = utils::getConfigurationParameterSizeT("OPENCV_OPENCL_ALIGNMENT_MEM_USE_HOST_PTR", 4);
272236

273-
#endif // HAVE_OPENCL
274237

275238
struct UMat2D
276239
{
@@ -331,7 +294,7 @@ static uint64 crc64( const uchar* data, size_t size, uint64 crc0=0 )
331294
return ~crc;
332295
}
333296

334-
#if defined HAVE_OPENCL && OPENCV_HAVE_FILESYSTEM_SUPPORT
297+
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
335298
struct OpenCLBinaryCacheConfigurator
336299
{
337300
cv::String cache_path_;
@@ -872,7 +835,6 @@ static bool g_isOpenCVActivated = false;
872835
bool haveOpenCL()
873836
{
874837
CV_TRACE_FUNCTION();
875-
#ifdef HAVE_OPENCL
876838
static bool g_isOpenCLInitialized = false;
877839
static bool g_isOpenCLAvailable = false;
878840

@@ -902,9 +864,6 @@ bool haveOpenCL()
902864
g_isOpenCLInitialized = true;
903865
}
904866
return g_isOpenCLAvailable;
905-
#else
906-
return false;
907-
#endif
908867
}
909868

910869
bool useOpenCL()
@@ -924,14 +883,12 @@ bool useOpenCL()
924883
return data.useOpenCL > 0;
925884
}
926885

927-
#ifdef HAVE_OPENCL
928886
bool isOpenCLActivated()
929887
{
930888
if (!g_isOpenCVActivated)
931889
return false; // prevent unnecessary OpenCL activation via useOpenCL()->haveOpenCL() calls
932890
return useOpenCL();
933891
}
934-
#endif
935892

936893
void setUseOpenCL(bool flag)
937894
{
@@ -1953,7 +1910,6 @@ static unsigned int getSVMCapabilitiesMask()
19531910
} // namespace
19541911
#endif
19551912

1956-
#ifdef HAVE_OPENCL
19571913
static size_t getProgramCountLimit()
19581914
{
19591915
static bool initialized = false;
@@ -1965,7 +1921,6 @@ static size_t getProgramCountLimit()
19651921
}
19661922
return count;
19671923
}
1968-
#endif
19691924

19701925
struct Context::Impl
19711926
{
@@ -3548,8 +3503,6 @@ internal::ProgramEntry::operator ProgramSource&() const
35483503

35493504
/////////////////////////////////////////// Program /////////////////////////////////////////////
35503505

3551-
#ifdef HAVE_OPENCL
3552-
35533506
static
35543507
cv::String joinBuildOptions(const cv::String& a, const cv::String& b)
35553508
{
@@ -3963,10 +3916,6 @@ struct Program::Impl
39633916
String sourceName_;
39643917
};
39653918

3966-
#else // HAVE_OPENCL
3967-
struct Program::Impl : public DummyImpl {};
3968-
#endif // HAVE_OPENCL
3969-
39703919

39713920
Program::Program() { p = 0; }
39723921

@@ -4009,26 +3958,18 @@ bool Program::create(const ProgramSource& src,
40093958
p->release();
40103959
p = NULL;
40113960
}
4012-
#ifdef HAVE_OPENCL
40133961
p = new Impl(src, buildflags, errmsg);
40143962
if(!p->handle)
40153963
{
40163964
p->release();
40173965
p = 0;
40183966
}
40193967
return p != 0;
4020-
#else
4021-
CV_OPENCL_NO_SUPPORT();
4022-
#endif
40233968
}
40243969

40253970
void* Program::ptr() const
40263971
{
4027-
#ifdef HAVE_OPENCL
40283972
return p ? p->handle : 0;
4029-
#else
4030-
CV_OPENCL_NO_SUPPORT();
4031-
#endif
40323973
}
40333974

40343975
#ifndef OPENCV_REMOVE_DEPRECATED_API
@@ -4051,44 +3992,30 @@ bool Program::write(String& bin) const
40513992

40523993
String Program::getPrefix() const
40533994
{
4054-
#ifdef HAVE_OPENCL
40553995
if(!p)
40563996
return String();
40573997
Context::Impl* ctx_ = Context::getDefault().getImpl();
40583998
CV_Assert(ctx_);
40593999
return cv::format("opencl=%s\nbuildflags=%s", ctx_->getPrefixString().c_str(), p->buildflags.c_str());
4060-
#else
4061-
CV_OPENCL_NO_SUPPORT();
4062-
#endif
40634000
}
40644001

40654002
String Program::getPrefix(const String& buildflags)
40664003
{
4067-
#ifdef HAVE_OPENCL
40684004
Context::Impl* ctx_ = Context::getDefault().getImpl();
40694005
CV_Assert(ctx_);
40704006
return cv::format("opencl=%s\nbuildflags=%s", ctx_->getPrefixString().c_str(), buildflags.c_str());
4071-
#else
4072-
CV_OPENCL_NO_SUPPORT();
4073-
#endif
40744007
}
4075-
#endif
4008+
#endif // OPENCV_REMOVE_DEPRECATED_API
40764009

40774010
void Program::getBinary(std::vector<char>& binary) const
40784011
{
4079-
#ifdef HAVE_OPENCL
40804012
CV_Assert(p && "Empty program");
40814013
p->getProgramBinary(binary);
4082-
#else
4083-
binary.clear();
4084-
CV_OPENCL_NO_SUPPORT();
4085-
#endif
40864014
}
40874015

40884016
Program Context::Impl::getProg(const ProgramSource& src,
40894017
const String& buildflags, String& errmsg)
40904018
{
4091-
#ifdef HAVE_OPENCL
40924019
size_t limit = getProgramCountLimit();
40934020
const ProgramSource::Impl* src_ = src.getImpl();
40944021
CV_Assert(src_);
@@ -4140,9 +4067,6 @@ Program Context::Impl::getProg(const ProgramSource& src,
41404067
cacheList.push_front(key);
41414068
}
41424069
return prog;
4143-
#else
4144-
CV_OPENCL_NO_SUPPORT();
4145-
#endif
41464070
}
41474071

41484072

@@ -4703,9 +4627,6 @@ class OpenCLAllocator CV_FINAL : public MatAllocator
47034627

47044628
bool allocate(UMatData* u, AccessFlag accessFlags, UMatUsageFlags usageFlags) const CV_OVERRIDE
47054629
{
4706-
#ifndef HAVE_OPENCL
4707-
return false;
4708-
#else
47094630
if(!u)
47104631
return false;
47114632

@@ -4825,7 +4746,6 @@ class OpenCLAllocator CV_FINAL : public MatAllocator
48254746
u->markHostCopyObsolete(true);
48264747
opencl_allocator_stats.onAllocate(u->size);
48274748
return true;
4828-
#endif // HAVE_OPENCL
48294749
}
48304750

48314751
/*void sync(UMatData* u) const
@@ -6705,27 +6625,19 @@ struct Timer::Impl
67056625

67066626
void start()
67076627
{
6708-
#ifdef HAVE_OPENCL
67096628
CV_OCL_DBG_CHECK(clFinish((cl_command_queue)queue.ptr()));
67106629
timer.start();
6711-
#endif
67126630
}
67136631

67146632
void stop()
67156633
{
6716-
#ifdef HAVE_OPENCL
67176634
CV_OCL_DBG_CHECK(clFinish((cl_command_queue)queue.ptr()));
67186635
timer.stop();
6719-
#endif
67206636
}
67216637

67226638
uint64 durationNS() const
67236639
{
6724-
#ifdef HAVE_OPENCL
67256640
return (uint64)(timer.getTimeSec() * 1e9);
6726-
#else
6727-
return 0;
6728-
#endif
67296641
}
67306642

67316643
TickMeter timer;
@@ -6752,13 +6664,6 @@ uint64 Timer::durationNS() const
67526664
return p->durationNS();
67536665
}
67546666

6755-
#ifndef HAVE_OPENCL
6756-
#if defined(_MSC_VER)
6757-
#pragma warning(pop)
6758-
#elif defined(__clang__)
6759-
#pragma clang diagnostic pop
6760-
#elif defined(__GNUC__)
6761-
#pragma GCC diagnostic pop
6762-
#endif
6763-
#endif
67646667
}} // namespace
6668+
6669+
#endif // HAVE_OPENCL

0 commit comments

Comments
 (0)