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]
#camera_type = 2
cam_is_showmewebcam = false
use_date_for_folder = false
file_extension = 'png'
projects_folder = 'testcv/'
projects_folder = ''
onion_skin_onstartup = true
onionskin_alpha_default = 0.5
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)
if text is not None:
font = ImageFont.truetype("Tuffy_Bold.ttf", (screen_w/32))
font_len = font.getlength(text.split('\n')[0])
text_image_draw.multiline_text((screen_w/2 - font_len/2, screen_h/2 ),
lines = text.split('\n')
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,
fill=(255, 255, 255),
font=font,
@ -192,7 +197,7 @@ def get_session_folder():
return False
# A previous session folder was found; ask the user if they wish to resume session
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)))
if resume_session:
next_letter = last_letter
@ -357,26 +362,6 @@ def remove_frame(img_list, img_index):
else:
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):
cap = cv2.VideoCapture(source)
@ -425,8 +410,9 @@ def main(args):
print(_("No camera device found. Exiting..."))
return 1
cam = cv2.VideoCapture(0)
cam.set(cv2.CAP_PROP_FRAME_WIDTH, 1600)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 900)
# TODO : find highest def available and use that
cam.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
frame = get_onionskin_frame(savepath, index)
@ -488,21 +474,21 @@ def main(args):
# ~ JPEG Compression Controls
# ~ compression_quality 0x009d0903 (int) : min=1 max=100 step=1 default=30 value=30
# Make sure we're using max bitrate
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
reset_wb_exp()
# Flip preview (0 = vert; 1 = hor)
if project_settings['vflip']:
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c vertical_flip=1')
else:
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c vertical_flip=0')
if project_settings['hflip']:
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c horizontal_flip=1')
else:
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c horizontal_flip=0')
time.sleep(.5)
if project_settings['cam_is_showmewebcam']:
# Make sure we're using max bitrate
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
reset_wb_exp()
# Flip preview (0 = vert; 1 = hor)
if project_settings['vflip']:
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c vertical_flip=1')
else:
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c vertical_flip=0')
if project_settings['hflip']:
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c horizontal_flip=1')
else:
serialutils.send_serial_cmd(serialutils.find_cam_port(), 'v4l2-ctl -d /dev/video0 -c horizontal_flip=0')
time.sleep(.5)
loop_delta = 0
while True:
start = timer()
@ -669,7 +655,7 @@ index = len(img_list)-1
print(project_letter)
# 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)
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])

Binary file not shown.

View File

@ -5,133 +5,101 @@
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:01+0200\n"
"POT-Creation-Date: 2024-09-12 18:30+0200\n"
"PO-Revision-Date: 2024-09-12 18:30+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."
msgstr ""
#: ../frame_opencv.py:61
msgid "Found configuration file in {}"
msgstr "Fichier de configuration trouvé dans {}"
msgstr ""
#: ../frame_opencv.py:105
msgid "Yes"
msgstr "Oui"
msgstr ""
#: ../frame_opencv.py:119
msgid "No"
msgstr "Non"
msgstr ""
#: ../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 ?"
msgid ""
"A previous session was found in\n {},\n"
" resume shooting ?"
msgstr ""
#: ../frame_opencv.py:206
msgid "Using {} as session folder."
msgstr "Utilisation de {} comme dossier de session."
msgstr ""
#: ../frame_opencv.py:322
msgid "{} does not exist"
msgstr "{} n'existe pas."
msgstr ""
#: ../frame_opencv.py:343
msgid "Removing {}"
msgstr "Suppression de {}"
msgstr ""
#: ../frame_opencv.py:384
#: ../frame_opencv.py:364
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..."
msgstr "Aucune caméra trouvée. Fermeture..."
msgstr ""
#: ../frame_opencv.py:542
#: ../frame_opencv.py:523
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
msgid "Export"
msgstr "Exporter"
msgid "Ctrl-C hit, exiting..."
msgstr ""
#: ../frame_opencv.py:589
msgid "Playback"
msgstr "Prévisualiser"
#: ../frame_opencv.py:588
msgid "Window was closed, exiting..."
msgstr ""
#: ../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."
msgstr ""
#: ../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:613 ../frame_opencv.py:614
msgid ""
"Ffmpeg is still running.\n"
" Waiting for task to complete."
msgstr ""
#: ../frame_opencv.py:623
msgid "Terminating running process..."
msgstr ""
#: ../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..."
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 ""
"Project-Id-Version: PACKAGE VERSION\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"
"Language-Team: LANGUAGE <LL@li.org>\n"
"Language: French\n"
@ -32,8 +32,8 @@ 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 ?"
msgid "A previous session was found in\n {},\n resume shooting ?"
msgstr "Une session précédente à été trouvée dans\n {},\n reprendre la session ?"
#: ../frame_opencv.py:206
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"