Fix ffmpeg export, serial to showmewebcam only, fix text align UI

This commit is contained in:
ABelliqueux 2024-09-12 19:02:53 +02:00
parent 8fa4667874
commit 760f30bd48
8 changed files with 84 additions and 371 deletions

View File

@ -1,8 +1,9 @@
[DEFAULT] [DEFAULT]
#camera_type = 2 #camera_type = 2
cam_is_showmewebcam = false
use_date_for_folder = false use_date_for_folder = false
file_extension = 'png' file_extension = 'png'
projects_folder = 'testcv/' projects_folder = ''
onion_skin_onstartup = true onion_skin_onstartup = true
onionskin_alpha_default = 0.5 onionskin_alpha_default = 0.5
fullscreen_bool = true fullscreen_bool = true

View File

@ -80,8 +80,13 @@ def generate_text_image(text:str, screen_w, screen_h, bullets=False):
text_image_draw = ImageDraw.Draw(text_image) text_image_draw = ImageDraw.Draw(text_image)
if text is not None: if text is not None:
font = ImageFont.truetype("Tuffy_Bold.ttf", (screen_w/32)) font = ImageFont.truetype("Tuffy_Bold.ttf", (screen_w/32))
font_len = font.getlength(text.split('\n')[0]) lines = text.split('\n')
text_image_draw.multiline_text((screen_w/2 - font_len/2, screen_h/2 ), longest_line = lines[0]
for line in lines:
if len(line) > len(longest_line):
longest_line = line
font_len = font.getlength(lines[lines.index(longest_line)])
text_image_draw.multiline_text((screen_w/2 - font_len/2, screen_h/3 ),
text, text,
fill=(255, 255, 255), fill=(255, 255, 255),
font=font, font=font,
@ -192,7 +197,7 @@ def get_session_folder():
return False return False
# A previous session folder was found; ask the user if they wish to resume session # A previous session folder was found; ask the user if they wish to resume session
if not project_settings['use_date_for_folder']: if not project_settings['use_date_for_folder']:
resume_session = askyesno(_("A previous session was found in {},\n resume shooting ?").format(os.path.join(project_folder, last_letter))) resume_session = askyesno(_("A previous session was found in\n {},\n resume shooting ?").format(os.path.join(project_folder, last_letter)))
# ~ resume_session = tk.messagebox.askyesno(_("Resume session?"), _("A previous session was found in {}, resume shooting ?").format(os.path.join(project_folder, last_letter))) # ~ resume_session = tk.messagebox.askyesno(_("Resume session?"), _("A previous session was found in {}, resume shooting ?").format(os.path.join(project_folder, last_letter)))
if resume_session: if resume_session:
next_letter = last_letter next_letter = last_letter
@ -357,26 +362,6 @@ def remove_frame(img_list, img_index):
else: else:
return img_list, 0, blank_image return img_list, 0, blank_image
# ~ def playback_animation(img_list, img_index):
# ~ # save onionskin state
# ~ if onionskin:
# ~ onionskin = False
# ~ onionskin_was_on = True
# ~ for file in img_list:
# ~ img = update_image(img_list, img_list.index(file))
# ~ print(str(img_list.index(file)) + " : " + file )
# ~ cv2.imshow("StopiCV", img)
# ~ time.sleep(.5)
# ~ # Restore previous frame
# ~ print(img_index)
# ~ frame_before_playback = update_image(img_list, img_index)
# ~ cv2.imshow("StopiCV", img)
# ~ # Restore onionskin
# ~ if 'onionskin_was_on' in locals():
# ~ onionskin = True
# ~ # Restore index
# ~ return img_index, frame_before_playback
def testDevice(source): def testDevice(source):
cap = cv2.VideoCapture(source) cap = cv2.VideoCapture(source)
@ -425,8 +410,9 @@ def main(args):
print(_("No camera device found. Exiting...")) print(_("No camera device found. Exiting..."))
return 1 return 1
cam = cv2.VideoCapture(0) cam = cv2.VideoCapture(0)
cam.set(cv2.CAP_PROP_FRAME_WIDTH, 1600) # TODO : find highest def available and use that
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 900) cam.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
frame = get_onionskin_frame(savepath, index) frame = get_onionskin_frame(savepath, index)
@ -488,21 +474,21 @@ def main(args):
# ~ JPEG Compression Controls # ~ JPEG Compression Controls
# ~ compression_quality 0x009d0903 (int) : min=1 max=100 step=1 default=30 value=30 # ~ compression_quality 0x009d0903 (int) : min=1 max=100 step=1 default=30 value=30
if project_settings['cam_is_showmewebcam']:
# Make sure we're using max bitrate # Make sure we're using max bitrate
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c video_bitrate=25000000') serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c video_bitrate=25000000')
# Flip auto-exposure, white-balance on and off to adapt to light environment # Flip auto-exposure, white-balance on and off to adapt to light environment
reset_wb_exp() reset_wb_exp()
# Flip preview (0 = vert; 1 = hor) # Flip preview (0 = vert; 1 = hor)
if project_settings['vflip']: if project_settings['vflip']:
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c vertical_flip=1') serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c vertical_flip=1')
else: else:
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c vertical_flip=0') serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c vertical_flip=0')
if project_settings['hflip']: if project_settings['hflip']:
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c horizontal_flip=1') serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c horizontal_flip=1')
else: else:
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c horizontal_flip=0') serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c horizontal_flip=0')
time.sleep(.5) time.sleep(.5)
loop_delta = 0 loop_delta = 0
while True: while True:
start = timer() start = timer()
@ -669,7 +655,7 @@ index = len(img_list)-1
print(project_letter) print(project_letter)
# Export settings # Export settings
input_filename = "{folder}{letter}{sep}{letter}.%04d.{ext}".format(folder=projects_folder, sep=os.sep, letter=project_letter, ext=project_settings['file_extension']) input_filename = "{folder}{sep}{letter}.%04d.{ext}".format(folder=savepath, sep=os.sep, letter=project_letter, ext=project_settings['file_extension'])
print(input_filename) print(input_filename)
input_options = ["image2", str(project_settings['framerate'])] input_options = ["image2", str(project_settings['framerate'])]
# ~ output_filename = "{folder}{sep}{filename}.mp4".format(folder=projects_folder, sep=os.sep, filename=savepath.split(os.sep)[-1]) # ~ output_filename = "{folder}{sep}{filename}.mp4".format(folder=projects_folder, sep=os.sep, filename=savepath.split(os.sep)[-1])

