opencv based CP detector for use with Hugin?

Skip to first unread message

Robert Mahar

Sep 7, 2023, 11:07:51 AMSep 7
to hugin and other free panoramic software

I've been using Hugin for a decade and for the most part can get it to do even difficult projects pretty easily.    But I have a couple microchip photography projects for which cpfind either finds no control points or a pile of extraneous ones.

Before I go crazy trying to make a cpfind like tool that speaks .pto files, and so on, I'm wondering if such a thing already exists to enable the use of the feature detection / mapping built into opencv.   I cannot imagine I am the first person on the planet to want to do this.   ( If I m I guess I should start coding. )

-- Bob

Rod Bibeau

Sep 7, 2023, 11:21:54 AMSep 7
So my use case is a bit different but maybe helpful -

I had a bunch of panos from my drone with lots of water and/or snow
that cause some images to not find CP's. My solution is not perfect, I
am confident, but works for the most part - Basically, I took a PTO
file that had all the images linked and used it as a template and then
incorporated the template into my pano script. While the results are
not perfect, they are much better than having large holes in the image
or water where the sky should be.

My git repository for this needs to be updated some, but here is the
script -
> --
> A list of frequently asked questions is available at:
> ---
> You received this message because you are subscribed to the Google Groups "hugin and other free panoramic software" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to
> To view this discussion on the web visit

Harry van der Wolf

Sep 7, 2023, 12:30:46 PMSep 7
Yes, it is already there in opencv and works pretty well.
There are multiple algorithms can do the "control point find" and multiple algorithms like the MergeMertens that can be combined as well.
And it also contains blending algorithms.

I did some work in Python. Not in C.


Op do 7 sep 2023 om 17:07 schreef Robert Mahar <>:

Robert Mahar

Sep 8, 2023, 1:56:32 PMSep 8
to hugin and other free panoramic software
Looking at the opencv feature detection, the only painful thing will be making something that "just works" with stock opencv packages, as the feature detection are in 3rd party modules so not normally available if you just grab opencv pre-built RPM.   Not so sure how easily sharable such a solution would be for average Hugin users if "step one" is build their own opencv libraries from source.   But the rest is just a lot of boilerplate and it should be easy to wrap it in a way that looks like a typical panotools utility.  "cvfind" LOL.

Saleh Saeed

Sep 8, 2023, 5:06:27 PMSep 8

OpenCV uses SIFT/SURF/ORB etc methods to extract features per image. The extracted features are matched between image pairs by predicting an alignment. OpenCV cannot find this alignment for non-linear images (i.e. wide angle/fisheye). 

- If you are using wide angle images with high distortion at corners, you can extract features with some incorrect/missing feature matches (at the distorted corners) using OpenCV. I recommend not to use OpenCV in this case.
- If you are using linear images, you can use OpenCV to write accurate 2D coordinates of matching features into the Hugin's pto file.

You have to compile OpenCV with some changes in the code to get the 2D coordinates of matched features between image pairs.

If you can share a sample of your work where the CP find gives you no or externous control points, it will be easier to check for issues.

Harry van der Wolf

Sep 8, 2023, 5:59:27 PMSep 8
Which ones do you mean?
In the 4.6 prebuilt libraries WITH the python bindings, I have ORB, SIFT, ECC, AlignMTB, mergeMertens exposure fusion, stiching, blending..
SIFT is free now, SURF is not, but ORB does a great job for keypoints and feature detection. Better than the other two (in my opinion).
It is for Python though, not C.

There is also the "" with many examples in both C(++) and Python.
And on github there are by now also a ton of examples.
Lots to learn and copy from.

Op vr 8 sep 2023 om 19:56 schreef Robert Mahar <>:
Reply all
Reply to author
0 new messages