ocl: update ocl samples

This commit is contained in:
Alexander Alekhin 2013-10-03 19:35:01 +04:00
parent 7f0680fc8b
commit 69c2ef5ed2
11 changed files with 10 additions and 73 deletions

View File

@ -132,17 +132,9 @@ int main(int argc, const char* argv[])
} }
#endif #endif
#if defined(HAVE_OPENCV_OCL) #if defined(HAVE_OPENCV_OCL)
std::vector<cv::ocl::Info>info;
if(useCuda) if(useCuda)
{ {
CV_Assert(!useOcl); CV_Assert(!useOcl);
info.clear();
}
if(useOcl)
{
CV_Assert(!useCuda);
cv::ocl::getDevice(info);
} }
#endif #endif
Ptr<SuperResolution> superRes; Ptr<SuperResolution> superRes;

View File

@ -25,9 +25,6 @@ int main( int argc, const char** argv )
return -1; return -1;
} }
std::vector<ocl::Info> infos;
ocl::getDevice(infos);
ocl::oclMat dsrc(src), dABFilter, dBFilter; ocl::oclMat dsrc(src), dABFilter, dBFilter;
Size ksize(ks, ks); Size ksize(ks, ks);
@ -48,4 +45,4 @@ int main( int argc, const char** argv )
waitKey(); waitKey();
return 0; return 0;
} }

View File

@ -24,7 +24,7 @@ int main(int argc, const char** argv)
if (cmd.get<bool>("help")) if (cmd.get<bool>("help"))
{ {
cout << "Usage : bgfg_segm [options]" << endl; cout << "Usage : bgfg_segm [options]" << endl;
cout << "Avaible options:" << endl; cout << "Available options:" << endl;
cmd.printParams(); cmd.printParams();
return 0; return 0;
} }
@ -54,9 +54,6 @@ int main(int argc, const char** argv)
return -1; return -1;
} }
std::vector<cv::ocl::Info>info;
cv::ocl::getDevice(info);
Mat frame; Mat frame;
cap >> frame; cap >> frame;

View File

@ -45,9 +45,6 @@ int main(int argc, char** argv)
createTrackbar("Tile Size", "CLAHE", &tilesize, 32, (TrackbarCallback)TSize_Callback); createTrackbar("Tile Size", "CLAHE", &tilesize, 32, (TrackbarCallback)TSize_Callback);
createTrackbar("Clip Limit", "CLAHE", &cliplimit, 20, (TrackbarCallback)Clip_Callback); createTrackbar("Clip Limit", "CLAHE", &cliplimit, 20, (TrackbarCallback)Clip_Callback);
vector<ocl::Info> info;
CV_Assert(ocl::getDevice(info));
Mat frame, outframe; Mat frame, outframe;
ocl::oclMat d_outframe; ocl::oclMat d_outframe;

View File

