Skip to content

Camera class

Camera related objects and classes.

Camera(clip: Clip, data: george.TVPCamera | None = None)

Bases: pytvpaint.utils.Refreshable

The Camera class represents the camera in a TVPaint clip.

There's only one camera in the clip so instantiating multiple objects of this class won't create cameras.

Source code in pytvpaint/camera.py
27
28
29
30
31
def __init__(self, clip: Clip, data: george.TVPCamera | None = None) -> None:
    super().__init__()
    self._clip = clip
    self._data: george.TVPCamera = data or george.tv_camera_info_get()
    self._points: list[CameraPoint] = []

clip: Clip property

The camera's clip.

layer: Layer | None property

The layer associated to this camera.

Note

This function is only available in TVPaint version 12 and above.

Raises:

Type Description
NotImplemented

if used in tvpaint version inferior to 12

points: Iterator[CameraPoint] property

Iterator for the CameraPoint objects of the camera.

Warning

Property Camera.points usually only returns the first camera point and nothing else, this is a TVPaint limitation, we advise using Camera.get_point_data_at() to get more accurate results.

refresh_on_call = True instance-attribute

refresh() -> None

Refreshes the camera data.

Source code in pytvpaint/camera.py
33
34
35
36
37
def refresh(self) -> None:
    """Refreshes the camera data."""
    if not self.refresh_on_call and self._data:
        return
    self._data = george.tv_camera_info_get()

make_current() -> None

Makes the parent clip the current one, thereby making sure the correct camera will be set.

Source code in pytvpaint/camera.py
48
49
50
def make_current(self) -> None:
    """Makes the parent clip the current one, thereby making sure the correct camera will be set."""
    self._clip.make_current()

width(value: int) -> None

The sensor width of the camera.

Source code in pytvpaint/camera.py
58
59
60
61
62
@width.setter
@set_as_current
def width(self, value: int) -> None:
    """The sensor width of the camera."""
    george.tv_camera_info_set(width=value, height=self.height)

height(value: int) -> None

The sensor height of the camera.

Source code in pytvpaint/camera.py
70
71
72
73
74
@height.setter
@set_as_current
def height(self, value: int) -> None:
    """The sensor height of the camera."""
    george.tv_camera_info_set(height=value, width=self.width)

fps(value: float) -> None

The framerate of the camera.

Warning

DEPRECATED: Property Camera.fps is not recommended for use in TVP 12, use Project.fps instead. For now, in TVP 12, it always returns 1.0 but will be removed in future versions.

Source code in pytvpaint/camera.py
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
@fps.setter
@set_as_current
@george.deprecated_warning(
    msg="Property `Camera.fps` is not recommended for use in TVP 12, use Project.fps instead. "
    "For now, in TVP 12, it always sets 1.0 but will be removed in future versions."
)
def fps(self, value: float) -> None:
    """The framerate of the camera.

    Warning:
        DEPRECATED: Property `Camera.fps` is not recommended for use in TVP 12, use Project.fps instead.
        For now, in TVP 12, it always returns 1.0 but will be removed in future versions.
    """
    george.tv_camera_info_set(
        self.width,
        self.height,
        self.field_order,
        frame_rate=value,
    )

pixel_aspect_ratio(value: float) -> None

The pixel aspect ratio of the camera.

Source code in pytvpaint/camera.py
117
118
119
120
121
122
123
124
125
126
127
@pixel_aspect_ratio.setter
@set_as_current
def pixel_aspect_ratio(self, value: float) -> None:
    """The pixel aspect ratio of the camera."""
    george.tv_camera_info_set(
        self.width,
        self.height,
        self.field_order,
        self.fps,
        pixel_aspect_ratio=value,
    )

anti_aliasing() -> int

The antialiasing value of the camera.

Warning

DEPRECATED: Property Camera.anti_aliasing not longer exists in TVP 12. For now, in TVP 12, it always returns 1 but will be removed in future versions.

Source code in pytvpaint/camera.py
129
130
131
132
133
134
135
136
137
138
139
140
141
142
@refreshed_property
@set_as_current
@george.deprecated_warning(
    msg="Property `Camera.anti_aliasing` not longer exists in TVP 12, "
    "for now, in TVP 12, it always returns 1 but will be removed in future versions."
)
def anti_aliasing(self) -> int:
    """The antialiasing value of the camera.

    Warning:
        DEPRECATED: Property `Camera.anti_aliasing` not longer exists in TVP 12.
        For now, in TVP 12, it always returns 1 but will be removed in future versions.
    """
    return self._data.anti_aliasing

