-
Notifications
You must be signed in to change notification settings - Fork 552
Added Homography #1085
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Added Homography #1085
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
53d77a7
Added homography function prototype and API
80869d9
Added CPU backend for homography
693397d
Added CUDA backend for homography
5ca352a
Added OpenCL backend for homography
008a6d9
Added homography documentation
b514aab
Added homography unit tests
e5e954e
Updated test data
80d49eb
Merge remote-tracking branch 'upstream/devel' into homography
33d4ead
Fixed homography for Intel OpenCL
cb13531
Disabled homography LMedS unit tests
b3da23b
Split vision.h prototypes into multiple lines
d7abcf2
Fixed __syncthreads() calls in homography
3e0abfa
Added AF_HOMOGRAPHY prefix to af_homography_t enum
c55cae4
Fixed homography documentation
31761d2
Removed unnecessary __syncthreads() on homography
1fd4511
Removed unnecessary barrier from homography
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| /******************************************************* | ||
| * Copyright (c) 2015, ArrayFire | ||
| * All rights reserved. | ||
| * | ||
| * This file is distributed under 3-clause BSD license. | ||
| * The complete license agreement can be obtained at: | ||
| * http://arrayfire.com/licenses/BSD-3-Clause | ||
| ********************************************************/ | ||
|
|
||
| #include <af/array.h> | ||
| #include <af/defines.h> | ||
| #include <af/vision.h> | ||
| #include <err_common.hpp> | ||
| #include <handle.hpp> | ||
| #include <backend.hpp> | ||
| #include <ArrayInfo.hpp> | ||
| #include <homography.hpp> | ||
|
|
||
| using af::dim4; | ||
| using namespace detail; | ||
|
|
||
| template<typename T> | ||
| static inline void homography(af_array &H, int &inliers, | ||
| const af_array x_src, const af_array y_src, | ||
| const af_array x_dst, const af_array y_dst, | ||
| const af_homography_type htype, const float inlier_thr, | ||
| const unsigned iterations) | ||
| { | ||
| Array<T> bestH = createEmptyArray<T>(af::dim4(3, 3)); | ||
|
|
||
| inliers = homography<T>(bestH, | ||
| getArray<float>(x_src), getArray<float>(y_src), | ||
| getArray<float>(x_dst), getArray<float>(y_dst), | ||
| htype, inlier_thr, iterations); | ||
|
|
||
| H = getHandle<T>(bestH); | ||
| } | ||
|
|
||
| af_err af_homography(af_array *H, int *inliers, | ||
| const af_array x_src, const af_array y_src, | ||
| const af_array x_dst, const af_array y_dst, | ||
| const af_homography_type htype, const float inlier_thr, | ||
| const unsigned iterations, const af_dtype otype) | ||
| { | ||
| try { | ||
| ArrayInfo xsinfo = getInfo(x_src); | ||
| ArrayInfo ysinfo = getInfo(y_src); | ||
| ArrayInfo xdinfo = getInfo(x_dst); | ||
| ArrayInfo ydinfo = getInfo(y_dst); | ||
|
|
||
| af::dim4 xsdims = xsinfo.dims(); | ||
| af::dim4 ysdims = ysinfo.dims(); | ||
| af::dim4 xddims = xdinfo.dims(); | ||
| af::dim4 yddims = ydinfo.dims(); | ||
|
|
||
| af_dtype xstype = xsinfo.getType(); | ||
| af_dtype ystype = ysinfo.getType(); | ||
| af_dtype xdtype = xdinfo.getType(); | ||
| af_dtype ydtype = ydinfo.getType(); | ||
|
|
||
| if (xstype != f32) { TYPE_ERROR(1, xstype); } | ||
| if (ystype != f32) { TYPE_ERROR(2, ystype); } | ||
| if (xdtype != f32) { TYPE_ERROR(3, xdtype); } | ||
| if (ydtype != f32) { TYPE_ERROR(4, ydtype); } | ||
|
|
||
| ARG_ASSERT(1, (xsdims[0] > 0)); | ||
| ARG_ASSERT(2, (ysdims[0] == xsdims[0])); | ||
| ARG_ASSERT(3, (xddims[0] > 0)); | ||
| ARG_ASSERT(4, (yddims[0] == yddims[0])); | ||
|
|
||
| ARG_ASSERT(5, (inlier_thr >= 0.1f)); | ||
| ARG_ASSERT(6, (iterations > 0)); | ||
|
|
||
| af_array outH; | ||
| int outInl; | ||
|
|
||
| switch(otype) { | ||
| case f32: homography<float >(outH, outInl, x_src, y_src, x_dst, y_dst, htype, inlier_thr, iterations); break; | ||
| case f64: homography<double>(outH, outInl, x_src, y_src, x_dst, y_dst, htype, inlier_thr, iterations); break; | ||
| default: TYPE_ERROR(1, otype); | ||
| } | ||
| std::swap(*H, outH); | ||
| std::swap(*inliers, outInl); | ||
| } | ||
| CATCHALL; | ||
|
|
||
| return AF_SUCCESS; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| /******************************************************* | ||
| * Copyright (c) 2015, ArrayFire | ||
| * All rights reserved. | ||
| * | ||
| * This file is distributed under 3-clause BSD license. | ||
| * The complete license agreement can be obtained at: | ||
| * http://arrayfire.com/licenses/BSD-3-Clause | ||
| ********************************************************/ | ||
|
|
||
| #include <af/vision.h> | ||
| #include <af/array.h> | ||
| #include "error.hpp" | ||
|
|
||
| namespace af | ||
| { | ||
|
|
||
| void homography(array &H, int &inliers, | ||
| const array &x_src, const array &y_src, | ||
| const array &x_dst, const array &y_dst, | ||
| const af_homography_type htype, const float inlier_thr, | ||
| const unsigned iterations, const af::dtype otype) | ||
| { | ||
| af_array outH; | ||
| AF_THROW(af_homography(&outH, &inliers, | ||
| x_src.get(), y_src.get(), | ||
| x_dst.get(), y_dst.get(), | ||
| htype, inlier_thr, iterations, otype)); | ||
|
|
||
| H = array(outH); | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
outis not a parameter namehtype,inlier_thranditerationsto match the function parameter orderaf_homography_typetohtypein the documentationtype/dtypetootype