Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
b88609a9
Commit
b88609a9
authored
Apr 06, 2018
by
Maksim Shabunin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reduced direct TBB dependencies
parent
875b4e21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
4 additions
and
207 deletions
+4
-207
boost.cpp
apps/traincascade/boost.cpp
+0
-36
OpenCVDetectTBB.cmake
cmake/OpenCVDetectTBB.cmake
+0
-4
CMakeLists.txt
modules/core/CMakeLists.txt
+4
-0
private.hpp
modules/core/include/opencv2/core/private.hpp
+0
-28
histogram.cpp
modules/imgproc/src/histogram.cpp
+0
-0
cap_openni.cpp
modules/videoio/src/cap_openni.cpp
+0
-135
cap_openni2.cpp
modules/videoio/src/cap_openni2.cpp
+0
-4
No files found.
apps/traincascade/boost.cpp
View file @
b88609a9
...
...
@@ -34,42 +34,6 @@ using cv::ParallelLoopBody;
#include "cvconfig.h"
#ifdef HAVE_TBB
# include "tbb/tbb.h"
# include "tbb/task.h"
# undef min
# undef max
#endif
#ifdef HAVE_TBB
typedef
tbb
::
blocked_range
<
int
>
BlockedRange
;
template
<
typename
Body
>
static
inline
void
parallel_for
(
const
BlockedRange
&
range
,
const
Body
&
body
)
{
tbb
::
parallel_for
(
range
,
body
);
}
#else
class
BlockedRange
{
public
:
BlockedRange
()
:
_begin
(
0
),
_end
(
0
),
_grainsize
(
0
)
{}
BlockedRange
(
int
b
,
int
e
,
int
g
=
1
)
:
_begin
(
b
),
_end
(
e
),
_grainsize
(
g
)
{}
int
begin
()
const
{
return
_begin
;
}
int
end
()
const
{
return
_end
;
}
int
grainsize
()
const
{
return
_grainsize
;
}
protected
:
int
_begin
,
_end
,
_grainsize
;
};
template
<
typename
Body
>
static
inline
void
parallel_for
(
const
BlockedRange
&
range
,
const
Body
&
body
)
{
body
(
range
);
}
#endif
using
namespace
std
;
static
inline
double
...
...
cmake/OpenCVDetectTBB.cmake
View file @
b88609a9
...
...
@@ -107,7 +107,3 @@ endif()
if
(
TBB_INTERFACE_VERSION LESS 6000
)
# drop support of versions < 4.0
set
(
HAVE_TBB FALSE
)
endif
()
if
(
HAVE_TBB
)
list
(
APPEND OPENCV_LINKER_LIBS tbb
)
endif
()
modules/core/CMakeLists.txt
View file @
b88609a9
...
...
@@ -13,6 +13,10 @@ if(WINRT AND CMAKE_SYSTEM_NAME MATCHES WindowsStore AND CMAKE_SYSTEM_VERSION MAT
list
(
APPEND extra_libs ole32.lib
)
endif
()
if
(
HAVE_TBB
)
list
(
APPEND extra_libs tbb
)
endif
()
if
(
DEFINED WINRT AND NOT DEFINED ENABLE_WINRT_MODE_NATIVE
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/ZW"
)
endif
()
...
...
modules/core/include/opencv2/core/private.hpp
View file @
b88609a9
...
...
@@ -61,37 +61,10 @@
# include "opencv2/core/eigen.hpp"
#endif
#ifdef HAVE_TBB
# include "tbb/tbb.h"
# include "tbb/task.h"
# undef min
# undef max
#endif
//! @cond IGNORED
namespace
cv
{
#ifdef HAVE_TBB
typedef
tbb
::
blocked_range
<
int
>
BlockedRange
;
template
<
typename
Body
>
static
inline
void
parallel_for
(
const
BlockedRange
&
range
,
const
Body
&
body
)
{
tbb
::
parallel_for
(
range
,
body
);
}
typedef
tbb
::
split
Split
;
template
<
typename
Body
>
static
inline
void
parallel_reduce
(
const
BlockedRange
&
range
,
Body
&
body
)
{
tbb
::
parallel_reduce
(
range
,
body
);
}
typedef
tbb
::
concurrent_vector
<
Rect
>
ConcurrentRectVector
;
#else
class
BlockedRange
{
public
:
...
...
@@ -119,7 +92,6 @@ namespace cv
{
body
(
range
);
}
#endif
// Returns a static string if there is a parallel framework,
// NULL otherwise.
...
...
modules/imgproc/src/histogram.cpp
View file @
b88609a9
This diff is collapsed.
Click to expand it.
modules/videoio/src/cap_openni.cpp
View file @
b88609a9
...
...
@@ -101,9 +101,6 @@ public:
context
(
_context
),
depthGenerator
(
_depthGenerator
),
imageGenerator
(
_imageGenerator
),
maxBufferSize
(
_maxBufferSize
),
isCircleBuffer
(
_isCircleBuffer
),
maxTimeDuration
(
_maxTimeDuration
)
{
#ifdef HAVE_TBB
task
=
0
;
#endif
CV_Assert
(
depthGenerator
.
IsValid
()
);
CV_Assert
(
imageGenerator
.
IsValid
()
);
...
...
@@ -112,9 +109,6 @@ public:
void
setMaxBufferSize
(
int
_maxBufferSize
)
{
maxBufferSize
=
_maxBufferSize
;
#ifdef HAVE_TBB
task
->
setMaxBufferSize
();
#endif
}
inline
int
getMaxBufferSize
()
const
{
return
maxBufferSize
;
}
...
...
@@ -132,9 +126,7 @@ public:
while
(
task
->
grab
(
depthMetaData
,
imageMetaData
)
==
false
)
{
#ifndef HAVE_TBB
task
->
spin
();
#endif
}
return
true
;
...
...
@@ -144,22 +136,12 @@ public:
{
CV_Assert
(
depthGenerator
.
IsValid
()
);
CV_Assert
(
imageGenerator
.
IsValid
()
);
#ifdef HAVE_TBB
task
=
new
(
tbb
::
task
::
allocate_root
()
)
TBBApproximateSynchronizerTask
(
*
this
);
tbb
::
task
::
enqueue
(
*
task
);
#else
task
.
reset
(
new
ApproximateSynchronizer
(
*
this
)
);
#endif
}
void
finish
()
{
#ifdef HAVE_TBB
if
(
task
)
tbb
::
task
::
destroy
(
*
task
);
#else
task
.
release
();
#endif
}
bool
isRun
()
const
{
return
task
!=
0
;
}
...
...
@@ -305,120 +287,7 @@ private:
std
::
queue
<
cv
::
Ptr
<
xn
::
ImageMetaData
>
>
imageQueue
;
};
#ifdef HAVE_TBB
// If there is TBB the synchronization will be executed in own thread.
class
TBBApproximateSynchronizer
:
public
ApproximateSynchronizerBase
{
public
:
TBBApproximateSynchronizer
(
ApproximateSyncGrabber
&
_approxSyncGrabber
)
:
ApproximateSynchronizerBase
(
_approxSyncGrabber
)
{
setMaxBufferSize
();
}
void
setMaxBufferSize
()
{
int
maxBufferSize
=
approxSyncGrabber
.
getMaxBufferSize
();
if
(
maxBufferSize
>=
0
)
{
depthQueue
.
set_capacity
(
maxBufferSize
);
imageQueue
.
set_capacity
(
maxBufferSize
);
}
}
virtual
inline
bool
isSpinContinue
()
const
{
return
true
;
}
virtual
inline
void
pushDepthMetaData
(
xn
::
DepthMetaData
&
depthMetaData
)
{
cv
::
Ptr
<
xn
::
DepthMetaData
>
depthPtr
=
cv
::
makePtr
<
xn
::
DepthMetaData
>
(),
tmp
;
depthPtr
->
CopyFrom
(
depthMetaData
);
tbb
::
mutex
mtx
;
mtx
.
lock
();
if
(
depthQueue
.
try_push
(
depthPtr
)
==
false
)
{
if
(
approxSyncGrabber
.
getIsCircleBuffer
()
)
{
CV_Assert
(
depthQueue
.
try_pop
(
tmp
)
);
CV_Assert
(
depthQueue
.
try_push
(
depthPtr
)
);
}
}
mtx
.
unlock
();
}
virtual
inline
void
pushImageMetaData
(
xn
::
ImageMetaData
&
imageMetaData
)
{
cv
::
Ptr
<
xn
::
ImageMetaData
>
imagePtr
=
cv
::
makePtr
<
xn
::
ImageMetaData
>
(),
tmp
;
imagePtr
->
CopyFrom
(
imageMetaData
);
tbb
::
mutex
mtx
;
mtx
.
lock
();
if
(
imageQueue
.
try_push
(
imagePtr
)
==
false
)
{
if
(
approxSyncGrabber
.
getIsCircleBuffer
()
)
{
CV_Assert
(
imageQueue
.
try_pop
(
tmp
)
);
CV_Assert
(
imageQueue
.
try_push
(
imagePtr
)
);
}
}
mtx
.
unlock
();
}
virtual
inline
bool
popDepthMetaData
(
xn
::
DepthMetaData
&
depthMetaData
)
{
cv
::
Ptr
<
xn
::
DepthMetaData
>
depthPtr
;
bool
isPop
=
depthQueue
.
try_pop
(
depthPtr
);
if
(
isPop
)
depthMetaData
.
CopyFrom
(
*
depthPtr
);
return
isPop
;
}
virtual
inline
bool
popImageMetaData
(
xn
::
ImageMetaData
&
imageMetaData
)
{
cv
::
Ptr
<
xn
::
ImageMetaData
>
imagePtr
;
bool
isPop
=
imageQueue
.
try_pop
(
imagePtr
);
if
(
isPop
)
imageMetaData
.
CopyFrom
(
*
imagePtr
);
return
isPop
;
}
private
:
tbb
::
concurrent_bounded_queue
<
cv
::
Ptr
<
xn
::
DepthMetaData
>
>
depthQueue
;
tbb
::
concurrent_bounded_queue
<
cv
::
Ptr
<
xn
::
ImageMetaData
>
>
imageQueue
;
};
class
TBBApproximateSynchronizerTask
:
public
tbb
::
task
{
public
:
TBBApproximateSynchronizerTask
(
ApproximateSyncGrabber
&
approxSyncGrabber
)
:
synchronizer
(
approxSyncGrabber
)
{}
void
setMaxBufferSize
()
{
synchronizer
.
setMaxBufferSize
();
}
bool
grab
(
xn
::
DepthMetaData
&
depthMetaData
,
xn
::
ImageMetaData
&
imageMetaData
)
{
return
synchronizer
.
grab
(
depthMetaData
,
imageMetaData
);
}
private
:
tbb
::
task
*
execute
()
{
synchronizer
.
spin
();
return
0
;
}
TBBApproximateSynchronizer
synchronizer
;
};
#endif // HAVE_TBB
#ifdef HAVE_TBB
TBBApproximateSynchronizerTask
*
task
;
#else
cv
::
Ptr
<
ApproximateSynchronizer
>
task
;
#endif
};
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
...
...
@@ -430,11 +299,7 @@ public:
static
const
int
INVALID_PIXEL_VAL
=
0
;
static
const
int
INVALID_COORDINATE_VAL
=
0
;
#ifdef HAVE_TBB
static
const
int
DEFAULT_MAX_BUFFER_SIZE
=
8
;
#else
static
const
int
DEFAULT_MAX_BUFFER_SIZE
=
2
;
#endif
static
const
int
DEFAULT_IS_CIRCLE_BUFFER
=
0
;
static
const
int
DEFAULT_MAX_TIME_DURATION
=
20
;
...
...
modules/videoio/src/cap_openni2.cpp
View file @
b88609a9
...
...
@@ -78,11 +78,7 @@ public:
static
const
int
INVALID_PIXEL_VAL
=
0
;
static
const
int
INVALID_COORDINATE_VAL
=
0
;
#ifdef HAVE_TBB
static
const
int
DEFAULT_MAX_BUFFER_SIZE
=
8
;
#else
static
const
int
DEFAULT_MAX_BUFFER_SIZE
=
2
;
#endif
static
const
int
DEFAULT_IS_CIRCLE_BUFFER
=
0
;
static
const
int
DEFAULT_MAX_TIME_DURATION
=
20
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment