Commit 4248f822 authored by Ilya Lavrenov's avatar Ilya Lavrenov

added ROI support to ocl::buildWarp*Maps functions

parent 0be27523
This diff is collapsed.
...@@ -43,31 +43,25 @@ ...@@ -43,31 +43,25 @@
// //
//M*/ //M*/
__kernel __kernel void buildWarpPlaneMaps(__global float * xmap, __global float * ymap,
void buildWarpPlaneMaps __constant float * KRT,
( int tl_u, int tl_v,
__global float * map_x, int cols, int rows,
__global float * map_y, int xmap_step, int ymap_step,
__constant float * KRT, int xmap_offset, int ymap_offset,
int tl_u, float scale)
int tl_v,
int cols,
int rows,
int step_x,
int step_y,
float scale
)
{ {
int du = get_global_id(0); int du = get_global_id(0);
int dv = get_global_id(1); int dv = get_global_id(1);
step_x /= sizeof(float);
step_y /= sizeof(float);
__constant float * ck_rinv = KRT; __constant float * ck_rinv = KRT;
__constant float * ct = KRT + 9; __constant float * ct = KRT + 9;
if (du < cols && dv < rows) if (du < cols && dv < rows)
{ {
int xmap_index = mad24(dv, xmap_step, xmap_offset + du);
int ymap_index = mad24(dv, ymap_step, ymap_offset + du);
float u = tl_u + du; float u = tl_u + du;
float v = tl_v + dv; float v = tl_v + dv;
float x, y; float x, y;
...@@ -83,33 +77,27 @@ __kernel ...@@ -83,33 +77,27 @@ __kernel
x /= z; x /= z;
y /= z; y /= z;
map_x[dv * step_x + du] = x; xmap[xmap_index] = x;
map_y[dv * step_y + du] = y; ymap[ymap_index] = y;
} }
} }
__kernel __kernel void buildWarpCylindricalMaps(__global float * xmap, __global float * ymap,
void buildWarpCylindricalMaps __constant float * ck_rinv,
( int tl_u, int tl_v,
__global float * map_x, int cols, int rows,
__global float * map_y, int xmap_step, int ymap_step,
__constant float * ck_rinv, int xmap_offset, int ymap_offset,
int tl_u, float scale)
int tl_v,
int cols,
int rows,
int step_x,
int step_y,
float scale
)
{ {
int du = get_global_id(0); int du = get_global_id(0);
int dv = get_global_id(1); int dv = get_global_id(1);
step_x /= sizeof(float);
step_y /= sizeof(float);
if (du < cols && dv < rows) if (du < cols && dv < rows)
{ {
int xmap_index = mad24(dv, xmap_step, xmap_offset + du);
int ymap_index = mad24(dv, ymap_step, ymap_offset + du);
float u = tl_u + du; float u = tl_u + du;
float v = tl_v + dv; float v = tl_v + dv;
float x, y; float x, y;
...@@ -127,33 +115,27 @@ __kernel ...@@ -127,33 +115,27 @@ __kernel
if (z > 0) { x /= z; y /= z; } if (z > 0) { x /= z; y /= z; }
else x = y = -1; else x = y = -1;
map_x[dv * step_x + du] = x; xmap[xmap_index] = x;
map_y[dv * step_y + du] = y; ymap[ymap_index] = y;
} }
} }
__kernel __kernel void buildWarpSphericalMaps(__global float * xmap, __global float * ymap,
void buildWarpSphericalMaps __constant float * ck_rinv,
( int tl_u, int tl_v,
__global float * map_x, int cols, int rows,
__global float * map_y, int xmap_step, int ymap_step,
__constant float * ck_rinv, int xmap_offset, int ymap_offset,
int tl_u, float scale)
int tl_v,
int cols,
int rows,
int step_x,
int step_y,
float scale
)
{ {
int du = get_global_id(0); int du = get_global_id(0);
int dv = get_global_id(1); int dv = get_global_id(1);
step_x /= sizeof(float);
step_y /= sizeof(float);
if (du < cols && dv < rows) if (du < cols && dv < rows)
{ {
int xmap_index = mad24(dv, xmap_step, xmap_offset + du);
int ymap_index = mad24(dv, ymap_step, ymap_offset + du);
float u = tl_u + du; float u = tl_u + du;
float v = tl_v + dv; float v = tl_v + dv;
float x, y; float x, y;
...@@ -174,63 +156,52 @@ __kernel ...@@ -174,63 +156,52 @@ __kernel
if (z > 0) { x /= z; y /= z; } if (z > 0) { x /= z; y /= z; }
else x = y = -1; else x = y = -1;
map_x[dv * step_x + du] = x; xmap[xmap_index] = x;
map_y[dv * step_y + du] = y; ymap[ymap_index] = y;
} }
} }
__kernel __kernel void buildWarpAffineMaps(__global float * xmap, __global float * ymap,
void buildWarpAffineMaps __constant float * c_warpMat,
( int cols, int rows,
__global float * xmap, int xmap_step, int ymap_step,
__global float * ymap, int xmap_offset, int ymap_offset)
__constant float * c_warpMat,
int cols,
int rows,
int step_x,
int step_y
)
{ {
int x = get_global_id(0); int x = get_global_id(0);
int y = get_global_id(1); int y = get_global_id(1);
step_x /= sizeof(float);
step_y /= sizeof(float);
if (x < cols && y < rows) if (x < cols && y < rows)
{ {
const float xcoo = c_warpMat[0] * x + c_warpMat[1] * y + c_warpMat[2]; int xmap_index = mad24(y, xmap_step, x + xmap_offset);
const float ycoo = c_warpMat[3] * x + c_warpMat[4] * y + c_warpMat[5]; int ymap_index = mad24(y, ymap_step, x + ymap_offset);
float xcoo = c_warpMat[0] * x + c_warpMat[1] * y + c_warpMat[2];
float ycoo = c_warpMat[3] * x + c_warpMat[4] * y + c_warpMat[5];
map_x[y * step_x + x] = xcoo; xmap[xmap_index] = xcoo;
map_y[y * step_y + x] = ycoo; ymap[ymap_index] = ycoo;
} }
} }
__kernel __kernel void buildWarpPerspectiveMaps(__global float * xmap, __global float * ymap,
void buildWarpPerspectiveMaps __constant float * c_warpMat,
( int cols, int rows,
__global float * xmap, int xmap_step, int ymap_step,
__global float * ymap, int xmap_offset, int ymap_offset)
__constant float * c_warpMat,
int cols,
int rows,
int step_x,
int step_y
)
{ {
int x = get_global_id(0); int x = get_global_id(0);
int y = get_global_id(1); int y = get_global_id(1);
step_x /= sizeof(float);
step_y /= sizeof(float);
if (x < cols && y < rows) if (x < cols && y < rows)
{ {
const float coeff = 1.0f / (c_warpMat[6] * x + c_warpMat[7] * y + c_warpMat[8]); int xmap_index = mad24(y, xmap_step, x + xmap_offset);
int ymap_index = mad24(y, ymap_step, x + ymap_offset);
const float xcoo = coeff * (c_warpMat[0] * x + c_warpMat[1] * y + c_warpMat[2]); float coeff = 1.0f / (c_warpMat[6] * x + c_warpMat[7] * y + c_warpMat[8]);
const float ycoo = coeff * (c_warpMat[3] * x + c_warpMat[4] * y + c_warpMat[5]); float xcoo = coeff * (c_warpMat[0] * x + c_warpMat[1] * y + c_warpMat[2]);
float ycoo = coeff * (c_warpMat[3] * x + c_warpMat[4] * y + c_warpMat[5]);
map_x[y * step_x + x] = xcoo; xmap[xmap_index] = xcoo;
map_y[y * step_y + x] = ycoo; ymap[ymap_index] = ycoo;
} }
} }
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