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
3b15f3e3
Commit
3b15f3e3
authored
Mar 29, 2018
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid calling of setNumThreads() to respect user settings
parent
265f335d
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
19 deletions
+15
-19
perf_stereosgbm.cpp
modules/calib3d/perf/perf_stereosgbm.cpp
+0
-1
test_solvepnp_ransac.cpp
modules/calib3d/test/test_solvepnp_ransac.cpp
+2
-0
connectedcomponents.cpp
modules/imgproc/src/connectedcomponents.cpp
+13
-18
No files found.
modules/calib3d/perf/perf_stereosgbm.cpp
View file @
3b15f3e3
...
...
@@ -67,7 +67,6 @@ PERF_TEST_P( TestStereoCorresp, DISABLED_TooLongInDebug_SGBM, Combine(Values(Siz
MakeArtificialExample
(
rng
,
src_left
,
src_right
);
cv
::
setNumThreads
(
cv
::
getNumberOfCPUs
());
int
wsize
=
3
;
int
P1
=
8
*
src_left
.
channels
()
*
wsize
*
wsize
;
TEST_CYCLE
()
...
...
modules/calib3d/test/test_solvepnp_ransac.cpp
View file @
3b15f3e3
...
...
@@ -382,6 +382,7 @@ TEST(Calib3d_SolvePnPRansac, concurrency)
Mat
rvec1
,
rvec2
;
Mat
tvec1
,
tvec2
;
int
threads
=
getNumThreads
();
{
// limit concurrency to get deterministic result
theRNG
().
state
=
20121010
;
...
...
@@ -390,6 +391,7 @@ TEST(Calib3d_SolvePnPRansac, concurrency)
}
{
setNumThreads
(
threads
);
Mat
rvec
;
Mat
tvec
;
// parallel executions
...
...
modules/imgproc/src/connectedcomponents.cpp
View file @
3b15f3e3
...
...
@@ -579,9 +579,6 @@ namespace cv{
CV_Assert
(
img
.
cols
==
imgLabels
.
cols
);
CV_Assert
(
connectivity
==
8
||
connectivity
==
4
);
const
int
nThreads
=
cv
::
getNumberOfCPUs
();
cv
::
setNumThreads
(
nThreads
);
const
int
h
=
img
.
rows
;
const
int
w
=
img
.
cols
;
...
...
@@ -606,12 +603,13 @@ namespace cv{
P
[
0
]
=
0
;
cv
::
Range
range
(
0
,
h
);
const
double
nParallelStripes
=
std
::
max
(
1
,
std
::
min
(
h
/
2
,
getNumThreads
()
*
4
));
LabelT
nLabels
=
1
;
if
(
connectivity
==
8
){
//First scan, each thread works with chunk of img.rows/nThreads rows
//e.g. 300 rows, 4 threads -> each chunks is composed of 75 rows
cv
::
parallel_for_
(
range
,
FirstScan8Connectivity
(
img
,
imgLabels
,
P
,
chunksSizeAndLabels
),
nThreads
);
//First scan
cv
::
parallel_for_
(
range
,
FirstScan8Connectivity
(
img
,
imgLabels
,
P
,
chunksSizeAndLabels
),
nParallelStripes
);
//merge labels of different chunks
mergeLabels8Connectivity
(
imgLabels
,
P
,
chunksSizeAndLabels
);
...
...
@@ -621,9 +619,8 @@ namespace cv{
}
}
else
{
//First scan, each thread works with chunk of img.rows/nThreads rows
//e.g. 300 rows, 4 threads -> each chunks is composed of 75 rows
cv
::
parallel_for_
(
range
,
FirstScan4Connectivity
(
img
,
imgLabels
,
P
,
chunksSizeAndLabels
),
nThreads
);
//First scan
cv
::
parallel_for_
(
range
,
FirstScan4Connectivity
(
img
,
imgLabels
,
P
,
chunksSizeAndLabels
),
nParallelStripes
);
//merge labels of different chunks
mergeLabels4Connectivity
(
imgLabels
,
P
,
chunksSizeAndLabels
);
...
...
@@ -638,7 +635,7 @@ namespace cv{
sop
.
init
(
nLabels
);
//Second scan
cv
::
parallel_for_
(
range
,
SecondScan
(
imgLabels
,
P
,
sop
,
sopArray
,
nLabels
),
n
Thread
s
);
cv
::
parallel_for_
(
range
,
SecondScan
(
imgLabels
,
P
,
sop
,
sopArray
,
nLabels
),
n
ParallelStripe
s
);
StatsOp
::
mergeStats
(
imgLabels
,
sopArray
,
sop
,
nLabels
);
sop
.
finish
();
...
...
@@ -2530,9 +2527,6 @@ namespace cv{
CV_Assert
(
img
.
cols
==
imgLabels
.
cols
);
CV_Assert
(
connectivity
==
8
);
const
int
nThreads
=
cv
::
getNumberOfCPUs
();
cv
::
setNumThreads
(
nThreads
);
const
int
h
=
img
.
rows
;
const
int
w
=
img
.
cols
;
...
...
@@ -2556,10 +2550,11 @@ namespace cv{
P
[
0
]
=
0
;
cv
::
Range
range
(
0
,
h
);
const
double
nParallelStripes
=
std
::
max
(
1
,
std
::
min
(
h
/
2
,
getNumThreads
()
*
4
));
//First scan, each thread works with chunk of img.rows/nThreads rows
//e.g. 300 rows, 4 threads -> each chunks is composed of 75 rows
cv
::
parallel_for_
(
range
,
FirstScan
(
img
,
imgLabels
,
P
,
chunksSizeAndLabels
),
n
Thread
s
);
cv
::
parallel_for_
(
range
,
FirstScan
(
img
,
imgLabels
,
P
,
chunksSizeAndLabels
),
n
ParallelStripe
s
);
//merge labels of different chunks
mergeLabels
(
img
,
imgLabels
,
P
,
chunksSizeAndLabels
);
...
...
@@ -2574,7 +2569,7 @@ namespace cv{
sop
.
init
(
nLabels
);
//Second scan
cv
::
parallel_for_
(
range
,
SecondScan
(
img
,
imgLabels
,
P
,
sop
,
sopArray
,
nLabels
),
n
Thread
s
);
cv
::
parallel_for_
(
range
,
SecondScan
(
img
,
imgLabels
,
P
,
sop
,
sopArray
,
nLabels
),
n
ParallelStripe
s
);
StatsOp
::
mergeStats
(
imgLabels
,
sopArray
,
sop
,
nLabels
);
sop
.
finish
();
...
...
@@ -3936,12 +3931,12 @@ namespace cv{
int
lDepth
=
L
.
depth
();
int
iDepth
=
I
.
depth
();
const
char
*
currentParallelFramework
=
cv
::
currentParallelFramework
();
const
int
n
umberOfCPUs
=
cv
::
getNumberOfCPU
s
();
const
int
n
Threads
=
cv
::
getNumThread
s
();
CV_Assert
(
iDepth
==
CV_8U
||
iDepth
==
CV_8S
);
//Run parallel labeling only if the rows of the image are at least twice the number
returned by getNumberOfCPU
s
const
bool
is_parallel
=
currentParallelFramework
!=
NULL
&&
n
umberOfCPUs
>
1
&&
L
.
rows
/
numberOfCPU
s
>=
2
;
//Run parallel labeling only if the rows of the image are at least twice the number
of available thread
s
const
bool
is_parallel
=
currentParallelFramework
!=
NULL
&&
n
Threads
>
1
&&
L
.
rows
/
nThread
s
>=
2
;
if
(
ccltype
==
CCL_WU
||
connectivity
==
4
){
// Wu algorithm is used
...
...
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