field_order(value: george.FieldOrder) -> None

The field order of the camera.

Source code in pytvpaint/camera.py
150
151
152
153
154
@field_order.setter
@set_as_current
def field_order(self, value: george.FieldOrder) -> None:
    """The field order of the camera."""
    george.tv_camera_info_set(self.width, self.height, field_order=value)

insert_point(index: int, x: int, y: int, angle: int, scale: float) -> CameraPoint

Insert a new point in the camera path.

Source code in pytvpaint/camera.py
170
171
172
173
174
175
176
177
178
179
180
@set_as_current
def insert_point(
    self,
    index: int,
    x: int,
    y: int,
    angle: int,
    scale: float,
) -> CameraPoint:
    """Insert a new point in the camera path."""
    return CameraPoint.new(self, index, x, y, angle, scale)

get_point_data_at(position: float) -> InterpolationCameraPoint

Get the points data interpolated at the provided position (between 0 and 1).

Source code in pytvpaint/camera.py
201
202
203
204
@set_as_current
def get_point_data_at(self, position: float) -> InterpolationCameraPoint:
    """Get the points data interpolated at the provided position (between 0 and 1)."""
    return InterpolationCameraPoint(position, self, InterpolationCameraPoint.get_point_data_at(position))

get_point_data_at_frame(frame: int) -> FrameCameraPoint

Get the points data interpolated at the specified frame in the clip.

Source code in pytvpaint/camera.py
206
207
208
209
210
@george.min_version_compatible(min_version="12")
@set_as_current
def get_point_data_at_frame(self, frame: int) -> FrameCameraPoint:
    """Get the points data interpolated at the specified frame in the clip."""
    return FrameCameraPoint(frame, self, FrameCameraPoint.get_point_data_at(self.clip, frame))

remove_point(index: int) -> None

Remove a point at the provided index.

Source code in pytvpaint/camera.py
212
213
214
215
216
217
218
219
@set_as_current
def remove_point(self, index: int) -> None:
    """Remove a point at the provided index."""
    try:
        point = next(p for i, p in enumerate(self.points) if i == index)
        point.remove()
    except StopIteration:
        pass

CameraPoint(index: int, camera: Camera, data: george.TVPCameraPoint | None = None)

Bases: pytvpaint.utils.Removable

A CameraPoint is a point on the camera path.

You can use them to animate the camera movement.

Source code in pytvpaint/camera.py
228
229
230
231
232
233
234
235
236
237
def __init__(
    self,
    index: int,
    camera: Camera,
    data: george.TVPCameraPoint | None = None,
) -> None:
    super().__init__()
    self._index: int = index
    self._camera: Camera = camera
    self._data = data or george.tv_camera_enum_points(self._index)

index: int property

The index of the point in the path.

camera: Camera property

The camera instance it belongs to.

width: float property

The width of the camera at the point.

height: float property

The height of the camera at the point.

refresh_on_call = True instance-attribute

is_removed: bool property

Checks if the object is removed by trying to refresh its data.

Returns:

Name Type Description
bool bool

whether if it was removed or not

refresh() -> None

Refreshes the camera point data.

Source code in pytvpaint/camera.py
239
240
241
242
243
244
def refresh(self) -> None:
    """Refreshes the camera point data."""
    super().refresh()
    if not self.refresh_on_call and self._data:
        return
    self._data = george.tv_camera_enum_points(self._index)

data() -> george.TVPCameraPoint

Returns the raw data of the point.

Source code in pytvpaint/camera.py
258
259
260
261
@refreshed_property
def data(self) -> george.TVPCameraPoint:
    """Returns the raw data of the point."""
    return self._data

x(value: float) -> None

The x coordinate of the point.

Source code in pytvpaint/camera.py
278
279
280
281
282
283
284
285
286
287
288
@x.setter
def x(self, value: float) -> None:
    """The x coordinate of the point."""
    current_data = george.tv_camera_enum_points(self.index)
    george.tv_camera_set_point(
        self.index,
        x=value,
        y=current_data.y,
        angle=current_data.angle,
        scale=current_data.scale,
    )

