1

I'm trying to implement the panorama stitching via OpenCV into our process, but want to use control points / matches gathered from PTGui.

PTGui however just lists the keypoints and the matches between images, no angles or additional data.

When using the normal workflow, the feature set is a list of ImageFeatures containing some parameters and a list of Keypoints.

Since I'm using OpenCV in Python, I don't really know how to create the list of ImageFeatures from scratch.

This is the current implementation, which doesn't work:

f1 = cv.detail_ImageFeatures()
f1.img_idx = 0
f1.descriptors = None
f1.img_size = (1920, 1080)
f1.keypoints = (
    cv.KeyPoint(1412.0, 734.0, 5.0),
    cv.KeyPoint(1415.0, 856.0, 5.0),
    cv.KeyPoint(1398.0, 885.0, 5.0)
)

...

features = [f1, f2, ...]

I get the following error when using my custom list just on the next step, which would be the matching: cv2.error: Conversion error: features

In addition to the custom ImageFeatures, I would also need custom matches. According to the documentation, these should be a MatchesInfo struct containing matches of type DMatch.

These are currently implemented as follows, but can't be tested since the above error already occurs beforehand:

matches = (
  cv.detail_MatchesInfo(confidence=1.0, dst_img_idx=1, H=None, inliers_mask=None, matches=(
    cv.DMatch(0, 0, 0.0),
    cv.DMatch(1, 1, 0.0),
    cv.DMatch(2, 2, 0.0)), num_inliers=None, src_img_idx=0),
  ...
)

So I was wondering, if it is even possible to "import" custom control points and matches using OpenCV Python. If yes, what would have to be changed to make it work.

k.m.
  • 41
  • 2
  • What is the code leading to the error message? I can't seem to find that line. – MSpiller Dec 20 '22 at 11:12
  • It's basically any function after the feature detection in the stitching pipeline. In the case above it would be `cv.detail_BestOf2NearestMatcher(**kwargs).apply2(features, *args, **kwargs)` – k.m. Dec 21 '22 at 05:53
  • I want to add custom keypoint stitching as Feature in my [stitching](https://github.com/lukasalexanderweber/stitching) package anyway. Why dont you open an issue with sample Images and keypoints? – Lukas Weber Dec 22 '22 at 18:26
  • @LukasWeber I was using your package for testing, but my question above was just for a generic sample. I tested the implementation in C++ and it worked, but another issue came up: In most cases, I have 2 fisheye cameras both taking 180° images, which don't have any overlapping keypoints. Using PTGui, these images can be aligned easily, but the export only gives me a yaw, pitch and roll per image and a general focal length, so I don't really know how to convert these to OpenCV `CameraParams`. – k.m. Dec 23 '22 at 07:54

0 Answers0