Binary file not shown.

View File

@ -5,133 +5,101 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-09-12 16:29+0200\n" "POT-Creation-Date: 2024-09-12 18:30+0200\n"
"PO-Revision-Date: 2024-09-12 18:01+0200\n" "PO-Revision-Date: 2024-09-12 18:30+0200\n"
"Last-Translator: arthus <arthus@ateliers>\n" "Last-Translator: arthus <arthus@ateliers>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: French\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n" "Generated-By: pygettext.py 1.5\n"
#: ../frame_opencv.py:50 #: ../frame_opencv.py:50
msgid "No configuration file found, using defaults." msgid "No configuration file found, using defaults."
msgstr "Aucun fichier de configuration trouvé, utilisation des valeurs par défaut." msgstr ""
#: ../frame_opencv.py:61 #: ../frame_opencv.py:61
msgid "Found configuration file in {}" msgid "Found configuration file in {}"
msgstr "Fichier de configuration trouvé dans {}" msgstr ""
#: ../frame_opencv.py:105 #: ../frame_opencv.py:105
msgid "Yes" msgid "Yes"
msgstr "Oui" msgstr ""
#: ../frame_opencv.py:119 #: ../frame_opencv.py:119
msgid "No" msgid "No"
msgstr "Non" msgstr ""
#: ../frame_opencv.py:195 #: ../frame_opencv.py:195
msgid "A previous session was found in {},\n resume shooting ?" msgid ""
msgstr "Une session précédente à été trouvée dans {},\n reprendre la session ?" "A previous session was found in\n {},\n"
" resume shooting ?"
msgstr ""
#: ../frame_opencv.py:206 #: ../frame_opencv.py:206
msgid "Using {} as session folder." msgid "Using {} as session folder."
msgstr "Utilisation de {} comme dossier de session." msgstr ""
#: ../frame_opencv.py:322 #: ../frame_opencv.py:322
msgid "{} does not exist" msgid "{} does not exist"
msgstr "{} n'existe pas." msgstr ""
#: ../frame_opencv.py:343 #: ../frame_opencv.py:343
msgid "Removing {}" msgid "Removing {}"
msgstr "Suppression de {}" msgstr ""
#: ../frame_opencv.py:384 #: ../frame_opencv.py:364
msgid "Warning: unable to open video source: {}" msgid "Warning: unable to open video source: {}"
msgstr "Attention: périphérique vidéo introuvable : {}" msgstr ""
#: ../frame_opencv.py:425 #: ../frame_opencv.py:405
msgid "No camera device found. Exiting..." msgid "No camera device found. Exiting..."
msgstr "Aucune caméra trouvée. Fermeture..." msgstr ""
#: ../frame_opencv.py:542 #: ../frame_opencv.py:523
msgid "Failed to grab frame." msgid "Failed to grab frame."
msgstr "Impossible de capturer l'image" msgstr ""
#: ../frame_opencv.py:566
msgid "Export"
msgstr ""
#: ../frame_opencv.py:570
msgid "Playback"
msgstr ""
#: ../frame_opencv.py:577
msgid "Remove frame"
msgstr ""
#: ../frame_opencv.py:582
msgid "Escape hit, exiting..."
msgstr ""
#: ../frame_opencv.py:585 #: ../frame_opencv.py:585
msgid "Export" msgid "Ctrl-C hit, exiting..."
msgstr "Exporter" msgstr ""
#: ../frame_opencv.py:589 #: ../frame_opencv.py:588
msgid "Playback" msgid "Window was closed, exiting..."
msgstr "Prévisualiser" msgstr ""
#: ../frame_opencv.py:596 #: ../frame_opencv.py:596
msgid "Remove frame"
msgstr "Supprimer image"
#: ../frame_opencv.py:601
msgid "Escape hit, exiting..."
msgstr "Touche Échap utilisée, fermeture..."
#: ../frame_opencv.py:604
msgid "Ctrl-C hit, exiting..."
msgstr "Combinaison Ctrl-C utilisée, fermeture..."
#: ../frame_opencv.py:607
msgid "Window was closed, exiting..."
msgstr "Fenêtre close, fermeture..."
#: ../frame_opencv.py:615
msgid "File {} written." msgid "File {} written."
msgstr "Fichier {} écris." msgstr ""
#: ../frame_opencv.py:632 ../frame_opencv.py:633 #: ../frame_opencv.py:613 ../frame_opencv.py:614
msgid "Ffmpeg is still running.\n Waiting for task to complete." msgid ""
msgstr "Ffmpeg est toujours en cours d'éxécution.\n Attente de la fin du processus.'" "Ffmpeg is still running.\n"
" Waiting for task to complete."
msgstr ""
#: ../frame_opencv.py:623
msgid "Terminating running process..."
msgstr ""
#: ../frame_opencv.py:642 #: ../frame_opencv.py:642
msgid "Terminating running process..."
msgstr "Terminaison des processus en cours..."
#: ../frame_opencv.py:661
msgid "No images yet! Start shooting..." msgid "No images yet! Start shooting..."
msgstr "Aucune image! Commencez à tourner..." msgstr ""
#~ msgid "Warning: Some settings are not set to the recommended value!"
#~ msgstr "Attention: certains paramètres ne sont pas optimaux!"
#~ msgid ""
#~ "\n"
#~ "Camera not found or busy."
#~ msgstr ""
#~ "\n"
#~ "Caméra introuvable ou occupée."
#~ msgid "Resume session?"
#~ msgstr "Reprendre la session ?"
#~ msgid "Image is being saved to {}"
#~ msgstr "Image sauvegardée dans {}"
#~ msgid "speed too high"
#~ msgstr "Vitesse trop élevée."
#~ msgid "Speed too low."
#~ msgstr "Vitesse trop basse."
#~ msgid "Saving {}{}"
#~ msgstr "Enregistrement de {}{}"
#~ msgid "Getting file {}"
#~ msgstr "Récupération du fichier {}"
#~ msgid "Ending thread"
#~ msgstr "Terminaison du processus."
#~ msgid "Exporting to {}"
#~ msgstr "Exportation dans {}"
#~ msgid "Mp4 files"
#~ msgstr "Fichier Mp4"

