Bug 439221 - Incorrect calculation of camera field of view
Summary: Incorrect calculation of camera field of view
Status: RESOLVED FIXED
Alias: None
Product: kstars
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Other Other
: NOR normal
Target Milestone: ---
Assignee: Jasem Mutlaq
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-06-27 13:17 UTC by Fred
Modified: 2022-08-25 14:12 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In: 3.6.1


Attachments
attachment-24758-0.html (1.83 KB, text/html)
2022-08-24 20:01 UTC, Fred
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Fred 2021-06-27 13:17:24 UTC
SUMMARY

The returned value for the camera field of view is wrong when the focal length is short.

OBSERVED RESULT
- Canon 6D mk II pixel pitch of 5,67 um and 6240x4160 px
- 24 mm lens

Returns :  84,47 x 56.31°

This is completely wrong

EXPECTED RESULT

73,6° x 53,1°

ADDITIONAL INFORMATION

Apparently your logic is to multiply the pixel sampling by the number of pixels. If this is a good approximation when the focal length is at least 10x bigger than the sensors size, it completely fails otherwise.

The formula that gives the proper result each time (but fisheyes) is :

fov = 2*atan[L/(2*F)]
Comment 2 Jasem Mutlaq 2021-06-27 14:27:46 UTC
Thank you for the report. What's L?
Comment 3 Fred 2021-06-27 17:09:08 UTC
Hi!

L is a length of the active region of the sensor. Whether the width, the height or the diagonal. 

Fred
Comment 4 Fred 2021-06-27 17:11:14 UTC
… and of course F is the focal length of the optical system.

L and F shall be expressed in the same unit.
Comment 5 Jasem Mutlaq 2021-06-27 23:20:29 UTC
The problem is this information is not available right now in Ekos. I believe a long term solution is to enable selection of scopes OR lenses in the equipment profile which can then be used to better calculated the FOV.
Comment 6 Fred 2021-06-28 06:13:16 UTC
You can have it differently. Just multiply the pixel size by the number of pixels and you get the sensor’s dimension.

The formula becomes :

- fov(width)=2*atan(P*Nw/(2F))
- fov(height)=2*atan(P*Nh/(2F))

Where P is the pixel size, Nw and Nh are the number of pixels of the sensor, and F the focal length. Take care with the units.
Comment 7 Fred 2021-06-28 06:16:12 UTC
This formula is valid for all optical equipment, from lenses to telescopes, focused at infinity, which is the general use in astrophoto. It doesn’t work with fisheyes and at macro/proxy focus (macro photo) but we rarely need to do macro photographies with DSOs ;-)
Comment 8 Fred 2021-06-28 14:55:01 UTC
Jasem the bug fix is in fovdialog.cpp replace the lines :
 
// FOV in arcmins
double fov_x = 206264.8062470963552 * ui->cameraWidth->value() * ui->cameraPixelSizeW->value() / 60000.0 / ui->TLength2->value();
double fov_y = 206264.8062470963552 * ui->cameraHeight->value() * ui->cameraPixelSizeH->value() / 60000.0 / ui->TLength2->value();
 
By:
 
// FOV in arcmins
double fov_x = (60*180 / M_PI) * 2 * atan( ui->cameraWidth->value() * ui->cameraPixelSizeW->value() / (2 * ui->TLength2->value()));
double fov_y = (60*180 / M_PI) * 2 * atan( ui->cameraHeight->value() * ui->cameraPixelSizeH->value() / (2 * ui->TLength2->value()));

You can replace (60*180 / M_PI) * 2 by 6875.5. There is no need to use dozen of decimals…

I haven’t checked if the fov is calculated elsewhere.
Comment 9 Fred 2021-06-28 14:57:37 UTC
 I forgot to say that you just have to check if all units are consistent !!! The pixel width and focal length shall be expressed in the same unit (both in mm, or both in inch, or both in m…).
Comment 10 Fred 2021-06-28 15:17:31 UTC
Apparently the pixel size is in um (10^-6 m) and the focal length is in mm (10^-3 m), therefore the full formula is :

// FOV in arcmins
double fov_x = 6875.5 * atan( ui->cameraWidth->value() * ui->cameraPixelSizeW->value() / (2000 * ui->TLength2->value()));
double fov_y = 6875.5 * atan( ui->cameraHeight->value() * ui->cameraPixelSizeH->value() / (2000 * ui->TLength2->value()));
Comment 11 Nate Graham 2021-07-29 16:11:28 UTC
Perhaps you can submit a merge request?

https://invent.kde.org/education/kstars/-/merge_requests/
Comment 12 Jasem Mutlaq 2021-08-18 17:40:57 UTC
So if we can add a test to see which method is used to calculate. However, for the camera lens, there aren't information for that available in Ekos right now. It just has access to focal length and aperture.
Comment 13 Jasem Mutlaq 2022-08-24 17:22:49 UTC
I'm about to add support for this in Ekos but the math doesn't check out.

For your camera, this would be 

fov_w = 6875.5*atan(6240*5.67 / (2000*24)) = 250226.44 arcsecs

which is 69.5 degrees. While you say it should be 73.6 degrees?
Comment 14 Fred 2022-08-24 20:01:43 UTC
Created attachment 151562 [details]
attachment-24758-0.html

Hi Jasem

The maths are :

FOV = 2.atan(dimension/(2*focal length))

That is as simple as that.

All the best

Fred

Fred
________________________________
De : Jasem Mutlaq <bugzilla_noreply@kde.org>
Envoyé : Wednesday, August 24, 2022 7:22:49 PM
À : fred_76_@hotmail.fr <fred_76_@hotmail.fr>
Objet : [kstars] [Bug 439221] Incorrect calculation of camera field of view

https://bugs.kde.org/show_bug.cgi?id=439221

--- Comment #13 from Jasem Mutlaq <mutlaqja@ikarustech.com> ---
I'm about to add support for this in Ekos but the math doesn't check out.

For your camera, this would be

fov_w = 6875.5*atan(6240*5.67 / (2000*24)) = 250226.44 arcsecs

which is 69.5 degrees. While you say it should be 73.6 degrees?

--
You are receiving this mail because:
You reported the bug.
Comment 15 Jasem Mutlaq 2022-08-24 20:51:01 UTC
Yes thanks, I already figured it out. It should be fixed in 3.6.1
Comment 16 Jasem Mutlaq 2022-08-25 14:12:24 UTC
Ok it should be fixed in 3.6.1