Skip to main content

dreifus lifts your 3D camera experience and facilitates computer vision applications

Project description

dreifus

OpenCV, OpenGL, Pytorch3D, ... you never know which camera coordinate convention you are currently using?
You always have to try invert() on your "pose" matrices because you never know whether they are cam2world or world2cam?
The dreifus library is what you need!
dreifus (German for tripod) assists you in dealing with 3D cameras in Python.

1. Installation

pip install dreifus

2. Usage

2.1. Extrinsic (Pose) matrices

Translating between coordinate conventions made easy:

from dreifus.matrix import Pose, CameraCoordinateConvention, PoseType

# wrap some 4x4 extrinsic matrix
# Default assumed coordinate convention: OPEN_CV
# Default assumed pose type: WORLD_2_CAM 
pose = Pose(some_extrinsic_matrix, pose_type=..., camera_coordinate_convention=...)

# Translate between coordinate conventions
pose.change_camera_coordinate_convention(CameraCoordinateConvention.OPEN_GL)

# Ensure your pose transforms into the direction you expect
pose.change_pose_type(PoseType.CAM_2_WORLD)

2.2. Intrinsics

from dreifus.matrix import Intrinsics

intrinsics = Intrinsics(fx, fy, cx, cy)

# Adapt your intrinsics to images downscaled by a factor of 2x
intrinsics.rescale(0.5)

# Adapt your intrinsics to an image cropped at (50, 50) left-top
intrinsics.crop(50, 50)

3. Visualization

The visualization tools will automatically interpret your camera poses correctly, as long as you specified camera_coordinate_convention and pose_type correctly.

import pyvista as pv
from dreifus.pyvista import add_coordinate_axes, add_camera_frustum

pose = Pose(...)  # Some extrinsics
intrinsics = Intrinsics(...)  # Some intrinsics
image = ...  # Some images taken from that view

p = pv.Plotter()

add_coordinate_axes(p)
add_camera_frustum(p, pose, intrinsics, image=image)

p.show()

Render a pyvista scene from a specific camera:

import pyvista as pv
from dreifus.pyvista import render_from_camera

p = pv.Plotter(window_size=[IMG_W, IMG_H], off_screen=True)
p.background_color = (0, 0, 0, 0)

image = render_from_camera(p, pose, intrinsics)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dreifus-0.1.22.tar.gz (36.6 kB view details)

Uploaded Source

Built Distribution

dreifus-0.1.22-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

Details for the file dreifus-0.1.22.tar.gz.

File metadata

  • Download URL: dreifus-0.1.22.tar.gz
  • Upload date:
  • Size: 36.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.7

File hashes

Hashes for dreifus-0.1.22.tar.gz
Algorithm Hash digest
SHA256 e4eb0aeefb2c860d8408dd1e8ca0582838c9d6f8bc972a3f7fab68e1b1d8d9ca
MD5 c9ea2ef6b6d386f05b277c0a8b973860
BLAKE2b-256 95642273a7241323a0268c0f786c81f9727e2376ee38e31cd9fe3e38c029da6b

See more details on using hashes here.

File details

Details for the file dreifus-0.1.22-py3-none-any.whl.

File metadata

  • Download URL: dreifus-0.1.22-py3-none-any.whl
  • Upload date:
  • Size: 38.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.7

File hashes

Hashes for dreifus-0.1.22-py3-none-any.whl
Algorithm Hash digest
SHA256 1ed5a4f5a727b167eced8fe1660911d4c3ce8fc80119aed1ec4c9e712e303e83
MD5 2adbb04ace1a6043033cc7b398703f0b
BLAKE2b-256 6d1e40fa758a1fb18e429103229cc378e2bcd08094fe7e4a8f7daf829682bed7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page