live during shooting + flash
This commit is contained in:
parent
353934b1fb
commit
6aa82a5676
21
Fotobox.py
21
Fotobox.py
@ -81,16 +81,11 @@ class Fotobox:
|
|||||||
|
|
||||||
def _shooting_callback(self):
|
def _shooting_callback(self):
|
||||||
print("SHOT: %d/%d" % (self._shooting_timer.current(), SHOOTING_COUNT))
|
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))
|
screen.fill((255, 255, 255))
|
||||||
pygame.display.flip()
|
pygame.display.flip()
|
||||||
if not DEBUG:
|
if not DEBUG:
|
||||||
time.sleep(0.2)
|
time.sleep(0.5)
|
||||||
|
|
||||||
frame = self._camera.switch_mode_and_capture_array(self._capture_config, "main")
|
frame = self._camera.switch_mode_and_capture_array(self._capture_config, "main")
|
||||||
image = Image.fromarray(frame)
|
image = Image.fromarray(frame)
|
||||||
@ -101,6 +96,11 @@ class Fotobox:
|
|||||||
|
|
||||||
if self._shooting_timer.complete():
|
if self._shooting_timer.complete():
|
||||||
self._set_state(State.PREPARE)
|
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):
|
def run(self):
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
@ -168,15 +168,13 @@ class Fotobox:
|
|||||||
screen.blit(self._idle_qr, self._idle_qr_rect)
|
screen.blit(self._idle_qr, self._idle_qr_rect)
|
||||||
screen.blit(self._idle_url, self._idle_url_rect)
|
screen.blit(self._idle_url, self._idle_url_rect)
|
||||||
elif self._state == State.COUNTDOWN:
|
elif self._state == State.COUNTDOWN:
|
||||||
screen.blit(self._event.frame, self._event.frame_rect)
|
self._draw_live_frame()
|
||||||
if self._countdown_timer.rest() == 3:
|
if self._countdown_timer.rest() == 3:
|
||||||
screen.blit(FOTOBOX_COUNTDOWN3_SURFACE, FOTOBOX_COUNTDOWN3_RECT)
|
screen.blit(FOTOBOX_COUNTDOWN3_SURFACE, FOTOBOX_COUNTDOWN3_RECT)
|
||||||
elif self._countdown_timer.rest() == 2:
|
elif self._countdown_timer.rest() == 2:
|
||||||
screen.blit(FOTOBOX_COUNTDOWN2_SURFACE, FOTOBOX_COUNTDOWN2_RECT)
|
screen.blit(FOTOBOX_COUNTDOWN2_SURFACE, FOTOBOX_COUNTDOWN2_RECT)
|
||||||
elif self._countdown_timer.rest() == 1:
|
elif self._countdown_timer.rest() == 1:
|
||||||
screen.blit(FOTOBOX_COUNTDOWN1_SURFACE, FOTOBOX_COUNTDOWN1_RECT)
|
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:
|
elif self._state == State.CHOOSE:
|
||||||
screen.blit(CHOOSE_SURFACE, CHOOSE_RECT)
|
screen.blit(CHOOSE_SURFACE, CHOOSE_RECT)
|
||||||
screen.blit(CANCEL_SURFACE, CANCEL_RECT)
|
screen.blit(CANCEL_SURFACE, CANCEL_RECT)
|
||||||
@ -199,6 +197,11 @@ class Fotobox:
|
|||||||
screen.blit(PRINT_SURFACE, PRINT_RECT)
|
screen.blit(PRINT_SURFACE, PRINT_RECT)
|
||||||
screen.blit(DONE_SURFACE, DONE_RECT)
|
screen.blit(DONE_SURFACE, DONE_RECT)
|
||||||
pygame.display.flip()
|
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):
|
def _set_state(self, new_state: State):
|
||||||
print(new_state)
|
print(new_state)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user