@ -72,7 +72,7 @@ int main( int argc, const char** argv )
CommandLineParser cmd(argc, argv, keys); CommandLineParser cmd(argc, argv, keys);
if (cmd.get<bool>("help")) if (cmd.get<bool>("help"))
{ {
cout << "Avaible options:" << endl; cout << "Available options:" << endl;
cmd.printParams(); cmd.printParams();
return 0; return 0;
} }
@ -120,16 +120,6 @@ int main( int argc, const char** argv )
cvNamedWindow( "result", 1 ); cvNamedWindow( "result", 1 );
vector<ocl::Info> 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 ) if( capture )
{ {
cout << "In capture ..." << endl; cout << "In capture ..." << endl;

View File

@ -135,8 +135,6 @@ App::App(CommandLineParser& cmd)
void App::run() void App::run()
{ {
vector<ocl::Info> oclinfo;
ocl::getDevice(oclinfo);
running = true; running = true;
VideoWriter video_writer; VideoWriter video_writer;

View File

@ -86,13 +86,6 @@ static void drawArrows(Mat& frame, const vector<Point2f>& prevPts, const vector<
int main(int argc, const char* argv[]) int main(int argc, const char* argv[])
{ {
static std::vector<Info> 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 = const char* keys =
"{ h | help | false | print help message }" "{ h | help | false | print help message }"
"{ l | left | | specify left image }" "{ l | left | | specify left image }"
@ -109,7 +102,7 @@ int main(int argc, const char* argv[])
if (cmd.get<bool>("help")) if (cmd.get<bool>("help"))
{ {
cout << "Usage: pyrlk_optical_flow [options]" << endl; cout << "Usage: pyrlk_optical_flow [options]" << endl;
cout << "Avaible options:" << endl; cout << "Available options:" << endl;
cmd.printParams(); cmd.printParams();
return 0; return 0;
} }

View File

@ -284,13 +284,11 @@ int main(int argc, char** argv)
string outfile = cmd.get<string>("o"); string outfile = cmd.get<string>("o");
if(inputName.empty()) if(inputName.empty())
{ {
cout << "Avaible options:" << endl; cout << "Available options:" << endl;
cmd.printParams(); cmd.printParams();
return 0; return 0;
} }
vector<ocl::Info> info;
CV_Assert(ocl::getDevice(info));
int iterations = 10; int iterations = 10;
namedWindow( wndname, 1 ); namedWindow( wndname, 1 );
vector<vector<Point> > squares_cpu, squares_ocl; vector<vector<Point> > squares_cpu, squares_ocl;

View File

@ -77,28 +77,18 @@ int main(int argc, char** argv)
"{ r | right | | specify right image }" "{ r | right | | specify right image }"
"{ m | method | BM | specify match method(BM/BP/CSBP) }" "{ m | method | BM | specify match method(BM/BP/CSBP) }"
"{ n | ndisp | 64 | specify number of disparity levels }" "{ 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}"; "{ o | output | stereo_match_output.jpg | specify output path when input is images}";
CommandLineParser cmd(argc, argv, keys); CommandLineParser cmd(argc, argv, keys);
if (cmd.get<bool>("help")) if (cmd.get<bool>("help"))
{ {
cout << "Avaible options:" << endl; cout << "Available options:" << endl;
cmd.printParams(); cmd.printParams();
return 0; return 0;
} }
try try
{ {
App app(cmd); App app(cmd);
int flag = CVCL_DEVICE_TYPE_GPU; cout << "Device name:" << cv::ocl::Context::getContext()->getDeviceInfo().deviceName << endl;
if(cmd.get<bool>("s") == true)
flag = CVCL_DEVICE_TYPE_CPU;
vector<Info> 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;
app.run(); app.run();
} }

View File

@ -145,19 +145,11 @@ int main(int argc, char* argv[])
CommandLineParser cmd(argc, argv, keys); CommandLineParser cmd(argc, argv, keys);
if (cmd.get<bool>("help")) if (cmd.get<bool>("help"))
{ {
std::cout << "Avaible options:" << std::endl; std::cout << "Available options:" << std::endl;
cmd.printParams(); cmd.printParams();
return 0; return 0;
} }
vector<cv::ocl::Info> 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; Mat cpu_img1, cpu_img2, cpu_img1_grey, cpu_img2_grey;
oclMat img1, img2; oclMat img1, img2;
bool useCPU = cmd.get<bool>("c"); bool useCPU = cmd.get<bool>("c");
@ -190,7 +182,7 @@ int main(int argc, char* argv[])
{ {
std::cout std::cout
<< "Device name:" << "Device name:"
<< info[0].DeviceName[0] << cv::ocl::Context::getContext()->getDeviceInfo().deviceName
<< std::endl; << std::endl;
} }
double surf_time = 0.; double surf_time = 0.;

View File

@ -80,13 +80,6 @@ static void getFlowField(const Mat& u, const Mat& v, Mat& flowField)
int main(int argc, const char* argv[]) int main(int argc, const char* argv[])
{ {
static std::vector<Info> 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 = const char* keys =
"{ h | help | false | print help message }" "{ h | help | false | print help message }"
"{ l | left | | specify left image }" "{ l | left | | specify left image }"
@ -101,7 +94,7 @@ int main(int argc, const char* argv[])
if (cmd.get<bool>("help")) if (cmd.get<bool>("help"))
{ {
cout << "Usage: pyrlk_optical_flow [options]" << endl; cout << "Usage: pyrlk_optical_flow [options]" << endl;
cout << "Avaible options:" << endl; cout << "Available options:" << endl;
cmd.printParams(); cmd.printParams();
return 0; return 0;
} }