Fix white-spacing

This commit is contained in:
peng xiao 2013-06-27 09:57:42 +08:00
parent 9270205947
commit dcc4766129
3 changed files with 207 additions and 197 deletions

View File

@ -136,11 +136,13 @@ PERFTEST(PyrLKOpticalFlow)
size_t mismatch = 0; size_t mismatch = 0;
for (int i = 0; i < (int)nextPts.size(); ++i) for (int i = 0; i < (int)nextPts.size(); ++i)
{ {
if(status[i] != ocl_status.at<unsigned char>(0, i)){ if(status[i] != ocl_status.at<unsigned char>(0, i))
{
mismatch++; mismatch++;
continue; continue;
} }
if(status[i]){ if(status[i])
{
Point2f gpu_rst = ocl_nextPts.at<Point2f>(0, i); Point2f gpu_rst = ocl_nextPts.at<Point2f>(0, i);
Point2f cpu_rst = nextPts[i]; Point2f cpu_rst = nextPts[i];
if(fabs(gpu_rst.x - cpu_rst.x) >= 1. || fabs(gpu_rst.y - cpu_rst.y) >= 1.) if(fabs(gpu_rst.x - cpu_rst.x) >= 1. || fabs(gpu_rst.y - cpu_rst.y) >= 1.)
@ -352,4 +354,3 @@ PERFTEST(FarnebackOpticalFlow)
} }
} }
} }

View File

@ -223,7 +223,8 @@ __kernel void updateMatrices(__global float * M,
int x1 = convert_int(floor(fx)); int x1 = convert_int(floor(fx));
int y1 = convert_int(floor(fy)); int y1 = convert_int(floor(fy));
fx -= x1; fy -= y1; fx -= x1;
fy -= y1;
float r2, r3, r4, r5, r6; float r2, r3, r4, r5, r6;
@ -283,8 +284,11 @@ __kernel void updateMatrices(__global float * M,
c_border[min(width - x - 1, BORDER_SIZE)] * c_border[min(width - x - 1, BORDER_SIZE)] *
c_border[min(height - y - 1, BORDER_SIZE)]; c_border[min(height - y - 1, BORDER_SIZE)];
r2 *= scale; r3 *= scale; r4 *= scale; r2 *= scale;
r5 *= scale; r6 *= scale; r3 *= scale;
r4 *= scale;
r5 *= scale;
r6 *= scale;
M[mad24(y, mStep, x)] = r4*r4 + r6*r6; M[mad24(y, mStep, x)] = r4*r4 + r6*r6;
M[mad24(height + y, mStep, x)] = (r4 + r5)*r6; M[mad24(height + y, mStep, x)] = (r4 + r5)*r6;

View File

@ -62,7 +62,9 @@ namespace cv
} }
} }
namespace cv { namespace ocl { namespace optflow_farneback namespace cv {
namespace ocl {
namespace optflow_farneback
{ {
oclMat g; oclMat g;
oclMat xg; oclMat xg;
@ -138,7 +140,8 @@ namespace cv { namespace ocl { namespace optflow_farneback
size_t localThreads[3] = { 32, 8, 1 }; size_t localThreads[3] = { 32, 8, 1 };
size_t globalThreads[3] = { divUp(flowx.cols, localThreads[0]) * localThreads[0], size_t globalThreads[3] = { divUp(flowx.cols, localThreads[0]) * localThreads[0],
divUp(flowx.rows, localThreads[1]) * localThreads[1], divUp(flowx.rows, localThreads[1]) * localThreads[1],
1 }; 1
};
std::vector< std::pair<size_t, const void *> > args; std::vector< std::pair<size_t, const void *> > args;
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&M.data)); args.push_back(std::make_pair(sizeof(cl_mem), (void *)&M.data));
@ -187,7 +190,8 @@ namespace cv { namespace ocl { namespace optflow_farneback
size_t localThreads[3] = { 32, 8, 1 }; size_t localThreads[3] = { 32, 8, 1 };
size_t globalThreads[3] = { divUp(cols, localThreads[0]) * localThreads[0], size_t globalThreads[3] = { divUp(cols, localThreads[0]) * localThreads[0],
divUp(flowx.rows, localThreads[1]) * localThreads[0], divUp(flowx.rows, localThreads[1]) * localThreads[0],
1 }; 1
};
std::vector< std::pair<size_t, const void *> > args; std::vector< std::pair<size_t, const void *> > args;
args.push_back(std::make_pair(sizeof(cl_mem), (void *)&flowx.data)); args.push_back(std::make_pair(sizeof(cl_mem), (void *)&flowx.data));
@ -226,7 +230,9 @@ namespace cv { namespace ocl { namespace optflow_farneback
openCLExecuteKernel(Context::getContext(), &optical_flow_farneback, kernelName, openCLExecuteKernel(Context::getContext(), &optical_flow_farneback, kernelName,
globalThreads, localThreads, args, -1, -1); globalThreads, localThreads, args, -1, -1);
} }
}}} // namespace cv { namespace ocl { namespace optflow_farneback }
}
} // namespace cv { namespace ocl { namespace optflow_farneback
static oclMat allocMatFromBuf(int rows, int cols, int type, oclMat &mat) static oclMat allocMatFromBuf(int rows, int cols, int type, oclMat &mat)
{ {
@ -504,4 +510,3 @@ void cv::ocl::FarnebackOpticalFlow::operator ()(
flowx = curFlowX; flowx = curFlowX;
flowy = curFlowY; flowy = curFlowY;
} }