wolfhece.lazviewer.viewer.viewer
Module Contents
- class wolfhece.lazviewer.viewer.viewer.viewer(*args, **kwargs)[source]
-
- set(**kwargs)[source]
Sets viewer property
Property Name
Value Type
Description
bg_color
4 x float32
Background color in RGBA [0, 1]
bg_color_top
4 x float32
Top background color
bg_color_bottom
4 x float32
Bottom background color
color_map
? x 4 x float32
Color map; array of RGBA’s [0, 1]
color_map_scale
2 x float32
Color map scaling interval
curr_attribute_id
uint
Current attribute set index
floor_level
float32
Floor z-level
floor_color
4 x float32
Floor color in RGBA [0, 1]
lookat
3 x float32
Camera look-at position
phi
float32
Camera azimuthal angle (radians)
point_size
float32
Point size in world space
r
float32
Camera distance to look-at point
selected
? x uint
Indices of selected points
show_grid
bool
Show floor grid
show_info
bool
Show information text overlay
show_axis
bool
Show axis / look-at cursor
theta
float32
Camera elevation angle (radians)
(phi, theta, r) are spherical coordinates specifying camera position relative to the look at position.
(right, up, view) are orthogonal vectors forming the camera coordinate frame, where view is pointed away from the look at position, and view is the cross product of up with right
Examples
>>> v = pptk.viewer(xyz) >>> v.set(point_size = 0.01)
- get(prop_name)[source]
Gets viewer property
Property Name
Return Type
Description
curr_atribute_id
uint
Current attribute set index
eye
3 x float64
Camera position
lookat
3 x float64
Camera look-at position
mvp
4 x 4 float64
num_points
uint
Number of points loaded
num_attributes
uint
Number of attribute sets loaded
phi
float64
Camera azimuthal angle (radians)
r
float64
Camera distance to look-at point
right
3 x float64
Camera Right vector
selected
? x int32
Indices of selected points
theta
float64
Camera elevation angle (radians)
up
3 x float64
Camera up vector
view
3 x float64
Camera view vector
Examples
>>> v = pptk.viewer(xyz) >>> v.get('selected')
- attributes(*attr)[source]
Loads point attributes
The loaded attributes are used to color the currently loaded point cloud. Supposing n points loaded, this function accepts attributes of the following forms:
scalars: 1-d array of length 1 or n
RGB colors: 2-d array of shape (1, 3) or (n, 3)
RGBA colors: 2-d array of shape (1, 4) or (n, 4)
Passing in no arguments clears all existing attribute sets and colors all points white. Cycle through attribute sets via ‘[’ and ‘]’ keys.
Examples:
>>> xyz = pptk.rand(100, 3) >>> v = pptk.viewer(xyz) >>> attr1 = pptk.rand(100) # 100 random scalars >>> attr2 = pptk.rand(100, 3) # 100 random RGB colors >>> attr3 = pptk.rand(100, 4) # 100 random RGBA colors >>> attr4 = pptk.rand(1, 1) # 1 random scalar >>> attr5 = pptk.rand(1, 3) # 1 random RGB color >>> attr6 = pptk.rand(1, 4) # 1 random RGBA color >>> v.attributes(attr1, attr2, attr3, attr4, attr6)
- color_map(c, scale=None)[source]
Specifies how scalar attributes are used to color points in the viewer.
Input c is expected to be an array of n RGB (or RGBA) vectors (i.e. c is a n x 3 or n x 4 numpy array). Upon return, scalar values equal to scale 0 are colored with c[0], scale[1] with c[-1], and scalars in between appropriately interpolated. If scale is None, scale is automatically set as the minimum and maximum scalar values in the current attribute set.
Alternatively, one can choose from a number of preset color maps by passing the corresponding string instead.
Preset color maps
‘jet’ (default)
‘hsv’
‘hot’
‘cool’
‘spring’
‘summer’
‘autumn’
‘winter’
‘gray’
Examples
>>> xyz = np.c_[np.arange(10), np.zeros(10), np.zeros(10)] >>> scalars = np.arange(10) >>> v = pptk.viewer(xyz, scalars) >>> v.color_map('cool', scale=[0, 5]) >>> v.color_map([[0, 0, 0], [1, 1, 1]])
- capture(filename)[source]
Take screen shot of current view and save to filename
Examples:
>>> v = pptk.viewer(xyz) >>> v.capture('screenshot.png')
- play(poses, ts=[], tlim=[-numpy.inf, numpy.inf], repeat=False, interp='cubic_natural')[source]
Plays back camera path animation specified by poses
- Parameters:
poses – Key poses. e.g. a list of 6-tuples (x, y, z, phi, theta, r) poses, or anything convertible to a 6-column array by np.array
ts (optional) – Key pose times. If unspecified key poses are placed at 1 second intervals.
tlim (optional) – Play back time range (in seconds)
repeat (optional) – Toggles infinite play back loop. Works well with interp=’cubic_periodic’.
interp (optional) – Interpolation method. Should be one of ‘constant’, ‘linear’, ‘cubic_natural’, or ‘cubic_periodic’.
Examples:
Rotate camera about origin at 1/8 Hz.
>>> poses = [] >>> poses.append([0, 0, 0, 0 * np.pi/2, np.pi/4, 5]) >>> poses.append([0, 0, 0, 1 * np.pi/2, np.pi/4, 5]) >>> poses.append([0, 0, 0, 2 * np.pi/2, np.pi/4, 5]) >>> poses.append([0, 0, 0, 3 * np.pi/2, np.pi/4, 5]) >>> poses.append([0, 0, 0, 4 * np.pi/2, np.pi/4, 5]) >>> v.play(poses, 2 * np.arange(5), repeat=True, interp='linear')
- record(folder, poses, ts=[], tlim=[-numpy.inf, numpy.inf], interp='cubic_natural', shutter_speed=numpy.inf, fps=24, prefix='frame_', ext='png')[source]
Records camera animation to a sequence of images. Usage of this method is very similar to viewer.play(…).
- Parameters:
folder – Folder to which images are saved
poses – Same as in
pptk.viewer.play()
ts – Same as in
pptk.viewer.play()
tlim – Same as in
pptk.viewer.play()
interp – Same as in
pptk.viewer.play()
fps – Frames per second
prefix – Resulting image file names are prefixed with this string
ext – Image format
Examples
Assuming poses defined as in the example for :meth:pptk.viewer.play
>>> mkdir 'recording' >>> v.record('recording', poses)
Tip: Uses ffmpeg to generate a video from the resulting image sequence
>>> ffmpeg -i "frame_%03d.png" -c:v mpeg4 -qscale:v 0 -r 24 output.mp4