Skip to content

Commit

Permalink
reduce preview window size to save cpu.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgineer85 committed Oct 25, 2024
1 parent e6fe180 commit f694bdb
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion node/services/backends/cameras/picamera2.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def start(self, nominal_framerate: int = None):
# Preview.QT seems to work reasonably well, so use this for now hardcoded.
# Further refs:
# https://github.com/raspberrypi/picamera2/issues/989
self._picamera2.start_preview(Preview.QT, x=0, y=0, width=800, height=480)
self._picamera2.start_preview(Preview.QT, x=0, y=0, width=400, height=240)
# self._qpicamera2 = QPicamera2(self._picamera2, width=800, height=480, keep_ar=True)
else:
pass
Expand Down
2 changes: 0 additions & 2 deletions node/services/backends/cameras/virtualcamera.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ def wait_for_lores_image(self):
imarray = numpy.random.rand(200, 200, 3) * 255
random_image = Image.fromarray(imarray.astype("uint8"), "RGB")
random_image.save(byte_io, format="JPEG", quality=50)
# random_image = Image.new("RGB", (64, 64), color="green")
# random_image.save(byte_io, format="JPEG", quality=50)

return byte_io.getbuffer()

Expand Down
3 changes: 1 addition & 2 deletions node/services/backends/io/gpiobackend.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ def set_hardware_clock(self, enable: bool = True):
# duty cycle = period / 2
"""
PWM_CHANNEL = self._config.pwm_channel
PERIOD = int(1.0 / self._config.FPS_NOMINAL * 1e9) # 1e9=ns
# PERIOD = int(0.5 / self._config.FPS_NOMINAL * 1e9) # 1e9=ns # double frequency!
PERIOD = int(1.0 / self._config.fps_nominal * 1e9) # 1e9=ns
DUTY_CYCLE = PERIOD // 2
PWM_SYSFS = Path(f"/sys/class/pwm/{self._config.pwmchip}")

Expand Down
2 changes: 1 addition & 1 deletion node/services/config/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ConfigBackendGpio(BaseModel):
trigger_out_pin_name: str = Field(default="GPIO17")

enable_clock: bool = Field(default=False)
FPS_NOMINAL: int = Field(default=9) # needs to be lower than cameras mode max fps to allow for control reserve
fps_nominal: int = Field(default=9) # needs to be lower than cameras mode max fps to allow for control reserve
pwmchip: str = Field(default="pwmchip2") # pi5: pwmchip2, other pwmchip0
pwm_channel: int = Field(default=2) # pi5: 2, other 0

Expand Down

0 comments on commit f694bdb

Please sign in to comment.