Compare commits
3 Commits
v2.0-alpha
...
v2
| Author | SHA1 | Date | |
|---|---|---|---|
| 904ba30817 | |||
| 21361341f8 | |||
| a273dbd161 |
@@ -8,7 +8,7 @@ Designed for contribution to street-level imagery projects like Mapillary or Pan
|
|||||||
|
|
||||||
__author__ = "Lucas MATHIEU (@campanu)"
|
__author__ = "Lucas MATHIEU (@campanu)"
|
||||||
__license__ = "GPL-3.0-or-later"
|
__license__ = "GPL-3.0-or-later"
|
||||||
__version__ = "2.0-alpha11"
|
__version__ = "2.0-alpha12"
|
||||||
__maintainer__ = "Lucas MATHIEU (@campanu)"
|
__maintainer__ = "Lucas MATHIEU (@campanu)"
|
||||||
__email__ = "campanu@luc-geo.fr"
|
__email__ = "campanu@luc-geo.fr"
|
||||||
|
|
||||||
@@ -274,20 +274,20 @@ try:
|
|||||||
raise ValueError
|
raise ValueError
|
||||||
else:
|
else:
|
||||||
frame_sampling = float(setting_toml['process_settings']['frame_sampling'])
|
frame_sampling = float(setting_toml['process_settings']['frame_sampling'])
|
||||||
print("> {}".format(locale_toml['ui']['toml_setting']['classic_mode'].format(frame_sampling)))
|
|
||||||
|
|
||||||
if min_frame_samp <= frame_sampling <= max_frame_samp:
|
if min_frame_samp <= frame_sampling <= max_frame_samp:
|
||||||
video_start_datetime_obj = setting_toml['video']['start_datetime']
|
print("> {}".format(locale_toml['ui']['toml_setting']['classic_mode'].format(frame_sampling)))
|
||||||
else:
|
else:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
|
|
||||||
|
video_start_datetime_obj = setting_toml['video']['start_datetime']
|
||||||
video_rec_timezone = str(setting_toml['video']['rec_timezone'])
|
video_rec_timezone = str(setting_toml['video']['rec_timezone'])
|
||||||
|
|
||||||
if 'time_offset' in setting_toml['process_settings']:
|
if 'time_offset' in setting_toml['process_settings']:
|
||||||
time_offset = setting_toml['process_settings']['time_offset']
|
time_offset = setting_toml['process_settings']['time_offset']
|
||||||
|
|
||||||
if time_offset != 0:
|
if time_offset != 0:
|
||||||
if min_time_offset >= time_offset >= max_time_offset:
|
if min_time_offset <= time_offset <= max_time_offset:
|
||||||
time_offset = float(time_offset)
|
time_offset = float(time_offset)
|
||||||
else:
|
else:
|
||||||
raise ValueError
|
raise ValueError
|
||||||
@@ -372,13 +372,14 @@ try:
|
|||||||
timelapse = input(locale_toml['ui']['parameters']['timelapse'].format(user_agree, user_disagree)).upper()
|
timelapse = input(locale_toml['ui']['parameters']['timelapse'].format(user_agree, user_disagree)).upper()
|
||||||
|
|
||||||
if timelapse == user_agree:
|
if timelapse == user_agree:
|
||||||
|
timelapse = True
|
||||||
|
|
||||||
# Timelapse framerate parameter
|
# Timelapse framerate parameter
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
timelapse_fps = int(input(locale_toml['ui']['parameters']['timelapse_fps'].format(min_timelapse_fps,
|
timelapse_fps = int(input(locale_toml['ui']['parameters']['timelapse_fps'].format(min_timelapse_fps,
|
||||||
max_timelapse_fps)))
|
max_timelapse_fps)))
|
||||||
if max_timelapse_fps >= timelapse_fps >= min_timelapse_fps:
|
if max_timelapse_fps >= timelapse_fps >= min_timelapse_fps:
|
||||||
frame_sampling = float(1 / timelapse_fps)
|
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
print('\n{}'.format(locale_toml['ui']['parameters']['timelapse_fps_err'].format(min_timelapse_fps,
|
print('\n{}'.format(locale_toml['ui']['parameters']['timelapse_fps_err'].format(min_timelapse_fps,
|
||||||
@@ -387,7 +388,6 @@ try:
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
print('\n{}'.format(locale_toml['ui']['parameters']['timelapse_fps_err'].format(min_timelapse_fps, max_timelapse_fps)))
|
print('\n{}'.format(locale_toml['ui']['parameters']['timelapse_fps_err'].format(min_timelapse_fps, max_timelapse_fps)))
|
||||||
True
|
True
|
||||||
|
|
||||||
else:
|
else:
|
||||||
# Frame sampling parameter
|
# Frame sampling parameter
|
||||||
while True:
|
while True:
|
||||||
@@ -488,16 +488,17 @@ try:
|
|||||||
|
|
||||||
i = 0
|
i = 0
|
||||||
|
|
||||||
if timelapse == user_agree:
|
if timelapse == True:
|
||||||
frame_interval = frame_sampling / video_fps
|
frame_sampling = float(1 / video_fps)
|
||||||
|
frame_interval = float(1 / timelapse_fps)
|
||||||
else:
|
else:
|
||||||
frame_interval = frame_sampling
|
frame_interval = frame_sampling
|
||||||
|
|
||||||
cv2_tqdm_unit = locale_toml['ui']['unit']['cv2_tqdm']
|
cv2_tqdm_unit = locale_toml['ui']['unit']['cv2_tqdm']
|
||||||
cv2_tqdm_range = int(video_duration / frame_interval)
|
cv2_tqdm_range = int(video_duration / frame_sampling)
|
||||||
|
|
||||||
for i in tqdm(range(cv2_tqdm_range), unit=cv2_tqdm_unit):
|
for i in tqdm(range(cv2_tqdm_range), unit=cv2_tqdm_unit):
|
||||||
t = frame_interval * i * 1000
|
t = frame_sampling * i * 1000
|
||||||
video.set(cv2.CAP_PROP_POS_MSEC, t)
|
video.set(cv2.CAP_PROP_POS_MSEC, t)
|
||||||
ret, frame = video.read()
|
ret, frame = video.read()
|
||||||
|
|
||||||
@@ -516,7 +517,7 @@ try:
|
|||||||
cv2.imwrite(image_path, frame, [cv2.IMWRITE_JPEG_QUALITY, 88, cv2.IMWRITE_JPEG_PROGRESSIVE, 1, cv2.IMWRITE_JPEG_SAMPLING_FACTOR, 0x221111])
|
cv2.imwrite(image_path, frame, [cv2.IMWRITE_JPEG_QUALITY, 88, cv2.IMWRITE_JPEG_PROGRESSIVE, 1, cv2.IMWRITE_JPEG_SAMPLING_FACTOR, 0x221111])
|
||||||
|
|
||||||
# Time tags formatting
|
# Time tags formatting
|
||||||
time_shift = i * frame_sampling
|
time_shift = i * frame_interval
|
||||||
current_datetime_obj = video_start_datetime_obj + timedelta(seconds=time_shift)
|
current_datetime_obj = video_start_datetime_obj + timedelta(seconds=time_shift)
|
||||||
current_datetime = current_datetime_obj.strftime('%Y:%m:%d %H:%M:%S')
|
current_datetime = current_datetime_obj.strftime('%Y:%m:%d %H:%M:%S')
|
||||||
current_subsec_time = int(int(current_datetime_obj.strftime('%f')) / 1000)
|
current_subsec_time = int(int(current_datetime_obj.strftime('%f')) / 1000)
|
||||||
@@ -534,12 +535,10 @@ try:
|
|||||||
|
|
||||||
exif_tags = {
|
exif_tags = {
|
||||||
piexif.ExifIFD.DateTimeOriginal: current_datetime,
|
piexif.ExifIFD.DateTimeOriginal: current_datetime,
|
||||||
|
piexif.ExifIFD.SubSecTimeOriginal: str(current_subsec_time),
|
||||||
piexif.ExifIFD.OffsetTimeOriginal: video_rec_timezone
|
piexif.ExifIFD.OffsetTimeOriginal: video_rec_timezone
|
||||||
}
|
}
|
||||||
|
|
||||||
if current_subsec_time > 0:
|
|
||||||
exif_tags[piexif.ExifIFD.SubSecTime] = str(current_subsec_time)
|
|
||||||
|
|
||||||
image_exif['0th'] = image_tags
|
image_exif['0th'] = image_tags
|
||||||
image_exif['Exif'] = exif_tags
|
image_exif['Exif'] = exif_tags
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user