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
51eba617
Commit
51eba617
authored
Feb 01, 2013
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
a part of PR269 (parallelization of several functions) by Alexander Mordvintsev
parent
b179e2dd
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
14 deletions
+14
-14
matrix.cpp
modules/core/src/matrix.cpp
+10
-10
stat.cpp
modules/core/src/stat.cpp
+4
-4
No files found.
modules/core/src/matrix.cpp
View file @
51eba617
...
...
@@ -2459,7 +2459,7 @@ static void generateRandomCenter(const vector<Vec2f>& box, float* center, RNG& r
center
[
j
]
=
((
float
)
rng
*
(
1.
f
+
margin
*
2.
f
)
-
margin
)
*
(
box
[
j
][
1
]
-
box
[
j
][
0
])
+
box
[
j
][
0
];
}
class
KMeansPPDistanceComputer
class
KMeansPPDistanceComputer
:
public
ParallelLoopBody
{
public
:
KMeansPPDistanceComputer
(
float
*
_tdist2
,
...
...
@@ -2475,10 +2475,10 @@ public:
step
(
_step
),
stepci
(
_stepci
)
{
}
void
operator
()(
const
cv
::
Blocked
Range
&
range
)
const
void
operator
()(
const
cv
::
Range
&
range
)
const
{
const
int
begin
=
range
.
begin
()
;
const
int
end
=
range
.
end
()
;
const
int
begin
=
range
.
start
;
const
int
end
=
range
.
end
;
for
(
int
i
=
begin
;
i
<
end
;
i
++
)
{
...
...
@@ -2534,7 +2534,7 @@ static void generateCentersPP(const Mat& _data, Mat& _out_centers,
break
;
int
ci
=
i
;
parallel_for
(
Blocked
Range
(
0
,
N
),
parallel_for
_
(
Range
(
0
,
N
),
KMeansPPDistanceComputer
(
tdist2
,
data
,
dist
,
dims
,
step
,
step
*
ci
));
for
(
i
=
0
;
i
<
N
;
i
++
)
{
...
...
@@ -2562,7 +2562,7 @@ static void generateCentersPP(const Mat& _data, Mat& _out_centers,
}
}
class
KMeansDistanceComputer
class
KMeansDistanceComputer
:
public
ParallelLoopBody
{
public
:
KMeansDistanceComputer
(
double
*
_distances
,
...
...
@@ -2576,10 +2576,10 @@ public:
{
}
void
operator
()(
const
Blocked
Range
&
range
)
const
void
operator
()(
const
Range
&
range
)
const
{
const
int
begin
=
range
.
begin
()
;
const
int
end
=
range
.
end
()
;
const
int
begin
=
range
.
start
;
const
int
end
=
range
.
end
;
const
int
K
=
centers
.
rows
;
const
int
dims
=
centers
.
cols
;
...
...
@@ -2836,7 +2836,7 @@ double cv::kmeans( InputArray _data, int K,
// assign labels
Mat
dists
(
1
,
N
,
CV_64F
);
double
*
dist
=
dists
.
ptr
<
double
>
(
0
);
parallel_for
(
Blocked
Range
(
0
,
N
),
parallel_for
_
(
Range
(
0
,
N
),
KMeansDistanceComputer
(
dist
,
labels
,
data
,
centers
));
compactness
=
0
;
for
(
i
=
0
;
i
<
N
;
i
++
)
...
...
modules/core/src/stat.cpp
View file @
51eba617
...
...
@@ -1726,7 +1726,7 @@ typedef void (*BatchDistFunc)(const uchar* src1, const uchar* src2, size_t step2
int
nvecs
,
int
len
,
uchar
*
dist
,
const
uchar
*
mask
);
struct
BatchDistInvoker
struct
BatchDistInvoker
:
public
ParallelLoopBody
{
BatchDistInvoker
(
const
Mat
&
_src1
,
const
Mat
&
_src2
,
Mat
&
_dist
,
Mat
&
_nidx
,
int
_K
,
...
...
@@ -1743,12 +1743,12 @@ struct BatchDistInvoker
func
=
_func
;
}
void
operator
()(
const
Blocked
Range
&
range
)
const
void
operator
()(
const
Range
&
range
)
const
{
AutoBuffer
<
int
>
buf
(
src2
->
rows
);
int
*
bufptr
=
buf
;
for
(
int
i
=
range
.
begin
();
i
<
range
.
end
()
;
i
++
)
for
(
int
i
=
range
.
start
;
i
<
range
.
end
;
i
++
)
{
func
(
src1
->
ptr
(
i
),
src2
->
ptr
(),
src2
->
step
,
src2
->
rows
,
src2
->
cols
,
K
>
0
?
(
uchar
*
)
bufptr
:
dist
->
ptr
(
i
),
mask
->
data
?
mask
->
ptr
(
i
)
:
0
);
...
...
@@ -1899,7 +1899,7 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
(
"The combination of type=%d, dtype=%d and normType=%d is not supported"
,
type
,
dtype
,
normType
));
parallel_for
(
Blocked
Range
(
0
,
src1
.
rows
),
parallel_for
_
(
Range
(
0
,
src1
.
rows
),
BatchDistInvoker
(
src1
,
src2
,
dist
,
nidx
,
K
,
mask
,
update
,
func
));
}
...
...
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