| 384 | |
| 385 | template<typename T> |
| 386 | int homography(Array<T>& bestH, const Array<float>& x_src, |
| 387 | const Array<float>& y_src, const Array<float>& x_dst, |
| 388 | const Array<float>& y_dst, const Array<float>& initial, |
| 389 | const af_homography_type htype, const float inlier_thr, |
| 390 | const unsigned iterations) { |
| 391 | const dim4& idims = x_src.dims(); |
| 392 | const unsigned nsamples = idims[0]; |
| 393 | |
| 394 | unsigned iter = iterations; |
| 395 | if (htype == AF_HOMOGRAPHY_LMEDS) { |
| 396 | iter = min(iter, static_cast<unsigned>( |
| 397 | log(1.f - LMEDSConfidence) / |
| 398 | log(1.f - pow(1.f - LMEDSOutlierRatio, 4.f)))); |
| 399 | } |
| 400 | |
| 401 | af::dim4 rdims(4, iter); |
| 402 | Array<float> fctr = |
| 403 | createValueArray<float>(rdims, static_cast<float>(nsamples)); |
| 404 | Array<float> rnd = arithOp<float, af_mul_t>(initial, fctr, rdims); |
| 405 | rnd.eval(); |
| 406 | getQueue().sync(); |
| 407 | |
| 408 | return findBestHomography<T>(bestH, x_src, y_src, x_dst, y_dst, rnd, iter, |
| 409 | nsamples, inlier_thr, htype); |
| 410 | } |
| 411 | |
| 412 | #define INSTANTIATE(T) \ |
| 413 | template int homography<T>( \ |