Last active
June 18, 2019 08:04
-
-
Save r7vme/01f8418f788c2402b621fb5e83e999bf to your computer and use it in GitHub Desktop.
Find camera intrinsics matrix from FOV and resolution
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import math | |
# input | |
VFOV=60 | |
H=480 | |
W=856 | |
aspRatio=W/H | |
VFOV_rad=VFOV*math.pi/180. | |
HFOV_rad= 2 * math.atan( math.tan(VFOV_rad/2) * aspRatio ) | |
fx = (W/2)/math.tan(HFOV_rad/2) | |
fy = (H/2)/math.tan(VFOV_rad/2) | |
u0 = W/2 | |
v0 = H/2 | |
print("fx:\t\t\t%.2f" % fx) | |
print("fy (same as fx):\t%.2f" % fy) | |
print("u0:\t\t\t%.2f" % u0) | |
print("v0:\t\t\t%.2f" % v0) | |
print() | |
print("Intrinsics matrix:") | |
print() | |
print("%.2f\t%.2f\t%.2f" % (fx,0,u0)) | |
print("%.2f\t%.2f\t%.2f" % (0,fy,v0)) | |
print("%.2f\t%.2f\t%.2f" % (0,0,1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment