GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - cheind/plotgeom: A lightweight Python library for visualizing camera poses, fields of view, coordinate axes, and geometric primitives in 3D using Matplotlib.

BranchesTags
Open more actions menu

Latest commit

 

History

10 Commits
10 Commits

Folders and files

NameName
Last commit message
Last commit date
etc
etc
 
 
plotgeom
plotgeom
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
example.py
example.py
 
 
pyproject.toml
pyproject.toml
 
 
requirements.in
requirements.in
 
 

Repository files navigation

plotgeom

A lightweight Python library for visualizing camera poses, fields of view, coordinate axes, and geometric primitives in 3D using Matplotlib.

Installation

pip install git+https://github.com/cheind/plotgeom.git

Usage

This script renders the teaser image above.

import numpy as np
import matplotlib.pyplot as plt

# Main import
import plotgeom as pg


np.random.seed(112)

# Create figure
fig = plt.figure(figsize=(10, 10))

# Helper to create 3d axis
ax = pg.make_ax(fig=fig, proj="persp")

# Plot world axes
pg.plot_axes(
    ax=ax,
    rt=np.eye(4),
    scale=0.05,
    name="world",
)

# Plot a plane with limits
pg.plot_plane(
    ax=ax,
    rt=pg.random_pose(),
    extent_xy=(0.2, 0.1),
    name="pi",
    draw_normal=True,
    normal_scale=0.05,
)

# Plot a ray
pg.plot_ray(
    ax=ax,
    origin=[0, 0, 0],
    dir=[0.1, 0.1, 0],
    linestyle="--",
    linewidth=1.0,
    name="ray",
)


# Helper function to produce camera params
def random_camera_params():
    pose = pg.random_pose()
    K = np.array([[800, 0, 320], [0, 800, 240], [0, 0, 1]])
    shape = (480, 640)
    hfov, vfov = pg.fov_from_K(K, shape)
    image = pg.generate_chessboard_image((8, 6), square_size=80)
    image[:80, :80] = (0, 1, 1)
    return pose, (hfov, vfov), image


# Plot camera field of view
pose, (hfov, vfov), image = random_camera_params()
pg.plot_camera_fov(
    ax=ax,
    rt=pose,
    hfov=hfov,
    vfov=vfov,
    scale=0.1,
)

# Add an image to far plane
pg.plot_camera_image(
    ax=ax,
    rt=pose,
    hfov=hfov,
    vfov=vfov,
    image=image,
    scale=0.1,
    tex_res=(32, 32),
)

# Mark camera origin
pg.plot_axes(ax, pose, scale=0.05, name="a camera")

# Final preps
pg.set_axes_equal(ax)
pg.style_ax(ax)

# Show
plt.show()

About

A lightweight Python library for visualizing camera poses, fields of view, coordinate axes, and geometric primitives in 3D using Matplotlib.

Resources

Readme
Apache-2.0 license
Activity

Stars

2 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.