y(value: float) -> None

The y coordinate of the point.

Source code in pytvpaint/camera.py
295
296
297
298
299
300
301
302
303
304
305
@y.setter
def y(self, value: float) -> None:
    """The y coordinate of the point."""
    current_data = george.tv_camera_enum_points(self.index)
    george.tv_camera_set_point(
        self.index,
        x=current_data.x,
        y=value,
        angle=current_data.angle,
        scale=current_data.scale,
    )

angle(value: float) -> None

The angle of the camera at the point.

Source code in pytvpaint/camera.py
312
313
314
315
316
317
318
319
320
321
322
@angle.setter
def angle(self, value: float) -> None:
    """The angle of the camera at the point."""
    current_data = george.tv_camera_enum_points(self.index)
    george.tv_camera_set_point(
        self.index,
        x=current_data.x,
        y=current_data.y,
        angle=value,
        scale=current_data.scale,
    )

scale(value: float) -> None

Source code in pytvpaint/camera.py
329
330
331
332
333
334
335
336
337
338
@scale.setter
def scale(self, value: float) -> None:
    current_data = george.tv_camera_enum_points(self.index)
    george.tv_camera_set_point(
        self.index,
        x=current_data.x,
        y=current_data.y,
        angle=current_data.angle,
        scale=value,
    )

new(camera: Camera, index: int, x: int, y: int, angle: int, scale: float) -> CameraPoint classmethod

Create a new point and add it to the camera path at the provided index.

Source code in pytvpaint/camera.py
350
351
352
353
354
355
356
357
358
359
360
361
362
@classmethod
def new(
    cls,
    camera: Camera,
    index: int,
    x: int,
    y: int,
    angle: int,
    scale: float,
) -> CameraPoint:
    """Create a new point and add it to the camera path at the provided index."""
    george.tv_camera_insert_point(index, x, y, angle, scale)
    return cls(index, camera)

remove() -> None

Remove the camera point.

Warning

the point instance won't be usable after this call

Source code in pytvpaint/camera.py
364
365
366
367
368
369
370
371
def remove(self) -> None:
    """Remove the camera point.

    Warning:
        the point instance won't be usable after this call
    """
    george.tv_camera_remove_point(self.index)
    self.mark_removed()

mark_removed() -> None

Marks the object as removed and is therefor not usable.

Source code in pytvpaint/utils.py
 98
 99
100
def mark_removed(self) -> None:
    """Marks the object as removed and is therefor not usable."""
    self._is_removed = True

InterpolationCameraPoint(interpolation_point: float, camera: Camera, data: george.TVPCameraPoint | None = None)

Bases: pytvpaint.camera.CameraPoint

A Read-Only CameraPoint.

You can use them to animate the camera movement.

Source code in pytvpaint/camera.py
380
381
382
383
384
385
386
387
def __init__(
    self,
    interpolation_point: float,
    camera: Camera,
    data: george.TVPCameraPoint | None = None,
) -> None:
    super().__init__(-1, camera, data)
    self._interpolation_point = interpolation_point

interpolation_point: float property

Interpolation point (between 0 and 1) for this CameraPoint.

refresh_on_call = True instance-attribute

is_removed: bool property

Checks if the object is removed by trying to refresh its data.

Returns:

Name Type Description
bool bool

whether if it was removed or not

index: int property

The index of the point in the path.

camera: Camera property

The camera instance it belongs to.

width: float property

The width of the camera at the point.

height: float property

The height of the camera at the point.

get_point_data_at(position: float) -> george.TVPCameraPoint classmethod

Get the points data interpolated at the provided position (between 0 and 1).

Source code in pytvpaint/camera.py
398
399
400
401
402
@classmethod
def get_point_data_at(cls, position: float) -> george.TVPCameraPoint:
    """Get the points data interpolated at the provided position (between 0 and 1)."""
    position = max(0.0, min(position, 1.0))
    return george.tv_camera_interpolation(position)

refresh() -> None

Refreshes the camera point data at the interpolation point.

Source code in pytvpaint/camera.py
404
405
406
407
408
def refresh(self) -> None:
    """Refreshes the camera point data at the interpolation point."""
    if not self.refresh_on_call and self._data:
        return
    self._data = self.get_point_data_at(self._interpolation_point)

