remove redundant OPENCL_DIR flag

remove as much warnings as possible
use enum instead of MACRO for ocl.hpp
add command line parser in accuracy test and perf test
some bug fix for arthim functions
This commit is contained in:
Niko
2012-10-22 15:14:22 +08:00
parent b6a2717c2b
commit 5df77a841e
44 changed files with 2040 additions and 1593 deletions

View File

@@ -73,22 +73,86 @@ void print_info()
#endif
}
std::string workdir;
int main(int argc, char **argv)
{
std::vector<cv::ocl::Info> oclinfo;
TS::ptr()->init("ocl");
InitGoogleTest(&argc, argv);
const char *keys =
"{ h | help | false | print help message }"
"{ w | workdir | ../../../samples/c/| set working directory }"
"{ 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);
if (cmd.get<bool>("help"))
{
cout << "Avaible options besides goole test option:" << endl;
cmd.printParams();
}
workdir = cmd.get<string>("workdir");
string type = cmd.get<string>("type");
unsigned int pid = cmd.get<unsigned int>("platform");
int device = cmd.get<int>("device");
print_info();
int devnums = getDevice(oclinfo);
if(devnums < 1)
int flag = CVCL_DEVICE_TYPE_GPU;
if(type == "cpu")
{
std::cout << "no device found\n";
return -1;
flag = CVCL_DEVICE_TYPE_CPU;
}
//if you want to use undefault device, set it here
//setDevice(oclinfo[0]);
std::vector<cv::ocl::Info> oclinfo;
int devnums = getDevice(oclinfo);
if(devnums <= device || device < 0)
{
std::cout << "device invalid\n";
return -1;
}
if(pid >= oclinfo.size())
{
std::cout << "platform invalid\n";
return -1;
}
if(pid != 0 || device != 0)
{
setDevice(oclinfo[pid], device);
}
cout << "Device type:" << type << endl << "Device name:" << oclinfo[pid].DeviceName[device] << endl;
setBinpath(CLBINPATH);
return RUN_ALL_TESTS();
}

View File

@@ -2672,13 +2672,13 @@ TEST_P(CountNonZero, MAT)
Has_roi(k);
t0 = (double)cvGetTickCount();//cpu start
int cpures = cv::countNonZero(mat1_roi);
cv::countNonZero(mat1_roi);
t0 = (double)cvGetTickCount() - t0;//cpu end
t1 = (double)cvGetTickCount();//gpu start1
gmat1 = mat1_roi;
t2 = (double)cvGetTickCount(); //kernel
int gpures = cv::ocl::countNonZero(gmat1);
cv::ocl::countNonZero(gmat1);
t2 = (double)cvGetTickCount() - t2;//kernel
t1 = (double)cvGetTickCount() - t1;//gpu end1
if(j == 0)
@@ -2713,7 +2713,7 @@ TEST_P(CountNonZero, MAT)
{
cout << "\nwith roi:";
};
int gpures = cv::ocl::countNonZero(gmat1);
cv::ocl::countNonZero(gmat1);
};
#endif

View File

