A Python library for camera-related utilities and lab tools.
Project description
CamLab
play with camera pose
pip install camlab
project a world-coordinate point to screen coordniate:
import numpy as np
from camlab import CameraObj
cam = CameraObj()
# init intrinsics
focal = 1111.1
w = 800
h = 800
cam.manual_init(focal, w, h)
# init extrinsics
extri = np.array(
[[-9.9990e-01, 4.1922e-03, -1.3346e-02, -5.3798e-02],
[-1.3989e-02, -2.9966e-01, 9.5394e-01, 3.8455e+00],
[-4.6566e-10, 9.5404e-01, 2.9969e-01, 1.2081e+00],
[0.0, 0.0, 0.0, 1.0]])
cam.load_extrinsic(extri)
# coordinates transformation
p_in_world = [0, 0, 0]
p_in_screen = cam.world2screen(p_in_world, to_int=True)
print(p_in_screen)
# [400, 400]
make a ray from a screen point:
import numpy as np
from camlab import CameraObj
intri = [[1111.0, 0.0, 400.0],
[0.0, 1111.0, 400.0],
[0.0, 0.0, 1.0]]
extri = np.array(
[[-9.9990e-01, 4.1922e-03, -1.3346e-02, -5.3798e-02],
[-1.3989e-02, -2.9966e-01, 9.5394e-01, 3.8455e+00],
[-4.6566e-10, 9.5404e-01, 2.9969e-01, 1.2081e+00],
[0.0, 0.0, 0.0, 1.0]])
cam_obj = CameraObj(intri)
cam_obj.load_extrinsic(extri)
p = (400, 400) # screen point
rayo, rayd = cam_obj.make_ray(p)
print(rayo, rayd)
# ray origin and ray direction
# (rayd - rayo) represents a point at the ray.
p_ = cam_obj.world2screen(rayd - rayo, to_int=True)
# reproject the ray point to screen
print(p_)
# (400, 400)
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
camlab-0.1.6.0.tar.gz
(7.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file camlab-0.1.6.0.tar.gz.
File metadata
- Download URL: camlab-0.1.6.0.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d11c7bb72bd30b041be827da26eb2545e050db02a9084a3876ab501b4f5fc6e
|
|
| MD5 |
0961b8afbe4929a698e54c8459fcd37a
|
|
| BLAKE2b-256 |
f5ee7ec3e2f4e1fd28ac82f16078e26f769de8574d44b69190b24adce866bc8c
|
File details
Details for the file camlab-0.1.6.0-py3-none-any.whl.
File metadata
- Download URL: camlab-0.1.6.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2206074e7191f3ea4e2ab674e8c85442919642095a7409b1112ec4dcdebdbd71
|
|
| MD5 |
debf7ee28a2a179d5ecb87c40aa3f172
|
|
| BLAKE2b-256 |
d215e62430e7f5e04079bfa4f867a72df888b35808f784b268bee8d1ec3c779d
|