Binary file not shown.

View File

@ -6,7 +6,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-09-12 16:29+0200\n" "POT-Creation-Date: 2024-09-12 16:29+0200\n"
"PO-Revision-Date: 2024-09-12 18:02+0200\n" "PO-Revision-Date: 2024-09-12 18:31+0200\n"
"Last-Translator: arthus <arthus@ateliers>\n" "Last-Translator: arthus <arthus@ateliers>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: French\n" "Language: French\n"
@ -32,8 +32,8 @@ msgid "No"
msgstr "Non" msgstr "Non"
#: ../frame_opencv.py:195 #: ../frame_opencv.py:195
msgid "A previous session was found in {},\n resume shooting ?" msgid "A previous session was found in\n {},\n resume shooting ?"
msgstr "Une session précédente à été trouvée dans {},\n reprendre la session ?" msgstr "Une session précédente à été trouvée dans\n {},\n reprendre la session ?"
#: ../frame_opencv.py:206 #: ../frame_opencv.py:206
msgid "Using {} as session folder." msgid "Using {} as session folder."

View File

@ -1,105 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-09-12 16:29+0200\n"
"PO-Revision-Date: 2024-09-12 16:36+0200\n"
"Last-Translator: arthus <arthus@ateliers>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: ../frame_opencv.py:50
msgid "No configuration file found, using defaults."
msgstr ""
#: ../frame_opencv.py:61
msgid "Found configuration file in {}"
msgstr ""
#: ../frame_opencv.py:105
msgid "Yes"
msgstr ""
#: ../frame_opencv.py:119
msgid "No"
msgstr ""
#: ../frame_opencv.py:195
msgid ""
"A previous session was found in {},\n"
" resume shooting ?"
msgstr ""
#: ../frame_opencv.py:206
msgid "Using {} as session folder."
msgstr ""
#: ../frame_opencv.py:322
msgid "{} does not exist"
msgstr ""
#: ../frame_opencv.py:343
msgid "Removing {}"
msgstr ""
#: ../frame_opencv.py:384
msgid "Warning: unable to open video source: {}"
msgstr ""
#: ../frame_opencv.py:425
msgid "No camera device found. Exiting..."
msgstr ""
#: ../frame_opencv.py:542
msgid "Failed to grab frame."
msgstr ""
#: ../frame_opencv.py:585
msgid "Export"
msgstr ""
#: ../frame_opencv.py:589
msgid "Playback"
msgstr ""
#: ../frame_opencv.py:596
msgid "Remove frame"
msgstr ""
#: ../frame_opencv.py:601
msgid "Escape hit, exiting..."
msgstr ""
#: ../frame_opencv.py:604
msgid "Ctrl-C hit, exiting..."
msgstr ""
#: ../frame_opencv.py:607
msgid "Window was closed, exiting..."
msgstr ""
#: ../frame_opencv.py:615
msgid "File {} written."
msgstr ""
#: ../frame_opencv.py:632 ../frame_opencv.py:633
msgid ""
"Ffmpeg is still running.\n"
" Waiting for task to complete."
msgstr ""
#: ../frame_opencv.py:642
msgid "Terminating running process..."
msgstr ""
#: ../frame_opencv.py:661
msgid "No images yet! Start shooting..."
msgstr ""

