ocl::Image2D imageI(I);
ocl::Image2D imageJ(J);
int idxArg = 0;
-#if 0
idxArg = kernel.set(idxArg, imageI); //image2d_t I
idxArg = kernel.set(idxArg, imageJ); //image2d_t J
idxArg = kernel.set(idxArg, ocl::KernelArg::PtrReadOnly(prevPts)); // __global const float2* prevPts
idxArg = kernel.set(idxArg, (int)winSize.height); // int c_winSize_y
idxArg = kernel.set(idxArg, (int)iters); // int c_iters
idxArg = kernel.set(idxArg, (char)calcErr); //char calcErr
-#else
- SAFE_KERNEL_SET_ARG(idxArg, imageI); //image2d_t I
- SAFE_KERNEL_SET_ARG(idxArg, imageJ); //image2d_t J
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(prevPts)); // __global const float2* prevPts
- SAFE_KERNEL_SET_ARG(idxArg, (int)prevPts.step); // int prevPtsStep
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadWrite(nextPts)); // __global const float2* nextPts
- SAFE_KERNEL_SET_ARG(idxArg, (int)nextPts.step); // int nextPtsStep
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadWrite(status)); // __global uchar* status
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadWrite(err)); // __global float* err
- SAFE_KERNEL_SET_ARG(idxArg, (int)level); // const int level
- SAFE_KERNEL_SET_ARG(idxArg, (int)I.rows); // const int rows
- SAFE_KERNEL_SET_ARG(idxArg, (int)I.cols); // const int cols
- SAFE_KERNEL_SET_ARG(idxArg, (int)patch.x); // int PATCH_X
- SAFE_KERNEL_SET_ARG(idxArg, (int)patch.y); // int PATCH_Y
- SAFE_KERNEL_SET_ARG(idxArg, (int)winSize.width); // int c_winSize_x
- SAFE_KERNEL_SET_ARG(idxArg, (int)winSize.height); // int c_winSize_y
- SAFE_KERNEL_SET_ARG(idxArg, (int)iters); // int c_iters
- SAFE_KERNEL_SET_ARG(idxArg, (char)calcErr); //char calcErr
-#endif
-
return kernel.run(2, globalThreads, localThreads, true);
}
private:
return false;
int idxArg = 0;
-#if 0
idxArg = kernel.set(idxArg, ocl::KernelArg::PtrReadOnly(src));//src mat
idxArg = kernel.set(idxArg, (int)(src.cols));//src mat col
idxArg = kernel.set(idxArg, (int)(src.rows));//src mat rows
idxArg = kernel.set(idxArg, ocl::KernelArg::PtrWriteOnly(dx));//res mat dx
idxArg = kernel.set(idxArg, ocl::KernelArg::PtrWriteOnly(dy));//res mat dy
idxArg = kernel.set(idxArg, (int)(dx.step/dx.elemSize()));//res mat step
-#else
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(src));
- SAFE_KERNEL_SET_ARG(idxArg, (int)(src.cols));
- SAFE_KERNEL_SET_ARG(idxArg, (int)(src.rows));
- SAFE_KERNEL_SET_ARG(idxArg, (int)(src.step / src.elemSize()));
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrWriteOnly(dx));
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrWriteOnly(dy));
- SAFE_KERNEL_SET_ARG(idxArg, (int)(dx.step / dx.elemSize()));
-#endif
return kernel.run(2, globalsize, NULL, false);
}
return false;
int idxArg = 0;
-#if 0
idxArg = kernel.set(idxArg, ocl::KernelArg::PtrReadOnly(I0));//I0 mat
int I0_step = (int)(I0.step / I0.elemSize());
idxArg = kernel.set(idxArg, I0_step);//I0_step
u2_offset_x = (int) (u2_offset_x / u2.elemSize());
idxArg = kernel.set(idxArg, (int)u2_offset_x);//u2_offset_x
idxArg = kernel.set(idxArg, (int)(u2.offset / u2.step));//u2_offset_y
-#else
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(I0));//I0 mat
- int I0_step = (int)(I0.step / I0.elemSize());
- SAFE_KERNEL_SET_ARG(idxArg, I0_step);//I0_step
- SAFE_KERNEL_SET_ARG(idxArg, (int)(I0.cols));//I0_col
- SAFE_KERNEL_SET_ARG(idxArg, (int)(I0.rows));//I0_row
- ocl::Image2D imageI1(I1);
- ocl::Image2D imageI1x(I1x);
- ocl::Image2D imageI1y(I1y);
- SAFE_KERNEL_SET_ARG(idxArg, imageI1);//image2d_t tex_I1
- SAFE_KERNEL_SET_ARG(idxArg, imageI1x);//image2d_t tex_I1x
- SAFE_KERNEL_SET_ARG(idxArg, imageI1y);//image2d_t tex_I1y
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(u1));//const float* u1
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u1.step / u1.elemSize()));//int u1_step
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(u2));//const float* u2
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrWriteOnly(I1w));///float* I1w
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrWriteOnly(I1wx));//float* I1wx
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrWriteOnly(I1wy));//float* I1wy
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrWriteOnly(grad));//float* grad
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrWriteOnly(rho));//float* rho
- SAFE_KERNEL_SET_ARG(idxArg, (int)(I1w.step / I1w.elemSize()));//I1w_step
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u2.step / u2.elemSize()));//u2_step
- int u1_offset_x = (int)((u1.offset) % (u1.step));
- u1_offset_x = (int)(u1_offset_x / u1.elemSize());
- SAFE_KERNEL_SET_ARG(idxArg, (int)u1_offset_x);//u1_offset_x
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u1.offset / u1.step));//u1_offset_y
- int u2_offset_x = (int)((u2.offset) % (u2.step));
- u2_offset_x = (int)(u2_offset_x / u2.elemSize());
- SAFE_KERNEL_SET_ARG(idxArg, (int)u2_offset_x);//u2_offset_x
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u2.offset / u2.step));//u2_offset_y
-#endif
return kernel.run(2, globalsize, NULL, false);
}
return false;
int idxArg = 0;
-#if 0
idxArg = kernel.set(idxArg, ocl::KernelArg::PtrReadOnly(I1wx)); //const float* I1wx
idxArg = kernel.set(idxArg, (int)(I1wx.cols)); //int I1wx_col
idxArg = kernel.set(idxArg, (int)(I1wx.rows)); //int I1wx_row
idxArg = kernel.set(idxArg, (int)u2_offset_x ); //int u2_offset_x
idxArg = kernel.set(idxArg, (int)(u2.offset / u2.step)); //int u2_offset_y
idxArg = kernel.set(idxArg, (char)calc_error); //char calc_error
-#else
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(I1wx)); //const float* I1wx
- SAFE_KERNEL_SET_ARG(idxArg, (int)(I1wx.cols)); //int I1wx_col
- SAFE_KERNEL_SET_ARG(idxArg, (int)(I1wx.rows)); //int I1wx_row
- SAFE_KERNEL_SET_ARG(idxArg, (int)(I1wx.step / I1wx.elemSize())); //int I1wx_step
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(I1wy)); //const float* I1wy
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(grad)); //const float* grad
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(rho_c)); //const float* rho_c
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(p11)); //const float* p11
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(p12)); //const float* p12
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(p21)); //const float* p21
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(p22)); //const float* p22
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadWrite(u1)); //float* u1
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u1.step / u1.elemSize())); //int u1_step
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadWrite(u2)); //float* u2
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrWriteOnly(error)); //float* error
- SAFE_KERNEL_SET_ARG(idxArg, (float)l_t); //float l_t
- SAFE_KERNEL_SET_ARG(idxArg, (float)theta); //float theta
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u2.step / u2.elemSize()));//int u2_step
- int u1_offset_x = (int)(u1.offset % u1.step);
- u1_offset_x = (int)(u1_offset_x / u1.elemSize());
- SAFE_KERNEL_SET_ARG(idxArg, (int)u1_offset_x); //int u1_offset_x
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u1.offset / u1.step)); //int u1_offset_y
- int u2_offset_x = (int)(u2.offset % u2.step);
- u2_offset_x = (int)(u2_offset_x / u2.elemSize());
- SAFE_KERNEL_SET_ARG(idxArg, (int)u2_offset_x); //int u2_offset_x
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u2.offset / u2.step)); //int u2_offset_y
- SAFE_KERNEL_SET_ARG(idxArg, (char)calc_error); //char calc_error
-#endif
+
return kernel.run(2, globalsize, NULL, false);
}
return false;
int idxArg = 0;
-#if 0
idxArg = kernel.set(idxArg, ocl::KernelArg::PtrReadOnly(u1));// const float* u1
idxArg = kernel.set(idxArg, (int)(u1.cols)); //int u1_col
idxArg = kernel.set(idxArg, (int)(u1.rows)); //int u1_row
u2_offset_x = (int)(u2_offset_x / u2.elemSize());
idxArg = kernel.set(idxArg, u2_offset_x); //int u2_offset_x
idxArg = kernel.set(idxArg, (int)(u2.offset / u2.step)); //int u2_offset_y
-#else
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(u1));// const float* u1
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u1.cols)); //int u1_col
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u1.rows)); //int u1_row
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u1.step / u1.elemSize())); //int u1_step
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadOnly(u2)); // const float* u2
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadWrite(p11)); // float* p11
- SAFE_KERNEL_SET_ARG(idxArg, (int)(p11.step / p11.elemSize())); //int p11_step
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadWrite(p12)); // float* p12
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadWrite(p21)); // float* p21
- SAFE_KERNEL_SET_ARG(idxArg, ocl::KernelArg::PtrReadWrite(p22)); // float* p22
- SAFE_KERNEL_SET_ARG(idxArg, (float)(taut)); //float taut
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u2.step / u2.elemSize())); //int u2_step
- int u1_offset_x = (int)(u1.offset % u1.step);
- u1_offset_x = (int)(u1_offset_x / u1.elemSize());
- SAFE_KERNEL_SET_ARG(idxArg, u1_offset_x); //int u1_offset_x
- SAFE_KERNEL_SET_ARG(idxArg, (int)(u1.offset / u1.step)); //int u1_offset_y
- int u2_offset_x = (int)(u2.offset % u2.step);
- u2_offset_x = (int)(u2_offset_x / u2.elemSize());
- SAFE_KERNEL_SET_ARG(idxArg, u2_offset_x); //int u2_offset_x
- idxArg = kernel.set(idxArg, (int)(u2.offset / u2.step)); //int u2_offset_y
-#endif
+
return kernel.run(2, globalsize, NULL, false);
}
-
OpticalFlowDual_TVL1::OpticalFlowDual_TVL1()
{
tau = 0.25;