Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions raysect/optical/observer/imaging/orthographic.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ cdef class OrthographicCamera(Observer2D):
pipelines = pipelines or [RGBPipeline2D()]
frame_sampler = frame_sampler or FullFrameSampler2D()

self._width = 1.0 # initial value to prevent undefined behaviour when setting pixels for the first time before width is set

super().__init__(pixels, frame_sampler, pipelines, parent=parent, transform=transform, name=name)

self.sensitivity = sensitivity or 1.0
Expand All @@ -89,6 +91,28 @@ cdef class OrthographicCamera(Observer2D):
self._width = width
self._update_image_geometry()

@property
def pixels(self):
"""
Tuple describing the pixel dimensions for this observer (nx, ny), i.e. (512, 512).

:rtype: tuple
"""
return self._pixels

@pixels.setter
def pixels(self, value):
pixels = tuple(value)
if len(pixels) != 2:
raise ValueError("Pixels must be a 2 element tuple defining the x and y resolution.")
x, y = pixels
if x <= 0:
raise ValueError("Number of x pixels must be greater than 0.")
if y <= 0:
raise ValueError("Number of y pixels must be greater than 0.")
self._pixels = pixels
self._update_image_geometry()

@property
def sensitivity(self):
"""
Expand Down
24 changes: 24 additions & 0 deletions raysect/optical/observer/imaging/pinhole.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ cdef class PinholeCamera(Observer2D):
pipelines = pipelines or [RGBPipeline2D()]
frame_sampler = frame_sampler or FullFrameSampler2D()

self._fov = 45 # initial value to prevent undefined behaviour when setting pixels for the first time before fov is set

super().__init__(pixels, frame_sampler, pipelines, parent=parent, transform=transform, name=name)

# note that the fov property triggers a call to _update_image_geometry()
Expand All @@ -106,6 +108,28 @@ cdef class PinholeCamera(Observer2D):
self._fov = value
self._update_image_geometry()

@property
def pixels(self):
"""
Tuple describing the pixel dimensions for this observer (nx, ny), i.e. (512, 512).

:rtype: tuple
"""
return self._pixels

@pixels.setter
def pixels(self, value):
pixels = tuple(value)
if len(pixels) != 2:
raise ValueError("Pixels must be a 2 element tuple defining the x and y resolution.")
x, y = pixels
if x <= 0:
raise ValueError("Number of x pixels must be greater than 0.")
if y <= 0:
raise ValueError("Number of y pixels must be greater than 0.")
self._pixels = pixels
self._update_image_geometry()

@property
def sensitivity(self):
"""
Expand Down