Added lots of stuff

This commit is contained in:
lefreud committed 2024-01-17 19:03:04 +00:00
1 parent 3aadde70eb
commit e602d69c43
14 files changed
+83 -33

No files matched your search

+4 -1
View File
@@ -8,7 +8,10 @@ import numpy as np
# fonction that apply the correction on the colors on the input images
def apply_correction(coefs, img, CORRECTION_CURVE_TYPE) -> np.array:
def apply_correction(coefs, img, CORRECTION_CURVE_TYPE) -> np.ndarray:
# check that img is in range 0-255
assert img.dtype == np.uint8
B, G, R = coefs
original_shape = img.shape
img = img.astype(np.float32)
+6 -6
View File
@@ -20,25 +20,25 @@ FRAME_SUBFOLDERS_CONFIG = [
'name': 'left_colmap_baseline',
'flip_k': -1,
'mask_person': True,
'custom_mask': './data/lab_ground_floor/custom_masks/left_mask.png'
'custom_mask': './stick_masks/left_mask.png'
},
{
'name': 'right_colmap_baseline',
'flip_k': 1,
'mask_person': True,
'custom_mask': './data/lab_ground_floor/custom_masks/right_mask.png'
'custom_mask': './stick_masks/right_mask.png'
},
{
'name': 'left_e1',
'flip_k': -1,
'mask_person': True,
'custom_mask': './data/lab_ground_floor/custom_masks/left_mask.png'
'custom_mask': './stick_masks/left_mask.png'
},
{
'name': 'right_e2',
'flip_k': 1,
'mask_person': False,
'custom_mask': './data/lab_ground_floor/custom_masks/right_mask.png'
'custom_mask': './stick_masks/right_mask.png'
}
]
@@ -46,8 +46,8 @@ PERSON_DILATE_KERNEL = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (40, 40))
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--input_dir', type=str, default='./data/lab_ground_floor/trimmed_videos', help='Directory containing all the frames')
parser.add_argument('--output_dir', type=str, default='./data/lab_ground_floor/trimmed_videos_masks')
parser.add_argument('--input_dir', type=str, default='./data/lab_ground_floor/trimmed_videos', help='Directory containing all the 4 directories containing frames')
parser.add_argument('--output_dir', type=str, default='./data/lab_ground_floor/trimmed_videos_masks', help='Directory to save masked frames')
args = parser.parse_args()
out = args.output_dir
+6 -4
View File
@@ -1,7 +1,6 @@
import subprocess
import os
import argparse
import os
import subprocess
# TODO: limit number of frames... maybe 3 per second?
@@ -13,10 +12,13 @@ if __name__ == '__main__':
# get video files
args = argparser.parse_args()
videos = [os.path.join(args.input_dir, f) for f in os.listdir(args.input_dir) if f.endswith(".mp4")]
if len(videos) == 0:
raise Exception("No video files found in input directory.")
for video in videos:
# Get the video name without extension
video_name = os.path.splitext(os.path.basename(video))[0]
print(f"Extracting frames from {video}...")
# Create a subfolder for the frames
output_folder = os.path.join(args.input_dir, f'{video_name}')
@@ -29,7 +31,7 @@ if __name__ == '__main__':
"-vf", "fps=29.97",
f"{output_folder}/output_%04d.png"
]
subprocess.run(command, check=True)
subprocess.run(command, check=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
# only keep frames where mod 10 = 0
for file in os.listdir(output_folder):
@@ -1 +0,0 @@
{"B": [46.82997512817383, 0.11160952597856522, 0.002294188365340233], "G": [41.67820739746094, 0.09581712633371353, 0.0028952741995453835], "R": [37.4744873046875, 0.22809027135372162, 0.002323441905900836], "type": "deg2"}