Commit 95869a60 authored by NikoKJ's avatar NikoKJ

fix the compilation bug of main.cpp in perf test and accuracy test on ocl…

fix the compilation bug of main.cpp in perf test and accuracy test on ocl module. It caused by the incompatibility of command line parser class in core.hpp between master branch and 2.4 branch.
parent 4d059e9e
...@@ -79,77 +79,47 @@ int main(int argc, char **argv) ...@@ -79,77 +79,47 @@ int main(int argc, char **argv)
TS::ptr()->init("ocl"); TS::ptr()->init("ocl");
InitGoogleTest(&argc, argv); InitGoogleTest(&argc, argv);
const char *keys = const char *keys =
"{ h | false | print help message }"
"{ h | help | false | print help message }" "{ w | ../../../samples/c/| set working directory i.e. -w=C:\\}"
"{ t | gpu | set device type:i.e. -t=cpu or gpu}"
"{ w | workdir | ../../../samples/c/| set working directory }" "{ p | 0 | set platform id i.e. -p=0}"
"{ d | 0 | set device id i.e. -d=0}";
"{ t | type | gpu | set device type:cpu or gpu}"
"{ p | platform | 0 | set platform id }"
"{ d | device | 0 | set device id }";
CommandLineParser cmd(argc, argv, keys); CommandLineParser cmd(argc, argv, keys);
if (cmd.get<string>("h")=="true")
if (cmd.get<bool>("help"))
{ {
cout << "Avaible options besides goole test option:" << endl; cout << "Avaible options besides goole test option:" << endl;
cmd.printMessage();
cmd.printParams(); return 0;
} }
workdir = cmd.get<string>("w");
workdir = cmd.get<string>("workdir"); string type = cmd.get<string>("t");
unsigned int pid = cmd.get<unsigned int>("p");
string type = cmd.get<string>("type"); int device = cmd.get<int>("d");
unsigned int pid = cmd.get<unsigned int>("platform");
int device = cmd.get<int>("device");
print_info(); print_info();
int flag = CVCL_DEVICE_TYPE_GPU; int flag = CVCL_DEVICE_TYPE_GPU;
if(type == "cpu") if(type == "cpu")
{ {
flag = CVCL_DEVICE_TYPE_CPU; flag = CVCL_DEVICE_TYPE_CPU;
} }
std::vector<cv::ocl::Info> oclinfo; std::vector<cv::ocl::Info> oclinfo;
int devnums = getDevice(oclinfo); int devnums = getDevice(oclinfo);
if(devnums <= device || device < 0) if(devnums <= device || device < 0)
{ {
std::cout << "device invalid\n"; std::cout << "device invalid\n";
return -1; return -1;
} }
if(pid >= oclinfo.size()) if(pid >= oclinfo.size())
{ {
std::cout << "platform invalid\n"; std::cout << "platform invalid\n";
return -1; return -1;
} }
if(pid != 0 || device != 0) if(pid != 0 || device != 0)
{ {
setDevice(oclinfo[pid], device); setDevice(oclinfo[pid], device);
} }
cout << "Device type:" << type << endl << "Device name:" << oclinfo[pid].DeviceName[device] << endl; cout << "Device type:" << type << endl << "Device name:" << oclinfo[pid].DeviceName[device] << endl;
......
...@@ -79,23 +79,23 @@ int main(int argc, char **argv) ...@@ -79,23 +79,23 @@ int main(int argc, char **argv)
TS::ptr()->init("ocl"); TS::ptr()->init("ocl");
InitGoogleTest(&argc, argv); InitGoogleTest(&argc, argv);
const char *keys = const char *keys =
"{ h | help | false | print help message }" "{ h | false | print help message }"
"{ w | workdir | ../../../samples/c/| set working directory }" "{ w | ../../../samples/c/| set working directory i.e. -w=C:\\}"
"{ t | type | gpu | set device type:cpu or gpu}" "{ t | gpu | set device type:i.e. -t=cpu or gpu}"
"{ p | platform | 0 | set platform id }" "{ p | 0 | set platform id i.e. -p=0}"
"{ d | device | 0 | set device id }"; "{ d | 0 | set device id i.e. -d=0}";
CommandLineParser cmd(argc, argv, keys); CommandLineParser cmd(argc, argv, keys);
if (cmd.get<bool>("help")) if (cmd.get<string>("h")=="true")
{ {
cout << "Avaible options besides goole test option:" << endl; cout << "Avaible options besides goole test option:" << endl;
cmd.printParams(); cmd.printMessage();
return 0; return 0;
} }
workdir = cmd.get<string>("workdir"); workdir = cmd.get<string>("w");
string type = cmd.get<string>("type"); string type = cmd.get<string>("t");
unsigned int pid = cmd.get<unsigned int>("platform"); unsigned int pid = cmd.get<unsigned int>("p");
int device = cmd.get<int>("device"); int device = cmd.get<int>("d");
print_info(); print_info();
int flag = CVCL_DEVICE_TYPE_GPU; int flag = CVCL_DEVICE_TYPE_GPU;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment