From 69c2ef5ed21255c2e67b143b3adc9500a87a1119 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Thu, 3 Oct 2013 19:35:01 +0400 Subject: [PATCH] ocl: update ocl samples --- samples/gpu/super_resolution.cpp | 8 -------- samples/ocl/adaptive_bilateral_filter.cpp | 5 +---- samples/ocl/bgfg_segm.cpp | 5 +---- samples/ocl/clahe.cpp | 3 --- samples/ocl/facedetect.cpp | 12 +----------- samples/ocl/hog.cpp | 2 -- samples/ocl/pyrlk_optical_flow.cpp | 9 +-------- samples/ocl/squares.cpp | 4 +--- samples/ocl/stereo_match.cpp | 14 ++------------ samples/ocl/surf_matcher.cpp | 12 ++---------- samples/ocl/tvl1_optical_flow.cpp | 9 +-------- 11 files changed, 10 insertions(+), 73 deletions(-) diff --git a/samples/gpu/super_resolution.cpp b/samples/gpu/super_resolution.cpp index 07dda775b..435e711a1 100644 --- a/samples/gpu/super_resolution.cpp +++ b/samples/gpu/super_resolution.cpp @@ -132,17 +132,9 @@ int main(int argc, const char* argv[]) } #endif #if defined(HAVE_OPENCV_OCL) - std::vectorinfo; if(useCuda) { CV_Assert(!useOcl); - info.clear(); - } - - if(useOcl) - { - CV_Assert(!useCuda); - cv::ocl::getDevice(info); } #endif Ptr superRes; diff --git a/samples/ocl/adaptive_bilateral_filter.cpp b/samples/ocl/adaptive_bilateral_filter.cpp index df226b195..d3d2521df 100644 --- a/samples/ocl/adaptive_bilateral_filter.cpp +++ b/samples/ocl/adaptive_bilateral_filter.cpp @@ -25,9 +25,6 @@ int main( int argc, const char** argv ) return -1; } - std::vector infos; - ocl::getDevice(infos); - ocl::oclMat dsrc(src), dABFilter, dBFilter; Size ksize(ks, ks); @@ -48,4 +45,4 @@ int main( int argc, const char** argv ) waitKey(); return 0; -} \ No newline at end of file +} diff --git a/samples/ocl/bgfg_segm.cpp b/samples/ocl/bgfg_segm.cpp index 410f34693..589a34914 100644 --- a/samples/ocl/bgfg_segm.cpp +++ b/samples/ocl/bgfg_segm.cpp @@ -24,7 +24,7 @@ int main(int argc, const char** argv) if (cmd.get("help")) { cout << "Usage : bgfg_segm [options]" << endl; - cout << "Avaible options:" << endl; + cout << "Available options:" << endl; cmd.printParams(); return 0; } @@ -54,9 +54,6 @@ int main(int argc, const char** argv) return -1; } - std::vectorinfo; - cv::ocl::getDevice(info); - Mat frame; cap >> frame; diff --git a/samples/ocl/clahe.cpp b/samples/ocl/clahe.cpp index 1fbf49fac..5dc20756b 100644 --- a/samples/ocl/clahe.cpp +++ b/samples/ocl/clahe.cpp @@ -45,9 +45,6 @@ int main(int argc, char** argv) createTrackbar("Tile Size", "CLAHE", &tilesize, 32, (TrackbarCallback)TSize_Callback); createTrackbar("Clip Limit", "CLAHE", &cliplimit, 20, (TrackbarCallback)Clip_Callback); - vector info; - CV_Assert(ocl::getDevice(info)); - Mat frame, outframe; ocl::oclMat d_outframe; diff --git a/samples/ocl/facedetect.cpp b/samples/ocl/facedetect.cpp index 711e257e7..be61b79e4 100644 --- a/samples/ocl/facedetect.cpp +++ b/samples/ocl/facedetect.cpp @@ -72,7 +72,7 @@ int main( int argc, const char** argv ) CommandLineParser cmd(argc, argv, keys); if (cmd.get("help")) { - cout << "Avaible options:" << endl; + cout << "Available options:" << endl; cmd.printParams(); return 0; } @@ -120,16 +120,6 @@ int main( int argc, const char** argv ) cvNamedWindow( "result", 1 ); - vector oclinfo; - int devnums = ocl::getDevice(oclinfo); - if( devnums < 1 ) - { - std::cout << "no device found\n"; - return -1; - } - //if you want to use undefault device, set it here - //setDevice(oclinfo[0]); - ocl::setBinpath("./"); if( capture ) { cout << "In capture ..." << endl; diff --git a/samples/ocl/hog.cpp b/samples/ocl/hog.cpp index ec88c14d2..89c8dff82 100644 --- a/samples/ocl/hog.cpp +++ b/samples/ocl/hog.cpp @@ -135,8 +135,6 @@ App::App(CommandLineParser& cmd) void App::run() { - vector oclinfo; - ocl::getDevice(oclinfo); running = true; VideoWriter video_writer; diff --git a/samples/ocl/pyrlk_optical_flow.cpp b/samples/ocl/pyrlk_optical_flow.cpp index cefa92867..5a5980379 100644 --- a/samples/ocl/pyrlk_optical_flow.cpp +++ b/samples/ocl/pyrlk_optical_flow.cpp @@ -86,13 +86,6 @@ static void drawArrows(Mat& frame, const vector& prevPts, const vector< int main(int argc, const char* argv[]) { - static std::vector ocl_info; - ocl::getDevice(ocl_info); - //if you want to use undefault device, set it here - setDevice(ocl_info[0]); - - //set this to save kernel compile time from second time you run - ocl::setBinpath("./"); const char* keys = "{ h | help | false | print help message }" "{ l | left | | specify left image }" @@ -109,7 +102,7 @@ int main(int argc, const char* argv[]) if (cmd.get("help")) { cout << "Usage: pyrlk_optical_flow [options]" << endl; - cout << "Avaible options:" << endl; + cout << "Available options:" << endl; cmd.printParams(); return 0; } diff --git a/samples/ocl/squares.cpp b/samples/ocl/squares.cpp index 48964ffb2..9e709245d 100644 --- a/samples/ocl/squares.cpp +++ b/samples/ocl/squares.cpp @@ -284,13 +284,11 @@ int main(int argc, char** argv) string outfile = cmd.get("o"); if(inputName.empty()) { - cout << "Avaible options:" << endl; + cout << "Available options:" << endl; cmd.printParams(); return 0; } - vector info; - CV_Assert(ocl::getDevice(info)); int iterations = 10; namedWindow( wndname, 1 ); vector > squares_cpu, squares_ocl; diff --git a/samples/ocl/stereo_match.cpp b/samples/ocl/stereo_match.cpp index 38dda8a94..86d60d49b 100644 --- a/samples/ocl/stereo_match.cpp +++ b/samples/ocl/stereo_match.cpp @@ -77,28 +77,18 @@ int main(int argc, char** argv) "{ r | right | | specify right image }" "{ m | method | BM | specify match method(BM/BP/CSBP) }" "{ n | ndisp | 64 | specify number of disparity levels }" - "{ s | cpu_ocl | false | use cpu or gpu as ocl device to process the image }" "{ o | output | stereo_match_output.jpg | specify output path when input is images}"; CommandLineParser cmd(argc, argv, keys); if (cmd.get("help")) { - cout << "Avaible options:" << endl; + cout << "Available options:" << endl; cmd.printParams(); return 0; } try { App app(cmd); - int flag = CVCL_DEVICE_TYPE_GPU; - if(cmd.get("s") == true) - flag = CVCL_DEVICE_TYPE_CPU; - - vector info; - if(getDevice(info, flag) == 0) - { - throw runtime_error("Error: Did not find a valid OpenCL device!"); - } - cout << "Device name:" << info[0].DeviceName[0] << endl; + cout << "Device name:" << cv::ocl::Context::getContext()->getDeviceInfo().deviceName << endl; app.run(); } diff --git a/samples/ocl/surf_matcher.cpp b/samples/ocl/surf_matcher.cpp index bee517fbc..4d7332305 100644 --- a/samples/ocl/surf_matcher.cpp +++ b/samples/ocl/surf_matcher.cpp @@ -145,19 +145,11 @@ int main(int argc, char* argv[]) CommandLineParser cmd(argc, argv, keys); if (cmd.get("help")) { - std::cout << "Avaible options:" << std::endl; + std::cout << "Available options:" << std::endl; cmd.printParams(); return 0; } - vector info; - if(cv::ocl::getDevice(info) == 0) - { - std::cout << "Error: Did not find a valid OpenCL device!" << std::endl; - return -1; - } - ocl::setDevice(info[0]); - Mat cpu_img1, cpu_img2, cpu_img1_grey, cpu_img2_grey; oclMat img1, img2; bool useCPU = cmd.get("c"); @@ -190,7 +182,7 @@ int main(int argc, char* argv[]) { std::cout << "Device name:" - << info[0].DeviceName[0] + << cv::ocl::Context::getContext()->getDeviceInfo().deviceName << std::endl; } double surf_time = 0.; diff --git a/samples/ocl/tvl1_optical_flow.cpp b/samples/ocl/tvl1_optical_flow.cpp index 315970b7a..296dc6933 100644 --- a/samples/ocl/tvl1_optical_flow.cpp +++ b/samples/ocl/tvl1_optical_flow.cpp @@ -80,13 +80,6 @@ static void getFlowField(const Mat& u, const Mat& v, Mat& flowField) int main(int argc, const char* argv[]) { - static std::vector ocl_info; - ocl::getDevice(ocl_info); - //if you want to use undefault device, set it here - setDevice(ocl_info[0]); - - //set this to save kernel compile time from second time you run - ocl::setBinpath("./"); const char* keys = "{ h | help | false | print help message }" "{ l | left | | specify left image }" @@ -101,7 +94,7 @@ int main(int argc, const char* argv[]) if (cmd.get("help")) { cout << "Usage: pyrlk_optical_flow [options]" << endl; - cout << "Avaible options:" << endl; + cout << "Available options:" << endl; cmd.printParams(); return 0; }