Update retina_ocl.cpp
This commit is contained in:
parent
8adebcbc00
commit
7a2a810de5
@ -26,7 +26,7 @@ int main(int argc, char* argv[])
|
|||||||
ocl::setBinaryDiskCache();
|
ocl::setBinaryDiskCache();
|
||||||
const char* keys =
|
const char* keys =
|
||||||
"{ h | help | false | print help message }"
|
"{ h | help | false | print help message }"
|
||||||
"{ c | use_cpp | false | use cpp (original version) or gpu(OpenCL) to process the image }"
|
"{ c | cpu | false | use cpu (original version) or gpu(OpenCL) to process the image }"
|
||||||
"{ i | image | cat.jpg | specify the input image }";
|
"{ i | image | cat.jpg | specify the input image }";
|
||||||
|
|
||||||
CommandLineParser cmd(argc, argv, keys);
|
CommandLineParser cmd(argc, argv, keys);
|
||||||
@ -38,12 +38,12 @@ int main(int argc, char* argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
String fname = cmd.get<String>("i");
|
String fname = cmd.get<String>("i");
|
||||||
bool useCPP = cmd.get<bool>("c");
|
bool useCPU = cmd.get<bool>("c");
|
||||||
|
|
||||||
cv::Mat input = imread(fname);
|
cv::Mat input = imread(fname);
|
||||||
if(input.empty())
|
if(input.empty())
|
||||||
{
|
{
|
||||||
help(cmd, fname + " not found!");
|
help(cmd, "Error opening: " + fname);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -59,7 +59,7 @@ int main(int argc, char* argv[])
|
|||||||
cv::Mat retina_parvo;
|
cv::Mat retina_parvo;
|
||||||
cv::Mat retina_magno;
|
cv::Mat retina_magno;
|
||||||
|
|
||||||
if(useCPP)
|
if(useCPU)
|
||||||
{
|
{
|
||||||
retina = cv::bioinspired::createRetina(input.size());
|
retina = cv::bioinspired::createRetina(input.size());
|
||||||
retina->clearBuffers();
|
retina->clearBuffers();
|
||||||
@ -73,10 +73,9 @@ int main(int argc, char* argv[])
|
|||||||
int64 temp_time = 0, total_time = 0;
|
int64 temp_time = 0, total_time = 0;
|
||||||
|
|
||||||
int loop_counter = 0;
|
int loop_counter = 0;
|
||||||
static bool initialized = false;
|
|
||||||
for(; loop_counter <= total_loop_count; ++loop_counter)
|
for(; loop_counter <= total_loop_count; ++loop_counter)
|
||||||
{
|
{
|
||||||
if(useCPP)
|
if(useCPU)
|
||||||
{
|
{
|
||||||
temp_time = cv::getTickCount();
|
temp_time = cv::getTickCount();
|
||||||
retina->run(input);
|
retina->run(input);
|
||||||
@ -92,17 +91,13 @@ int main(int argc, char* argv[])
|
|||||||
oclRetina->getMagno(retina_magno_ocl);
|
oclRetina->getMagno(retina_magno_ocl);
|
||||||
}
|
}
|
||||||
// will not count the first loop, which is considered as warm-up period
|
// will not count the first loop, which is considered as warm-up period
|
||||||
if(initialized)
|
if(loop_counter > 0)
|
||||||
{
|
{
|
||||||
temp_time = (cv::getTickCount() - temp_time);
|
temp_time = (cv::getTickCount() - temp_time);
|
||||||
total_time += temp_time;
|
total_time += temp_time;
|
||||||
printf("Frame id %2d: %3.4fms\n", loop_counter, (double)temp_time / cv::getTickFrequency() * 1000.0);
|
printf("Frame id %2d: %3.4fms\n", loop_counter, (double)temp_time / cv::getTickFrequency() * 1000.0);
|
||||||
}
|
}
|
||||||
else
|
if(!useCPU)
|
||||||
{
|
|
||||||
initialized = true;
|
|
||||||
}
|
|
||||||
if(!useCPP)
|
|
||||||
{
|
{
|
||||||
retina_parvo = retina_parvo_ocl;
|
retina_parvo = retina_parvo_ocl;
|
||||||
retina_magno = retina_magno_ocl;
|
retina_magno = retina_magno_ocl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user