@@ -52,8 +52,6 @@ using namespace cvtest;
using namespace testing;
using namespace std;
#define FILTER_IMAGE "../../../samples/gpu/road.png"
#ifndef MWC_TEST_UTILITY
#define MWC_TEST_UTILITY
@@ -79,7 +77,7 @@ IMPLEMENT_PARAM_CLASS(Channels, int)
////////////////////////////////////////////////////////
// Canny1
extern std::string workdir;
IMPLEMENT_PARAM_CLASS(AppertureSize, int);
IMPLEMENT_PARAM_CLASS(L2gradient, bool);
@@ -101,7 +99,7 @@ PARAM_TEST_CASE(Canny1, AppertureSize, L2gradient)
TEST_P(Canny1, Performance)
{
cv::Mat img = readImage(FILTER_IMAGE, cv::IMREAD_GRAYSCALE);
cv::Mat img = readImage(workdir + "fruits.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
double low_thresh = 100.0;

View File

@@ -1184,11 +1184,11 @@ INSTANTIATE_TEST_CASE_P(Filters, Laplacian, Combine(
//INSTANTIATE_TEST_CASE_P(Filter, ErodeDilate, Combine(Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(1, 2, 3)));
INSTANTIATE_TEST_CASE_P(Filter, Erode, Combine(Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(false)));
INSTANTIATE_TEST_CASE_P(Filter, Erode, Combine(Values(CV_8UC1, CV_8UC1), Values(false)));
//INSTANTIATE_TEST_CASE_P(Filter, ErodeDilate, Combine(Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(1, 2, 3)));
INSTANTIATE_TEST_CASE_P(Filter, Dilate, Combine(Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(false)));
INSTANTIATE_TEST_CASE_P(Filter, Dilate, Combine(Values(CV_8UC1, CV_8UC1), Values(false)));
INSTANTIATE_TEST_CASE_P(Filter, Sobel, Combine(Values(CV_8UC1, CV_32FC1),

View File

@@ -52,7 +52,7 @@ using namespace cvtest;
using namespace testing;
using namespace std;
using namespace cv;
extern std::string workdir;
struct getRect
{
Rect operator ()(const CvAvgComp &e) const
@@ -80,9 +80,6 @@ PARAM_TEST_CASE(HaarTestBase, int, int)
if( (!cascade.load( cascadeName )) || (!cpucascade.load(cascadeName)))
{
cout << "ERROR: Could not load classifier cascade" << endl;
cout << "Usage: facedetect [--cascade=<cascade_path>]\n"
" [--scale[=<image scale>\n"
" [filename|camera_index]\n" << endl ;
return;
}
//int devnums = getDevice(oclinfo);
@@ -99,16 +96,16 @@ struct Haar : HaarTestBase {};
TEST_F(Haar, FaceDetect)
{
string imgName = "../../../samples/c/lena.jpg";
string imgName = workdir + "lena.jpg";
Mat img = imread( imgName, 1 );
if(img.empty())
{
std::cout << "Couldn't read test" << index << ".jpg" << std::endl;
std::cout << imgName << std::endl;
return ;
}
int i = 0;
//int i = 0;
double t = 0;
vector<Rect> faces, oclfaces;

View File

@@ -53,8 +53,7 @@ using namespace cv::ocl;
using namespace cvtest;
using namespace testing;
using namespace std;
#define FILTER_IMAGE "../../../samples/gpu/road.png"
extern std::string workdir;
#ifndef MWC_TEST_UTILITY
#define MWC_TEST_UTILITY
@@ -100,15 +99,15 @@ PARAM_TEST_CASE(HOG, WinSizw48, bool)
TEST_P(HOG, Performance)
{
cv::Mat img = readImage(FILTER_IMAGE, cv::IMREAD_GRAYSCALE);
cv::Mat img = readImage(workdir + "lena.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
// define HOG related arguments
float scale = 1.05;
int nlevels = 13;
//int nlevels = 13;
float gr_threshold = 8;
float hit_threshold = 1.4;
bool hit_threshold_auto = true;
//bool hit_threshold_auto = true;
int win_width = is48 ? 48 : 64;
int win_stride_width = 8;

View File

@@ -1246,6 +1246,7 @@ TEST_P(Remap, Mat)
}
int bordertype[] = {cv::BORDER_CONSTANT, cv::BORDER_REPLICATE/*,BORDER_REFLECT,BORDER_WRAP,BORDER_REFLECT_101*/};
const char *borderstr[] = {"BORDER_CONSTANT", "BORDER_REPLICATE"/*, "BORDER_REFLECT","BORDER_WRAP","BORDER_REFLECT_101"*/};
cout << borderstr[0] << endl;
#ifndef PRINT_KERNEL_RUN_TIME
double totalcputick = 0;
double totalgputick = 0;

View File

@@ -714,7 +714,6 @@ TEST_P(DataTransfer, perf)
totaluploadtick = t0 + totaluploadtick;
totaldownloadtick = t1 + totaldownloadtick;
}
EXPECT_MAT_SIMILAR(mat, cpu_dst, 0.0);
totaltick = totaluploadtick + totaldownloadtick;
cout << "average upload time is " << totaluploadtick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;
cout << "average download time is " << totaldownloadtick / ((double)cvGetTickFrequency()* LOOP_TIMES * 1000.) << "ms" << endl;

View File

@@ -450,7 +450,7 @@ TEST_P(Split, Accuracy)
for(int j = LOOPROISTART; j < LOOPROIEND; j ++)
{
Has_roi(j);
cv::Mat dev_dst[4] = {dst1_roi, dst2_roi, dst3_roi, dst4_roi};
//cv::Mat dev_dst[4] = {dst1_roi, dst2_roi, dst3_roi, dst4_roi};
cv::ocl::oclMat dev_gdst[4] = {gdst1, gdst2, gdst3, gdst4};
gdst1_whole = dst1;
gdst1 = gdst1_whole(Rect(dst1x, dst1y, roicols, roirows));

View File

@@ -54,11 +54,11 @@ using namespace cvtest;
using namespace testing;
using namespace std;
#define FILTER_IMAGE "../../../samples/gpu/road.png"
extern std::string workdir;
TEST(SURF, Performance)
{
cv::Mat img = readImage(FILTER_IMAGE, cv::IMREAD_GRAYSCALE);
cv::Mat img = readImage(workdir+"lena.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
ocl::SURF_OCL d_surf;