remove() -> None

Remove the camera point.

Warning

the FrameCameraPoint instance is read-only and cannot be removed as it doesn't really exist

Source code in pytvpaint/camera.py
410
411
412
413
414
415
416
417
418
419
def remove(self) -> None:
    """Remove the camera point.

    Warning:
        the FrameCameraPoint instance is read-only and cannot be removed as  it doesn't really exist
    """
    log.warning(
        "Read-Only InterpolationCameraPoint cannot be deleted as it doesn't really exist, ignoring request."
    )
    return

mark_removed() -> None

Marks the object as removed and is therefor not usable.

Source code in pytvpaint/utils.py
 98
 99
100
def mark_removed(self) -> None:
    """Marks the object as removed and is therefor not usable."""
    self._is_removed = True

data() -> george.TVPCameraPoint

Returns the raw data of the point.

Source code in pytvpaint/camera.py
258
259
260
261
@refreshed_property
def data(self) -> george.TVPCameraPoint:
    """Returns the raw data of the point."""
    return self._data

x(value: float) -> None

The x coordinate of the point.

Source code in pytvpaint/camera.py
278
279
280
281
282
283
284
285
286
287
288
@x.setter
def x(self, value: float) -> None:
    """The x coordinate of the point."""
    current_data = george.tv_camera_enum_points(self.index)
    george.tv_camera_set_point(
        self.index,
        x=value,
        y=current_data.y,
        angle=current_data.angle,
        scale=current_data.scale,
    )

y(value: float) -> None

The y coordinate of the point.

Source code in pytvpaint/camera.py
295
296
297
298
299
300
301
302
303
304
305
@y.setter
def y(self, value: float) -> None:
    """The y coordinate of the point."""
    current_data = george.tv_camera_enum_points(self.index)
    george.tv_camera_set_point(
        self.index,
        x=current_data.x,
        y=value,
        angle=current_data.angle,
        scale=current_data.scale,
    )

angle(value: float) -> None

The angle of the camera at the point.

Source code in pytvpaint/camera.py
312
313
314
315
316
317
318
319
320
321
322
@angle.setter
def angle(self, value: float) -> None:
    """The angle of the camera at the point."""
    current_data = george.tv_camera_enum_points(self.index)
    george.tv_camera_set_point(
        self.index,
        x=current_data.x,
        y=current_data.y,
        angle=value,
        scale=current_data.scale,
    )

scale(value: float) -> None

Source code in pytvpaint/camera.py
329
330
331
332
333
334
335
336
337
338
@scale.setter
def scale(self, value: float) -> None:
    current_data = george.tv_camera_enum_points(self.index)
    george.tv_camera_set_point(
        self.index,
        x=current_data.x,
        y=current_data.y,
        angle=current_data.angle,
        scale=value,
    )

new(camera: Camera, index: int, x: int, y: int, angle: int, scale: float) -> CameraPoint classmethod

Create a new point and add it to the camera path at the provided index.

Source code in pytvpaint/camera.py
350
351
352
353
354
355
356
357
358
359
360
361
362
@classmethod
def new(
    cls,
    camera: Camera,
    index: int,
    x: int,
    y: int,
    angle: int,
    scale: float,
) -> CameraPoint:
    """Create a new point and add it to the camera path at the provided index."""
    george.tv_camera_insert_point(index, x, y, angle, scale)
    return cls(index, camera)

FrameCameraPoint(frame: int, camera: Camera, data: george.TVPCameraPoint | None = None)

Bases: pytvpaint.camera.CameraPoint

A Read-Only CameraPoint.

You can use them to animate the camera movement.

Source code in pytvpaint/camera.py
428
429
430
431
432
433
434
435
def __init__(
    self,
    frame: int,
    camera: Camera,
    data: george.TVPCameraPoint | None = None,
) -> None:
    super().__init__(-1, camera, data)
    self._frame = frame

frame: float property

Frame for this CameraPoint.

refresh_on_call = True instance-attribute

is_removed: bool property

Checks if the object is removed by trying to refresh its data.

Returns:

Name Type Description
bool bool

whether if it was removed or not

index: int property

The index of the point in the path.

camera: Camera property

