From 7a2a810de52905ca9b0b84a91a91ad6cd0f7512a Mon Sep 17 00:00:00 2001 From: Peng Xiao Date: Wed, 6 Nov 2013 17:00:27 +0800 Subject: [PATCH] Update retina_ocl.cpp --- samples/ocl/retina_ocl.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/samples/ocl/retina_ocl.cpp b/samples/ocl/retina_ocl.cpp index bd364855e8..6c58f73254 100644 --- a/samples/ocl/retina_ocl.cpp +++ b/samples/ocl/retina_ocl.cpp @@ -26,7 +26,7 @@ int main(int argc, char* argv[]) 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 }" + "{ c | cpu | false | use cpu (original version) or gpu(OpenCL) to process the image }" "{ i | image | cat.jpg | specify the input image }"; CommandLineParser cmd(argc, argv, keys); @@ -38,12 +38,12 @@ int main(int argc, char* argv[]) } String fname = cmd.get("i"); - bool useCPP = cmd.get("c"); + bool useCPU = cmd.get("c"); cv::Mat input = imread(fname); if(input.empty()) { - help(cmd, fname + " not found!"); + help(cmd, "Error opening: " + fname); return EXIT_FAILURE; } ////////////////////////////////////////////////////////////////////////////// @@ -59,7 +59,7 @@ int main(int argc, char* argv[]) cv::Mat retina_parvo; cv::Mat retina_magno; - if(useCPP) + if(useCPU) { retina = cv::bioinspired::createRetina(input.size()); retina->clearBuffers(); @@ -73,10 +73,9 @@ int main(int argc, char* argv[]) 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) + if(useCPU) { temp_time = cv::getTickCount(); retina->run(input); @@ -92,17 +91,13 @@ int main(int argc, char* argv[]) oclRetina->getMagno(retina_magno_ocl); } // 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); 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) + if(!useCPU) { retina_parvo = retina_parvo_ocl; retina_magno = retina_magno_ocl;