Python 3D calibration and homogenous coordinates computation library
Project description
Python camera calibration and projective geometry library
This library offers several tools to ease manipulation of camera calibration, projective geometry and computations using homogenous coordinates.
Full API documentation is available in here.
2D and 3D points implementation
The vector used to represent 2D and 3D points are vertical vectors, which are stored as 2D matrices in numpy
. Furthemore, in homogenous coordinates: a 3D point (x,y,z) in the world is represented by a 4 element vector (𝜆x,𝜆y,𝜆z,𝜆) where 𝜆 ∈ ℝ₀.
To simplify access to x and y (and z) coordinates of those points as well as computations in homogenous coordinates, we defined the objects Point2D
(and Point3D
) extending numpy.ndarray
. Therefore, access to y coordinate of point
is point.y
instead of point[1][0]
(point[1][:]
for an array of points), and access to homogenous coordinates is made easy with point.H
, while it is still possible to use point
with any numpy
operators.
Construction
The construction of such point is made convenient with multiple ways of building them. With 𝜆 represented as l
a 2D point can be created provided x
and y
as scalar for single points, or as numpy.ndarray
, list
or tuple
for array of points.
Point2D(x, y)
Point2D(l*x, l*y, l)
The construction can also be made from numpy
arrays of dimensions (D,N) or (D+1,N) in homogenous coordinates where D ∈ {2,3} is the space dimension and N is the number of points (which can be 0 for an empty set of points). Example:
>>> array = np.array([[0, 0, 0, 0, 0], # x coordinates
[1, 2, 3, 4, 5]]) # y coordinates
>>> points = Point2D(array)
>>> points.x
array([0., 0., 0., 0., 0.])
>>> points.H
array([[0., 0., 0., 0., 0.],
[1., 2., 3., 4., 5.],
[1., 1., 1., 1., 1.]])
Usage with numpy operators
The implementation extends numpy.ndarray
. It means that all operators work out of the box.
>>> point = Point2D(1,2)
>>> point*2
Point2D([[2.],
[4.]])
>>> point+5
Point2D([[6.],
[7.]])
>>> np.linalg.norm(point)
2.23606797749979
Camera calibration
This library implements a Calib
object that represent a calibrated camera given its intrinsic and extrinsic parameters.
The object has a serie of methods to handle 3D to 2D projections, 2D to 3D liftings, image transformations and more.
Construction
The Calib
object requires the camera matirx K
, the rotation matrix R
, the translation vector T
, the image width
and height
and optionally the lens distortion coefficients kc
.
R
is expressed using Euler angles and represents the rotation applied to the world coordinates system to obtain the camera coordinates system orientation.
T
is the position of the origin of the world coordinates system expressed in the camera coordinates system
The camera coordinates system is therefore a transformation of the world coordinates systems with:
- A rotation defined by a rotation matrix $R$ using euler angles in a right-hand orthogonal system. The rotation is applied to the world coordinates system to obtain the camera orientation.
- A translation defined by a translation vector $T$ representing the position of the center of the world in the camera coordinates system !
Reference
This library is developed and maintained by Gabriel Van Zandycke. If you use this repository, please consider citing my work.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file calib3d-2.3.2.tar.gz
.
File metadata
- Download URL: calib3d-2.3.2.tar.gz
- Upload date:
- Size: 16.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.56.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4bd0a608ffac62ee4db0ac5e17f66b7bb922feb981fd073e57e150392018dcb |
|
MD5 | 29d6014ed01559e4be26a8fd46c30baa |
|
BLAKE2b-256 | 7ccb1e3a2ed0a2959e47b21cdf7824682623302464856a1d00ff63f51885562f |