The camera instance it belongs to.

width: float property

The width of the camera at the point.

height: float property

The height of the camera at the point.

get_point_data_at(clip: Clip, frame: int) -> george.TVPCameraPoint classmethod

Get the points data interpolated at the specified frame in the clip.

Source code in pytvpaint/camera.py
446
447
448
449
450
@classmethod
def get_point_data_at(cls, clip: Clip, frame: int) -> george.TVPCameraPoint:
    """Get the points data interpolated at the specified frame in the clip."""
    real_frame = frame - clip.project.start_frame
    return george.tv_camera_info_frame(real_frame)

refresh() -> None

Refreshes the camera point data at the frame.

Source code in pytvpaint/camera.py
452
453
454
455
456
def refresh(self) -> None:
    """Refreshes the camera point data at the frame."""
    if not self.refresh_on_call and self._data:
        return
    self._data = self.get_point_data_at(self.camera.clip, self._frame)

remove() -> None

Remove the camera point.

Warning

the FrameCameraPoint instance is read-only and cannot be removed as it doesn't really exist

Source code in pytvpaint/camera.py
458
459
460
461
462
463
464
465
def remove(self) -> None:
    """Remove the camera point.

    Warning:
        the FrameCameraPoint instance is read-only and cannot be removed as  it doesn't really exist
    """
    log.warning("Read-Only FrameCameraPoint cannot be deleted as it doesn't really exist, ignoring request.")
    return

mark_removed() -> None

Marks the object as removed and is therefor not usable.

Source code in pytvpaint/utils.py
 98
 99
100
def mark_removed(self) -> None:
    """Marks the object as removed and is therefor not usable."""
    self._is_removed = True

data() -> george.TVPCameraPoint

Returns the raw data of the point.

Source code in pytvpaint/camera.py
258
259
260
261
@refreshed_property
def data(self) -> george.TVPCameraPoint:
    """Returns the raw data of the point."""
    return self._data

x(value: float) -> None

The x coordinate of the point.

Source code in pytvpaint/camera.py
278
279
280
281
282
283
284
285
286
287
288
@x.setter
def x(self, value: float) -> None:
    """The x coordinate of the point."""
    current_data = george.tv_camera_enum_points(self.index)
    george.tv_camera_set_point(
        self.index,
        x=value,
        y=current_data.y,
        angle=current_data.angle,
        scale=current_data.scale,
    )

y(value: float) -> None

The y coordinate of the point.

Source code in pytvpaint/camera.py
295
296
297
298
299
300
301
302
303
304
305
@y.setter
def y(self, value: float) -> None:
    """The y coordinate of the point."""
    current_data = george.tv_camera_enum_points(self.index)
    george.tv_camera_set_point(
        self.index,
        x=current_data.x,
        y=value,
        angle=current_data.angle,
        scale=current_data.scale,
    )

angle(value: float) -> None

The angle of the camera at the point.

Source code in pytvpaint/camera.py
312
313
314
315
316
317
318
319
320
321
322
@angle.setter
def angle(self, value: float) -> None:
    """The angle of the camera at the point."""
    current_data = george.tv_camera_enum_points(self.index)
    george.tv_camera_set_point(
        self.index,
        x=current_data.x,
        y=current_data.y,
        angle=value,
        scale=current_data.scale,
    )

scale(value: float) -> None

Source code in pytvpaint/camera.py
329
330
331
332
333
334
335
336
337
338
@scale.setter
def scale(self, value: float) -> None:
    current_data = george.tv_camera_enum_points(self.index)
    george.tv_camera_set_point(
        self.index,
        x=current_data.x,
        y=current_data.y,
        angle=current_data.angle,
        scale=value,
    )

new(camera: Camera, index: int, x: int, y: int, angle: int, scale: float) -> CameraPoint classmethod

Create a new point and add it to the camera path at the provided index.

Source code in pytvpaint/camera.py
350
351
352
353
354
355
356
357
358
359
360
361
362
@classmethod
def new(
    cls,
    camera: Camera,
    index: int,
    x: int,
    y: int,
    angle: int,
    scale: float,
) -> CameraPoint:
    """Create a new point and add it to the camera path at the provided index."""
    george.tv_camera_insert_point(index, x, y, angle, scale)
    return cls(index, camera)