MCPcopy Create free account
hub / github.com/arrayfire/arrayfire / buildLinearSystem

Function buildLinearSystem

src/backend/cuda/kernel/homography.hpp:200–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

198
199template<typename T>
200__global__ void buildLinearSystem(Param<T> H, CParam<float> x_src,
201 CParam<float> y_src, CParam<float> x_dst,
202 CParam<float> y_dst, CParam<float> rnd,
203 const unsigned iterations) {
204 unsigned tid_y = threadIdx.y;
205 unsigned i = blockIdx.y * blockDim.y + tid_y;
206
207 if (i < iterations) {
208 float x_src_mean, y_src_mean;
209 float x_dst_mean, y_dst_mean;
210 float src_scale, dst_scale;
211 float src_pt_x[4], src_pt_y[4], dst_pt_x[4], dst_pt_y[4];
212
213 computeMeanScale(&x_src_mean, &y_src_mean, &x_dst_mean, &y_dst_mean,
214 &src_scale, &dst_scale, src_pt_x, src_pt_y, dst_pt_x,
215 dst_pt_y, x_src, y_src, x_dst, y_dst, rnd, i);
216
217 T* s_V = (T*)sh;
218 T* s_S = (T*)sh + 16 * 81;
219
220 // Compute input matrix
221 for (unsigned j = threadIdx.x; j < 4; j += blockDim.x) {
222 float srcx = (src_pt_x[j] - x_src_mean) * src_scale;
223 float srcy = (src_pt_y[j] - y_src_mean) * src_scale;
224 float dstx = (dst_pt_x[j] - x_dst_mean) * dst_scale;
225 float dsty = (dst_pt_y[j] - y_dst_mean) * dst_scale;
226
227 SSPTR(tid_y, 0, j * 2) = 0.0f;
228 SSPTR(tid_y, 1, j * 2) = 0.0f;
229 SSPTR(tid_y, 2, j * 2) = 0.0f;
230 SSPTR(tid_y, 3, j * 2) = -srcx;
231 SSPTR(tid_y, 4, j * 2) = -srcy;
232 SSPTR(tid_y, 5, j * 2) = -1.0f;
233 SSPTR(tid_y, 6, j * 2) = dsty * srcx;
234 SSPTR(tid_y, 7, j * 2) = dsty * srcy;
235 SSPTR(tid_y, 8, j * 2) = dsty;
236
237 SSPTR(tid_y, 0, j * 2 + 1) = srcx;
238 SSPTR(tid_y, 1, j * 2 + 1) = srcy;
239 SSPTR(tid_y, 2, j * 2 + 1) = 1.0f;
240 SSPTR(tid_y, 3, j * 2 + 1) = 0.0f;
241 SSPTR(tid_y, 4, j * 2 + 1) = 0.0f;
242 SSPTR(tid_y, 5, j * 2 + 1) = 0.0f;
243 SSPTR(tid_y, 6, j * 2 + 1) = -dstx * srcx;
244 SSPTR(tid_y, 7, j * 2 + 1) = -dstx * srcy;
245 SSPTR(tid_y, 8, j * 2 + 1) = -dstx;
246
247 if (j == 4) {
248 SSPTR(tid_y, 0, 8) = 0.0f;
249 SSPTR(tid_y, 1, 8) = 0.0f;
250 SSPTR(tid_y, 2, 8) = 0.0f;
251 SSPTR(tid_y, 3, 8) = 0.0f;
252 SSPTR(tid_y, 4, 8) = 0.0f;
253 SSPTR(tid_y, 5, 8) = 0.0f;
254 SSPTR(tid_y, 6, 8) = 0.0f;
255 SSPTR(tid_y, 7, 8) = 0.0f;
256 SSPTR(tid_y, 8, 8) = 0.0f;
257 }

Callers

nothing calls this directly

Calls 1

computeMeanScaleFunction · 0.85

Tested by

no test coverage detected