Skip to content

Instantly share code, notes, and snippets.

@sysuyl
sysuyl / make_vtk_camera.cpp
Created July 6, 2022 04:08 — forked from decrispell/make_vtk_camera.cpp
Convert standard camera intrinsic (focal length, principal point) and extrinsic parameters (rotation and translation) into a vtkCamera for rendering. Assume square pixels and 0 skew for now.
/**
* Convert standard camera intrinsic and extrinsic parameters to a vtkCamera instance for rendering
* Assume square pixels and 0 skew (for now).
*
* focal_len : camera focal length (units pixels)
* nx,ny : image dimensions in pixels
* principal_pt: camera principal point,
* i.e. the intersection of the principal ray with the image plane (units pixels)
* camera_rot, camera_trans : rotation, translation matrix mapping world points to camera coordinates
* depth_min, depth_max : needed to set the clipping range
@sysuyl
sysuyl / README.md
Created July 4, 2022 02:48 — forked from xaliphostes/README.md
Emscripten pthread lib in web worker

A small multi-threaded C++ library (so, does not include any main) compiled with emscripten and pthread running under the main thread in the browser, a web worker or using node.js.

Using a web browser

Running this lib in the main thread is fine but, obviously, block the main thread. Running it using a web worker leads no error with modification of the worker script (see below)

Using node.js

Run fine except that it prevents Node app from ever exiting.

@sysuyl
sysuyl / VTK_camera_intrinsics.py
Created July 4, 2022 02:46 — forked from benoitrosa/VTK_camera_intrinsics.py
Example for setting camera intrinsics in VTK using python
import vtk
import numpy as np
from vtk.util import numpy_support
import cv2
class Camera_VTK():
"""
Example class showing how to project a 3D world coordinate onto a 2D image plane using VTK