fix the compilation bugs

This commit is contained in:
niko
2012-07-30 14:34:36 +08:00
parent c0a4105467
commit cf04fed369
6 changed files with 912 additions and 466 deletions

View File

@@ -260,7 +260,7 @@ namespace cv
CV_Assert((!map2.data || map2.size()== map1.size()));
dst.create(map1.size(), src.type());
int depth = src.depth(), map_depth = map1.depth();
string kernelName;
@@ -279,28 +279,107 @@ namespace cv
kernelName = "remapNNSConstant";
}
int type = src.type();
size_t blkSizeX = 16, blkSizeY = 16;
size_t glbSizeX;
if(src.type() == CV_8UC1 || src.type() == CV_8UC2 || src.type() == CV_8UC4)
int channels = dst.channels();
int depth = dst.depth();
int type = src.type();
size_t blkSizeX = 16, blkSizeY = 16;
size_t glbSizeX;
int cols = dst.cols;
if(src.type() == CV_8UC1)
{
size_t cols = (dst.cols + dst.offset%4 + 3)/4;
cols = (dst.cols + dst.offset%4 + 3)/4;
glbSizeX = cols %blkSizeX==0 ? cols : (cols/blkSizeX+1)*blkSizeX;
}
else if(src.type() == CV_8UC4 || src.type() == CV_32FC1)
{
cols = (dst.cols + (dst.offset>>2)%4 + 3)/4;
glbSizeX = cols %blkSizeX==0 ? cols : (cols/blkSizeX+1)*blkSizeX;
}
else
{
glbSizeX = dst.cols%blkSizeX==0 ? dst.cols : (dst.cols/blkSizeX+1)*blkSizeX;
}
size_t glbSizeY = dst.rows%blkSizeY==0 ? dst.rows : (dst.rows/blkSizeY+1)*blkSizeY;
size_t globalThreads[3] = {glbSizeX,glbSizeY,1};
size_t localThreads[3] = {blkSizeX,blkSizeY,1};
/*
/////////////////////////////
//using the image buffer
/////////////////////////////
size_t image_row_pitch = 0;
cl_int err1, err2, err3;
cl_mem_flags flags1 = CL_MEM_READ_ONLY;
cl_image_format format;
if(src.type() == CV_8UC1)
{
format.image_channel_order = CL_R;
format.image_channel_data_type = CL_UNSIGNED_INT8;
}
else if(src.type() == CV_8UC4)
{
format.image_channel_order = CL_RGBA;
format.image_channel_data_type = CL_UNSIGNED_INT8;
}
else if(src.type() == CV_32FC1)
{
format.image_channel_order = CL_R;
format.image_channel_data_type = CL_FLOAT;
}
else if(src.type() == CV_32FC4)
{
format.image_channel_order = CL_RGBA;
format.image_channel_data_type = CL_FLOAT;
}
cl_mem srcImage = clCreateImage2D(clCxt->impl->clContext, flags1, &format, src.cols, src.rows,
image_row_pitch, NULL, &err1);
if(err1 != CL_SUCCESS)
{
printf("Error creating CL image buffer, error code %d\n", err1);
return;
}
const size_t src_origin[3] = {0, 0, 0};
const size_t region[3] = {src.cols, src.rows, 1};
cl_event BtoI_event, ItoB_event;
err3 = clEnqueueCopyBufferToImage(clCxt->impl->clCmdQueue, (cl_mem)src.data, srcImage,
0, src_origin, region, 0, NULL, NULL);
if(err3 != CL_SUCCESS)
{
printf("Error copying buffer to image\n");
printf("Error code %d \n", err3);
return;
}
// clWaitForEvents(1, &BtoI_event);
cl_int ret;
Mat test(src.rows, src.cols, CV_8UC1);
memset(test.data, 0, src.rows*src.cols);
ret = clEnqueueReadImage(clCxt->impl->clCmdQueue, srcImage, CL_TRUE,
src_origin, region, 0, 0, test.data, NULL, NULL, &ItoB_event);
if(ret != CL_SUCCESS)
{
printf("read image error, %d ", ret);
return;
}
clWaitForEvents(1, &ItoB_event);
cout << "src" << endl;
cout << src << endl;
cout<<"image:"<<endl;
cout<< test << endl;
*/
vector< pair<size_t, const void *> > args;
if(map1.channels() == 2)
{
args.push_back( make_pair(sizeof(cl_mem),(void*)&dst.data));
args.push_back( make_pair(sizeof(cl_mem),(void*)&src.data));
// args.push_back( make_pair(sizeof(cl_mem),(void*)&srcImage)); //imageBuffer
args.push_back( make_pair(sizeof(cl_mem),(void*)&map1.data));
args.push_back( make_pair(sizeof(cl_int),(void*)&dst.offset));
args.push_back( make_pair(sizeof(cl_int),(void*)&src.offset));
@@ -314,12 +393,10 @@ namespace cv
args.push_back( make_pair(sizeof(cl_int),(void*)&dst.rows));
args.push_back( make_pair(sizeof(cl_int),(void*)&map1.cols));
args.push_back( make_pair(sizeof(cl_int),(void*)&map1.rows));
args.push_back( make_pair(sizeof(cl_int), (void *)&cols));
args.push_back( make_pair(sizeof(cl_double4),(void*)&borderValue));
}
openCLExecuteKernel(clCxt,&imgproc_remap,kernelName,globalThreads,localThreads,args,src.channels(),src.depth());
}
////////////////////////////////////////////////////////////////////////////////////////////

File diff suppressed because it is too large Load Diff