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
e02418e9
Commit
e02418e9
authored
Dec 30, 2014
by
Alexander Smorkalov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
parallel_do replaced by parallel_for_ in gpu/multi.cpp sample to get rid of cvconfig.h
parent
840088e0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
32 additions
and
54 deletions
+32
-54
brox_optical_flow.cpp
samples/gpu/brox_optical_flow.cpp
+0
-1
multi.cpp
samples/gpu/multi.cpp
+32
-52
pyrlk_optical_flow.cpp
samples/gpu/pyrlk_optical_flow.cpp
+0
-1
No files found.
samples/gpu/brox_optical_flow.cpp
View file @
e02418e9
...
...
@@ -3,7 +3,6 @@
#include <string>
#include <ctype.h>
#include "cvconfig.h"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
...
...
samples/gpu/multi.cpp
View file @
e02418e9
...
...
@@ -7,34 +7,47 @@
#endif
#include <iostream>
#include "cvconfig.h"
#include "opencv2/core/core.hpp"
#include "opencv2/gpu/gpu.hpp"
#if !defined(HAVE_CUDA) || !defined(HAVE_TBB)
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
gpu
;
int
main
()
struct
Worker
:
public
ParallelLoopBody
{
#if !defined(HAVE_CUDA)
std
::
cout
<<
"CUDA support is required (CMake key 'WITH_CUDA' must be true).
\n
"
;
#endif
virtual
void
operator
()
(
const
Range
&
range
)
const
{
for
(
int
device_id
=
range
.
start
;
device_id
!=
range
.
end
;
++
device_id
)
{
setDevice
(
device_id
);
#if !defined(HAVE_TBB)
std
::
cout
<<
"TBB support is required (CMake key 'WITH_TBB' must be true).
\n
"
;
#endif
Mat
src
(
1000
,
1000
,
CV_32F
);
Mat
dst
;
return
0
;
}
RNG
rng
(
0
)
;
rng
.
fill
(
src
,
RNG
::
UNIFORM
,
0
,
1
);
#else
// CPU works
transpose
(
src
,
dst
);
#include "opencv2/core/internal.hpp" // For TBB wrappers
// GPU works
GpuMat
d_src
(
src
);
GpuMat
d_dst
;
transpose
(
d_src
,
d_dst
);
using
namespace
std
;
using
namespace
cv
;
using
namespace
cv
::
gpu
;
// Check results
bool
passed
=
norm
(
dst
-
Mat
(
d_dst
),
NORM_INF
)
<
1e-3
;
std
::
cout
<<
"GPU #"
<<
device_id
<<
" ("
<<
DeviceInfo
().
name
()
<<
"): "
<<
(
passed
?
"passed"
:
"FAILED"
)
<<
endl
;
struct
Worker
{
void
operator
()(
int
device_id
)
const
;
};
// Deallocate data here, otherwise deallocation will be performed
// after context is extracted from the stack
d_src
.
release
();
d_dst
.
release
();
}
}
};
int
main
()
{
...
...
@@ -58,41 +71,8 @@ int main()
}
}
// Execute calculation in two threads using two GPUs
int
devices
[]
=
{
0
,
1
};
parallel_do
(
devices
,
devices
+
2
,
Worker
());
// Execute calculation in several threads, 1 GPU per thread
parallel_for_
(
cv
::
Range
(
0
,
num_devices
,
Worker
());
return
0
;
}
void
Worker
::
operator
()(
int
device_id
)
const
{
setDevice
(
device_id
);
Mat
src
(
1000
,
1000
,
CV_32F
);
Mat
dst
;
RNG
rng
(
0
);
rng
.
fill
(
src
,
RNG
::
UNIFORM
,
0
,
1
);
// CPU works
transpose
(
src
,
dst
);
// GPU works
GpuMat
d_src
(
src
);
GpuMat
d_dst
;
transpose
(
d_src
,
d_dst
);
// Check results
bool
passed
=
norm
(
dst
-
Mat
(
d_dst
),
NORM_INF
)
<
1e-3
;
std
::
cout
<<
"GPU #"
<<
device_id
<<
" ("
<<
DeviceInfo
().
name
()
<<
"): "
<<
(
passed
?
"passed"
:
"FAILED"
)
<<
endl
;
// Deallocate data here, otherwise deallocation will be performed
// after context is extracted from the stack
d_src
.
release
();
d_dst
.
release
();
}
#endif
samples/gpu/pyrlk_optical_flow.cpp
View file @
e02418e9
#include <iostream>
#include <vector>
#include "cvconfig.h"
#include "opencv2/core/core.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
...
...
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