Calcam can be used to render images of a CAD model from a calibrated camera’s point of view. This includes all lens distortion in the camera model, so for calibrated real camera images, the rendered images should match exactly with the camera images. The appearance of the CAD model (colour, wireframe, which parts are loaded etc) is configured using the features of the CAD Models class.
For examples of using these features, see the Examples page.
render_cam_view(cadmodel, calibration, extra_actors=, filename=None, oversampling=1, aa=1, transparency=False, verbose=True, coords='display', interpolation='cubic')¶
Render an image of a given CAD model from the point of view of a given calibration.
This function uses off-screen OpenGL rendering which fails above some image dimension which depends on the system. The workaround for this is that above a render dimension set by
calcam.render.max_render_dimension, the image is rendered at lower resolution and then scaled up using nearest-neighbour scaling. For this reason, when rendering very high resolution images, the rendered image quality may be lower than expected.
- cadmodel (calcam.CADModel) – CAD model of scene
- calibration (calcam.Calibration) – Calibration whose point-of-view to render from.
- extra_actors (list of vtk.vtkActor) – List containing any additional vtkActors to add to the scene in addition to the CAD model.
- filename (str) – Filename to which to save the resulting image. If not given, no file is saved.
- oversampling (float) – Used to render the image at higher (if > 1) or lower (if < 1) resolution than the calibrated camera. Must be an integer if > 1 or if <1, 1/oversampling must be a factor of both image width and height.
- aa (int) – Anti-aliasing factor, 1 = no anti-aliasing.
- transparency (bool) – If true, empty areas of the image are set transparent. Otherwise they are black.
- verbose (bool) – Whether to print status updates while rendering.
- coords (str) – Either
Original, the image orientation in which to return the image.
- interpolation (str) – Either
cubic, inerpolation used when applying lens distortion.
Array containing the rendered 8-bit per channel RGB (h x w x 3) or RGBA (h x w x 4) image. Also saves the result to disk if the filename parameter is set.
render_unfolded_wall(cadmodel, calibrations=, labels=, colours=None, cal_opacity=0.7, w=None, theta_start=90, phi_start=0, progress_callback=<bound method LoopProgPrinter.update of <calcam.misc.LoopProgPrinter object at 0x7f982d0bae80>>, cancel=<function <lambda>>, theta_steps=18, phi_steps=360, r_equiscale=None, extra_actors=, filename=None)¶
Render an image of the tokamak wall “flattened” out. Creates an image where the horizontal direction is the toroidal direction and vertical direction is poloidal.
- cadmodel (calcam.CADModel) – CAD Model to render. The CAD model must have an R, Z wall contour embedded in it (this is ued in the wall flattening calculations), which can be added in the CAD model editor.
- calibrations (list of calcam.Calibration) – List of camera calibrations to visualise on the wall. If provided, each camera calibration will be shown on the image as a colour shaded area indicating which parts of the wall the camera can see.
- labels (list of strings) – List of strings containing legend text for the calibrations. If not provided, no legend will be added to the image. If provided, must be the same length as the list of calibrations.
- colours (list of tuple) – List of 3-element tuples specifying the colours to use for the displayed calibrations. Each element of the list must have the format (R, G, B) where 0 <= R, G and B <= 1.
- cal_opcity (float) – How opaque to make the wall shading when showing calibrations. 0 = completely invisible, 1 = complete opaque. Default is 0.7.
- w (int) – Desired approximate width of the rendered image in pixels. If not given, the image width will be chosen to give a scale of about 2mm/pixel.
- theta_start (float) – Poloidal angle in degrees to “split” the image i.e. this angle will be at the top and bottom of the image. 0 corresponds to the outboard midplane. Default is 90 degrees i.e. the top of the machine.
- phi_start (float) – Toroidal angle in degrees to “split” the image i.e. this angle will be at the left and right of the image.
- progress_callback (callable) – Used for GUI integration - a callable which will be called with the fraction of the render completed. Default is to print an estimate of how long the render will take.
- cancel (ref to bool) – Used for GUI integration - a booleam which starts False, and if set to True during the calculation, the function will stop and return.
- theta_steps (int) – Number of tiles to use in the poloidal direction. The default is optimised for image quality so it is advised not to change this. Effects the calculation time linearly.
- phi_steps (int) – Number of tiles to use in the toroidal direction. The default is optimised for image quality so it is advised not to change this. Effects the calculation time linearly.
- r_equiscale (float) – Due to the unwrapping of the torus to a rectangle, objects will appear stretched or compressed depending on their major radius. This parameter sets at what major radius objects appear at their correct shape. If not specified, the centre of the wall contour is used so objects on the inboard side appear “fatter” than in real life and objects on the outboard side will be “skinnier”.
- filename (string) – If provided, the result will be saved to an image file with this name in addition to being returned as an array. Must include file extension.
A NumPy array of size ( h * w * 3 ) and dtype uint8 containing the RGB image result.