Skip to content

Camera Views

Use camera view structures to represent pinhole cameras in a 3D scene. Given camera locations, orientations, and field of view (intrinsics + extrinsics), Polyscope will draw a camera frame on the scene. Images quantities can be associated with the cameras and displayed on the camera frame. You can even align the interactive viewport with a selected camera.

Add an Image Quantity!

Camera views structures on their own are not so interesting; they are simplify displayed as a wireframe camera widget in the viewport.

Try adding an Image Quantitiy to the camera view. When image quantities are added to camera view structures, they gain the additional ability to be displayed in the camera’s frame.


#include "polyscope/camera_view.h"

// Create a camera view from parameters
polyscope::CameraParameters params(
                polyscope::CameraIntrinsics::fromFoVDegVerticalAndAspect(60, 2.),
                        glm::vec3{2., 2., 2.},      // root position
                        glm::vec3{-1., 0., 0.},   // look direction 
                        glm::vec3{0., 1., 0.})      // up direction

polyscope::CameraView* cam1 = polyscope::registerCameraView("cam1", params);

// Set some options for the camera view
cam1->setWidgetFocalLength(0.75);           // size of displayed widget (relative value)
cam1->setWidgetThickness(0.25);             // thickness of widget lines
glm::vec3 c = glm::vec3{0.25, 0.25, 0.25}; 
cam1->setWidgetColor(c);                    // color of widget lines

// Add an image to be displayed in the camera frame
int width = 600;
int height = 300;
std::vector<std::array<float, 3>> imageColor(width * height); // fill with your data
polyscope::ColorImageQuantity* im = 
    cam1->addColorImageQuantity("color image", width, height, imageColor, 


Registering a Camera View

Camera views are created from Camera Parameters.

Note that we do not specify an image resolution for the camera view. It can hold images of any resolution, as long as the aspect ratio is right.

CameraView* registerCameraView(std::string name, const CameraParameters& params)

Add a new camera view structure to Polyscope.

As with all structures, there is also getCameraView("name"), hasCameraView("name"), and removeCameraView("name").

Updating a Camera View

You can update the parameters associated with a camera view to move it within the scene after creation.

void CameraView::updateCameraParameters(const CameraParameters& newParams)

Update camera parameters.


See structure management for options common to all structures such as enabling/disabling, transforms, and transparency.

Parameter Meaning Getter Setter Persistent?
focal length size of rendered widget double getWidgetFocalLength() setWidgetFocalLength(double newVal, bool isRelative=true) yes
thickness rendered widget line thickness double getWidgetThickness() setWidgetThickness(double newVal) yes
color widget color glm::vec3 getWidgetColor() setWidgetColor(glm::vec3 newVal) yes

(All setters return this to support chaining. Structure options return a generic structure pointer, so chain them last.)