From 6aa82a5676c7bfa8da6c5d205830a1e880faf513 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20Ha=C3=9Fel?= Date: Sat, 28 Jun 2025 00:22:17 +0200 Subject: [PATCH] live during shooting + flash --- Fotobox.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Fotobox.py b/Fotobox.py index 0df5e9a..305932c 100644 --- a/Fotobox.py +++ b/Fotobox.py @@ -81,16 +81,11 @@ class Fotobox: def _shooting_callback(self): print("SHOT: %d/%d" % (self._shooting_timer.current(), SHOOTING_COUNT)) - for i in range(24): - array = self._camera.capture_array() - img = pygame.image.frombuffer(array.data, res, 'RGB') - screen.blit(img, (0, 0)) - pygame.display.update() screen.fill((255, 255, 255)) pygame.display.flip() if not DEBUG: - time.sleep(0.2) + time.sleep(0.5) frame = self._camera.switch_mode_and_capture_array(self._capture_config, "main") image = Image.fromarray(frame) @@ -101,6 +96,11 @@ class Fotobox: if self._shooting_timer.complete(): self._set_state(State.PREPARE) + elif not DEBUG: + start = time.time() + while time.time() - start < 1: + self._draw_live_frame() + pygame.display.flip() def run(self): if DEBUG: @@ -168,15 +168,13 @@ class Fotobox: screen.blit(self._idle_qr, self._idle_qr_rect) screen.blit(self._idle_url, self._idle_url_rect) elif self._state == State.COUNTDOWN: - screen.blit(self._event.frame, self._event.frame_rect) + self._draw_live_frame() if self._countdown_timer.rest() == 3: screen.blit(FOTOBOX_COUNTDOWN3_SURFACE, FOTOBOX_COUNTDOWN3_RECT) elif self._countdown_timer.rest() == 2: screen.blit(FOTOBOX_COUNTDOWN2_SURFACE, FOTOBOX_COUNTDOWN2_RECT) elif self._countdown_timer.rest() == 1: screen.blit(FOTOBOX_COUNTDOWN1_SURFACE, FOTOBOX_COUNTDOWN1_RECT) - elif self._state == State.SHOOTING: - screen.blit(self._event.frame, self._event.frame_rect) elif self._state == State.CHOOSE: screen.blit(CHOOSE_SURFACE, CHOOSE_RECT) screen.blit(CANCEL_SURFACE, CANCEL_RECT) @@ -199,6 +197,11 @@ class Fotobox: screen.blit(PRINT_SURFACE, PRINT_RECT) screen.blit(DONE_SURFACE, DONE_RECT) pygame.display.flip() + + def _draw_live_frame(self): + array = self._camera.capture_array() + img = pygame.image.frombuffer(array.data, res, 'RGB') + screen.blit(img, (0, 0)) def _set_state(self, new_state: State): print(new_state)