I am looking to speed up some bundle adjustment code by specifying which images are overlapping. I created a function that places a grid of points in each image and then tests the pairwise overlap. Basically, it approximates the intersection area of the photos from the initial homography. Here is an example these 4 overlapping photos:
Ive been working off of this example https://github.com/amdecker/ir/blob/master/Stitcher.py
match_mask = np.zeros((len(features), len(features)), np.uint8)
for i in range(len(data[0][1]) - 1):
match_mask[i, i 1] = 1
matches_info = matcher.apply2(features, match_mask)
.
.
.
b, cameras = adjuster.apply(features, matches_info, cameras)
I can not find any documentation with regards to what format the match_mask needs to be. I would like to apply the mask such that only images with above some threshold say 50% overlap are used. If anyone could explain what the match_mask is that would be awesome!!
PS this is the docstring I found if it helps... finding it a bit cryptic doesnt give dimms or any details
"""
apply2(features[, mask]) -> pairwise_matches
. @brief Performs images matching.
.
. @param features Features of the source images
. @param pairwise_matches Found pairwise matches
. @param mask Mask indicating which image pairs must be matched
.
. The function is parallelized with the TBB library.
.
. @sa detail::MatchesInfo
"""
CodePudding user response:
Implementation: https://github.com/opencv/opencv/blob/676a724491de423c5d964d83594f7e99aa0d31c7/modules/stitching/src/matchers.cpp#L338
It looks like mask needs to be a NxN uint8 (boolean) matrix, N being the number of images, i.e. len(features).
If docs are unclear/vague/lacking, feel free to open an issue on the github about it. This function seems a good candidate for improvement.


