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
8adebcbc
Commit
8adebcbc
authored
Nov 05, 2013
by
peng xiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ocl retina sample.
parent
03bbee32
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
1 deletion
+125
-1
CMakeLists.txt
samples/ocl/CMakeLists.txt
+1
-1
retina_ocl.cpp
samples/ocl/retina_ocl.cpp
+124
-0
No files found.
samples/ocl/CMakeLists.txt
View file @
8adebcbc
SET
(
OPENCV_OCL_SAMPLES_REQUIRED_DEPS opencv_core opencv_flann opencv_imgproc opencv_highgui
opencv_ml opencv_video opencv_objdetect opencv_features2d
opencv_calib3d opencv_legacy opencv_contrib opencv_ocl
opencv_nonfree
)
opencv_nonfree
opencv_bioinspired
)
ocv_check_dependencies
(
${
OPENCV_OCL_SAMPLES_REQUIRED_DEPS
}
)
...
...
samples/ocl/retina_ocl.cpp
0 → 100644
View file @
8adebcbc
#include <iostream>
#include <cstring>
#include "opencv2/core.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/ocl.hpp"
#include "opencv2/bioinspired.hpp"
using
namespace
cv
;
using
namespace
cv
::
ocl
;
using
namespace
std
;
const
int
total_loop_count
=
50
;
static
void
help
(
CommandLineParser
cmd
,
const
String
&
errorMessage
)
{
cout
<<
errorMessage
<<
endl
;
cout
<<
"Avaible options:"
<<
endl
;
cmd
.
printMessage
();
}
int
main
(
int
argc
,
char
*
argv
[])
{
//set this to save kernel compile time from second time you run
ocl
::
setBinaryDiskCache
();
const
char
*
keys
=
"{ h | help | false | print help message }"
"{ c | use_cpp | false | use cpp (original version) or gpu(OpenCL) to process the image }"
"{ i | image | cat.jpg | specify the input image }"
;
CommandLineParser
cmd
(
argc
,
argv
,
keys
);
if
(
cmd
.
get
<
bool
>
(
"help"
))
{
help
(
cmd
,
"Usage: ./retina_ocl [options]"
);
return
EXIT_FAILURE
;
}
String
fname
=
cmd
.
get
<
String
>
(
"i"
);
bool
useCPP
=
cmd
.
get
<
bool
>
(
"c"
);
cv
::
Mat
input
=
imread
(
fname
);
if
(
input
.
empty
())
{
help
(
cmd
,
fname
+
" not found!"
);
return
EXIT_FAILURE
;
}
//////////////////////////////////////////////////////////////////////////////
// Program start in a try/catch safety context (Retina may throw errors)
try
{
// create a retina instance with default parameters setup, uncomment the initialisation you wanna test
cv
::
Ptr
<
cv
::
bioinspired
::
Retina
>
oclRetina
;
cv
::
Ptr
<
cv
::
bioinspired
::
Retina
>
retina
;
// declare retina output buffers
cv
::
ocl
::
oclMat
retina_parvo_ocl
;
cv
::
ocl
::
oclMat
retina_magno_ocl
;
cv
::
Mat
retina_parvo
;
cv
::
Mat
retina_magno
;
if
(
useCPP
)
{
retina
=
cv
::
bioinspired
::
createRetina
(
input
.
size
());
retina
->
clearBuffers
();
}
else
{
oclRetina
=
cv
::
bioinspired
::
createRetina_OCL
(
input
.
size
());
oclRetina
->
clearBuffers
();
}
int64
temp_time
=
0
,
total_time
=
0
;
int
loop_counter
=
0
;
static
bool
initialized
=
false
;
for
(;
loop_counter
<=
total_loop_count
;
++
loop_counter
)
{
if
(
useCPP
)
{
temp_time
=
cv
::
getTickCount
();
retina
->
run
(
input
);
retina
->
getParvo
(
retina_parvo
);
retina
->
getMagno
(
retina_magno
);
}
else
{
cv
::
ocl
::
oclMat
input_ocl
(
input
);
temp_time
=
cv
::
getTickCount
();
oclRetina
->
run
(
input_ocl
);
oclRetina
->
getParvo
(
retina_parvo_ocl
);
oclRetina
->
getMagno
(
retina_magno_ocl
);
}
// will not count the first loop, which is considered as warm-up period
if
(
initialized
)
{
temp_time
=
(
cv
::
getTickCount
()
-
temp_time
);
total_time
+=
temp_time
;
printf
(
"Frame id %2d: %3.4fms
\n
"
,
loop_counter
,
(
double
)
temp_time
/
cv
::
getTickFrequency
()
*
1000.0
);
}
else
{
initialized
=
true
;
}
if
(
!
useCPP
)
{
retina_parvo
=
retina_parvo_ocl
;
retina_magno
=
retina_magno_ocl
;
}
cv
::
imshow
(
"retina input"
,
input
);
cv
::
imshow
(
"Retina Parvo"
,
retina_parvo
);
cv
::
imshow
(
"Retina Magno"
,
retina_magno
);
cv
::
waitKey
(
10
);
}
printf
(
"Average: %.4fms
\n
"
,
(
double
)
total_time
/
total_loop_count
/
cv
::
getTickFrequency
()
*
1000.0
);
}
catch
(
cv
::
Exception
e
)
{
std
::
cerr
<<
"Error using Retina : "
<<
e
.
what
()
<<
std
::
endl
;
}
// Program end message
std
::
cout
<<
"Retina demo end"
<<
std
::
endl
;
return
EXIT_SUCCESS
;
}
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