View File

@ -1,137 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2024-09-12 16:29+0200\n"
"PO-Revision-Date: 2024-09-12 18:00+0200\n"
"Last-Translator: arthus <arthus@ateliers>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: French\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
#: ../frame_opencv.py:50
msgid "No configuration file found, using defaults."
msgstr "Aucun fichier de configuration trouvé, utilisation des valeurs par défaut."
#: ../frame_opencv.py:61
msgid "Found configuration file in {}"
msgstr "Fichier de configuration trouvé dans {}"
#: ../frame_opencv.py:105
msgid "Yes"
msgstr "Oui"
#: ../frame_opencv.py:119
msgid "No"
msgstr "Non"
#: ../frame_opencv.py:195
msgid "A previous session was found in {},\n resume shooting ?"
msgstr "Une session précédente à été trouvée dans {},\n reprendre la session ?"
#: ../frame_opencv.py:206
msgid "Using {} as session folder."
msgstr "Utilisation de {} comme dossier de session."
#: ../frame_opencv.py:322
msgid "{} does not exist"
msgstr "{} n'existe pas."
#: ../frame_opencv.py:343
msgid "Removing {}"
msgstr "Suppression de {}"
#: ../frame_opencv.py:384
msgid "Warning: unable to open video source: {}"
msgstr "Attention: périphérique vidéo introuvable : {}"
#: ../frame_opencv.py:425
msgid "No camera device found. Exiting..."
msgstr "Aucune caméra trouvée. Fermeture..."
#: ../frame_opencv.py:542
msgid "Failed to grab frame."
msgstr "Impossible de capturer l'image"
#: ../frame_opencv.py:585
msgid "Export"
msgstr "Exporter"
#: ../frame_opencv.py:589
msgid "Playback"
msgstr "Prévisualiser"
#: ../frame_opencv.py:596
msgid "Remove frame"
msgstr "Supprimer image"
#: ../frame_opencv.py:601
msgid "Escape hit, exiting..."
msgstr "Touche Échap utilisée, fermeture..."
#: ../frame_opencv.py:604
msgid "Ctrl-C hit, exiting..."
msgstr "Combinaison Ctrl-C utilisée, fermeture..."
#: ../frame_opencv.py:607
msgid "Window was closed, exiting..."
msgstr "Fenêtre close, fermeture..."
#: ../frame_opencv.py:615
msgid "File {} written."
msgstr "Fichier {} écris."
#: ../frame_opencv.py:632 ../frame_opencv.py:633
msgid "Ffmpeg is still running.\n Waiting for task to complete."
msgstr "Ffmpeg est toujours en cours d'éxécution.\n Attente de la fin du processus.'"
#: ../frame_opencv.py:642
msgid "Terminating running process..."
msgstr "Terminaison des processus en cours..."
#: ../frame_opencv.py:661
msgid "No images yet! Start shooting..."
msgstr "Aucune image! Commencez à tourner..."
#~ msgid "Warning: Some settings are not set to the recommended value!"
#~ msgstr "Attention: certains paramètres ne sont pas optimaux!"
#~ msgid ""
#~ "\n"
#~ "Camera not found or busy."
#~ msgstr ""
#~ "\n"
#~ "Caméra introuvable ou occupée."
#~ msgid "Resume session?"
#~ msgstr "Reprendre la session ?"
#~ msgid "Image is being saved to {}"
#~ msgstr "Image sauvegardée dans {}"
#~ msgid "speed too high"
#~ msgstr "Vitesse trop élevée."
#~ msgid "Speed too low."
#~ msgstr "Vitesse trop basse."
#~ msgid "Saving {}{}"
#~ msgstr "Enregistrement de {}{}"
#~ msgid "Getting file {}"
#~ msgstr "Récupération du fichier {}"
#~ msgid "Ending thread"
#~ msgstr "Terminaison du processus."
#~ msgid "Exporting to {}"
#~ msgstr "Exportation dans {}"
#~ msgid "Mp4 files"
#~ msgstr "Fichier Mp4"