Skip to content

PyEllCV: tools for ellipses/ellipsoids manipulation and camera pose estimation

License

Notifications You must be signed in to change notification settings

zinsmatt/pyellcv

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

PyEllCV


Warning

The code has been moved to: https://gitlab.inria.fr/tangram/pyellcv


This repository regroups tools to manipulate ellipses and ellipsoids in the context of camera pose estimation. Most of the code is in python, but some parts were written in C++ for efficiency purposes.

This library is used in combination with 3D-aware predicted ellipses for object-based visual localization in 3D-Aware-Ellipses-for-Visual-Localization

Installation

The library can be build with the following commands:

python -m pip install 'git+https://gitlab.inria.fr/tangram/pyellcv.git'
# (add --user if you don't have permission)

# Or, to install it from a local clone:
git clone --recursive  https://gitlab.inria.fr/tangram/pyellcv.git
python -m pip install -e ./pyellcv

Example

import cv2
import numpy as np
from ellcv.types import Ellipsoid
from ellcv.utils import generate_random_scene, generate_random_camera, \
                        generate_K, bbox_from_ellipse
from ellcv.visu import draw_ellipse, draw_bbox


# Create a scene of ellipsoids
N = 4
scene = generate_random_scene(N, axes_range=[0.3, 1.5], position_range=[-3.0, 3.0])

# Define the camera
W, H = 640, 480
o, p = generate_random_camera(dist_range=[10.0, 15.0], target_range=[-0.5, 0.5])
K = generate_K(500, W/2, H/2)
P = K @ np.hstack((o.T, -o.T@p.reshape((3, 1))))

# Project and display
img = np.zeros((H, W, 3), dtype=np.uint8)
for ell in scene:
    ellipse = ell.project(P)
    bbox = bbox_from_ellipse(ellipse)
    draw_bbox(img, bbox, color=(255, 0, 0))
    draw_ellipse(img, ellipse, color=(0, 255, 0))
cv2.imshow("viz", img)
cv2.waitKey()

References

About

PyEllCV: tools for ellipses/ellipsoids manipulation and camera pose estimation

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published