Setting focal length from the command-line?

58 views
Skip to first unread message

David Turner

unread,
Sep 26, 2024, 10:31:34 AM9/26/24
to hugin and other free panoramic software
How do I set the focal length from the command-line?

To make sure that I'm asking the right question, here's the background:

In Hugin, when I load images, I'm offered a dialog allowing me to set HFO(v), focal length, and a focal length multiplier.

(I understand that some cameras put this in the EXIF; mine doesn't.  This is the camera in question: https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/64MP-OV64A40/)

I know (from the spec sheet) my camera's focal length and FOV, so I choose a focal length multiplier which gives the correct results.  This works great.

But I want to be able to do this from the command-line.  Right now, my process is:

pto_gen -f 86 -o foo.pto

cpfind --multirow  -o foo.pto foo.pto

cpclean -o foo.pto foo.pto

autooptimiser -a -l -s -o foo.pto foo.pto

# unclear if needed

pano_modify -o foo.pto --center --straighten --canvas=AUTO --crop=AUTO foo.pto

nona -o outfile- -m TIFF_m foo.pto

This lets me set the FOV but not the focal length.  The result is different (and worse) than hugin, and I suspect that the focal length is the difference. 

Thanks!

T. Modes

unread,
Sep 26, 2024, 11:46:12 AM9/26/24
to hugin and other free panoramic software
Hi,
nov...@novalis.org schrieb am Donnerstag, 26. September 2024 um 16:31:34 UTC+2:
How do I set the focal length from the command-line?

To make sure that I'm asking the right question, here's the background:

In Hugin, when I load images, I'm offered a dialog allowing me to set HFO(v), focal length, and a focal length multiplier.

For all optimising/remapping steps Hugin is only using the HFOV.
In the GUI the focal length is calculated from the HFOV and focal length multiplier and displayed only for convenience.
So the command line tools have only the option to set the HFOV.


David Turner

unread,
Sep 26, 2024, 1:43:24 PM9/26/24
to 'T. Modes' via hugin and other free panoramic software

Thanks. 

In that case, do you have any idea what's wrong with my script?

Here's a worked example:

https://novalis.org/hugin/

The script is at https://novalis.org/hugin/merge.sh

The result of the script is at

https://novalis.org/hugin/out-cli.jpg

The result from Hugin is at:

https://novalis.org/hugin/hugin.jpg

Is there something I can do to make the command-line output match (at least more closely) the Hugin output?


T. Modes

unread,
Sep 26, 2024, 1:55:13 PM9/26/24
to hugin and other free panoramic software
nov...@novalis.org schrieb am Donnerstag, 26. September 2024 um 19:43:24 UTC+2:

In that case, do you have any idea what's wrong with my script?

My advise would be to compare the working pto file with the pto file generated by your script and look for differences.

The working hugin.pto file has a hfov of 68 for all images, but in the script you are using 86 deg.

If the assistant in the GUI works fine for you, you can use it also from the command line with hugin_executor --assistant --output=project.pto project.pto instead of reinventing the wheel again.

Reply all
Reply to author
Forward
0 new messages