3 suivi_auto, a module for pymecavideo:
4 a program to track moving points
in a video frameset
6 Copyright (C) 2007 Jean-Baptiste Butet <ashashiwa
@gmail.com>
7 Copyright (C) 2023 Georges Khaznadar <georgesk
@debian.org>
9 This program
is free software: you can redistribute it
and/
or modify
10 it under the terms of the GNU General Public License
as published by
11 the Free Software Foundation, either version 3 of the License,
or
12 (at your option) any later version.
14 This program
is distributed
in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License
for more details.
19 You should have received a copy of the GNU General Public License
20 along
with this program. If
not, see <http://www.gnu.org/licenses/>.
23from version import Version
24from PyQt6.QtCore import QStandardPaths, QTimer
25from PyQt6.QtGui import QPixmap, QCursor
26from PyQt6.QtWidgets import QApplication
28import subprocess, os, sys, re
31 pymecavideo version %s:
33 a program to track moving points
in a video frameset
35 Copyright (C) 2007-2008 Jean-Baptiste Butet <ashashiwa
@gmail.com>
37 Copyright (C) 2007-2018 Georges Khaznadar <georgesk.debian.org>
39 This program
is free software: you can redistribute it
and/
or modify
40 it under the terms of the GNU General Public License
as published by
41 the Free Software Foundation, either version 3 of the License,
or
42 (at your option) any later version.
44 This program
is distributed
in the hope that it will be useful,
45 but WITHOUT ANY WARRANTY; without even the implied warranty of
46 MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the
47 GNU General Public License
for more details.
49 You should have received a copy of the GNU General Public License
50 along
with this program. If
not, see <http://www.gnu.org/licenses/>.
54 pymecavideo version %s :
56 un programme pour tracer les trajectoires des points dans une vidéo.
58 Copyright (C) 2007-2008 Jean-Baptiste Butet <ashashiwa@gmail.com>
60 Copyright (C) 2007-2018 Georges Khaznadar <georgesk.debian.org>
62 Ce projet est un logiciel libre : vous pouvez le redistribuer, le modifier selon les terme de la GPL (GNU Public License) dans les termes de la Free Software Foundation concernant la version 3 ou plus de la dite licence.
64 Ce programme est fait avec l
'espoir qu'il sera utile mais SANS AUCUNE GARANTIE. Lisez la licence pour plus de détails.
66 <http://www.gnu.org/licenses/>.
71# Version de pymecavideo
76def testerDossier(listDir, defaut=""):
78 if os.path.exists(dir_):
83FILE_ENCODING = sys.getfilesystemencoding()
84DEFAUT_ENCODING =
"utf-8"
89def toFileEncoding(path):
91 path = path.decode(DEFAUT_ENCODING)
92 return path.encode(FILE_ENCODING)
113PATH = os.path.dirname(os.path.abspath(sys.argv[0]))
118if sys.platform ==
'win32':
119 DATA_PATH = os.path.join(APP_PATH,
"data")
121 DATA_PATH = testerDossier(
122 (os.path.join(
"..",
"data"),
'/usr/share/pymecavideo/data',))
125CONF_PATH = os.path.join(
126 QStandardPaths.writableLocation(QStandardPaths.StandardLocation.AppLocalDataLocation),
131HOME_PATH = QStandardPaths.writableLocation(QStandardPaths.StandardLocation.HomeLocation)
134DOCUMENT_PATH = QStandardPaths.writableLocation(QStandardPaths.StandardLocation.DocumentsLocation)
140ICON_PATH = testerDossier(
141 (os.path.join(DATA_PATH,
"icones"), os.path.join(
"..",
"data",
"icones"),
142 '/usr/share/python3-mecavideo/icones',
143 '/usr/share/pymecavideo/icones',
150LANG_PATH = testerDossier((os.path.join(DATA_PATH,
"lang"), os.path.join(
"..",
"data",
"lang"),
151 '/usr/share/pyshared/pymecavideo/lang',
'/usr/share/python3-mecavideo/lang',
152 '/usr/share/pymecavideo/lang'))
156VIDEO_PATH = testerDossier((os.path.join(DATA_PATH,
"video"), os.path.join(
"..",
"data",
"video"),
157 '/usr/share/pyshared/pymecavideo/video',
'/usr/share/python3-mecavideo/video',
158 '/usr/share/pymecavideo/video'))
163HELP_PATH = testerDossier((os.path.join(DATA_PATH,
"help"), os.path.join(
"..",
"data",
"help"),
"/usr/share/doc/python-mecavideo/html",
164 "/usr/share/doc/HTML/fr/pymecavideo"))
167ERROR_FILE = os.path.join(CONF_PATH,
'pymecavideo.exe' +
'.log')
171 """ Renvoie le handler par défaut pour les Popen()
172 (pour contourner un bug ... sous windows)
174 if sys.platform ==
'win32':
177 if hasattr(sys.stderr,
'fileno'):
178 childstderr = sys.stderr
179 elif hasattr(sys.stderr,
'_file')
and hasattr(sys.stderr._file,
'fileno'):
180 childstderr = sys.stderr._file
183 childStderrPath =
'nul'
184 childstderr = open(childStderrPath,
'a')
185 return childstderr, win32process.CREATE_NO_WINDOW
189cible_icon = os.path.join(ICON_PATH,
"curseur_cible.svg")
193def inhibe(motcle, duree):
195 Qt 5.15 a un bug : certains évenements sont lancés deux fois
196 On peut y remédier avec un timer.
198 Cette fonction teste si un mot-clé est dans la liste globdef.inhibe
199 s'il n'y est pas, elle l
'y place et fait en sorte de l'effacer
200 après une durée de duree millisecondes
202 @param motcle le mot-clé d
'inhibition
203 @param duree la durée du tabou sur le mot-clé
205 @return vrai si le mot-clé est encore là dans la liste des inhibitions,
206 faux s
'il n'était pas là (et alors il y est placé pour quelques temps)
208 result = motcle in inhibitions
210 inhibitions.append(motcle)
213 if mot
in inhibitions:
214 inhibitions.remove(mot)
217 QTimer.singleShot(duree, efface(motcle))
223pattern_float = re.compile(
r'^[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?$')
227 """Timestamp decorator for dedicated functions"""
228 @functools.wraps(func)
229 def wrapper(*args, **kwargs):
231 result = func(*args, **kwargs)
232 elapsed = time.time() - start
233 mlsec = repr(elapsed).split(
'.')[1][:3]
234 readable = time.strftime(
235 "%H:%M:%S.{}".format(mlsec), time.gmtime(elapsed))
236 print(
'Function "{}": {} sec'.format(func.__name__, readable))