play with camera poses
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.3.0.tar.gz
(6.0 kB
view details)
Built Distribution
File details
Details for the file camlab-0.1.3.0.tar.gz
.
File metadata
- Download URL: camlab-0.1.3.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9cb606b46dfd986377730c268684eb362fe533ef731362ee29b17ecba33701fc |
|
MD5 | ff2434fbd58cb1b8e5ded6fc72e6d935 |
|
BLAKE2b-256 | 98525def330f51f4b5826fcb578bf8a008abd7e4cb13a0b0056f750a98d73fea |
File details
Details for the file camlab-0.1.3.0-py3-none-any.whl
.
File metadata
- Download URL: camlab-0.1.3.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15f154c93c9d5b4ca073cce2a17759a31947c8aff8d6c5b8557ae283ddc05197 |
|
MD5 | 8cd3a80596db6305394c2fbbd6e9404c |
|
BLAKE2b-256 | e4c1fa97bbdf31d9b2b1ed2af854f266ca399ea60002a154aed3afa71b9b2ea4 |