-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/bin/bash | ||
input_folder="${1?"Usage: $0 <input/folder> <output/folder>"}" | ||
output_base_folder="${2?"Usage: $0 <input/folder> <output/folder>"}" | ||
for input in "$input_folder"/*/; do | ||
sequence_name=$(basename "$input") | ||
output_folder="${output_base_folder}/${sequence_name}" | ||
python "${EVENT_CNN_BASE}/utils/extract_images_MMP.py" \ | ||
"${input}/memmaps" \ | ||
"$output_folder" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import argparse | ||
import cv2 | ||
import os | ||
import numpy as np | ||
from util import setup_output_folder, append_timestamp | ||
from os.path import join | ||
from tqdm import tqdm | ||
|
||
|
||
def load_data(data_path, timestamp_fname='timestamps.npy', image_fname='images.npy'): | ||
|
||
assert os.path.isdir(data_path), '%s is not a valid data_pathectory' % data_path | ||
|
||
data = {} | ||
for subroot, _, fnames in sorted(os.walk(data_path)): | ||
for fname in sorted(fnames): | ||
path = os.path.join(subroot, fname) | ||
if fname.endswith('.npy'): | ||
if fname.endswith(timestamp_fname): | ||
frame_stamps = np.load(path) | ||
data['frame_stamps'] = frame_stamps | ||
elif fname.endswith(image_fname): | ||
data['images'] = np.load(path, mmap_mode='r') # N x H x W x C | ||
return data | ||
|
||
|
||
def save_images(data, output_folder, ts_path): | ||
for i, (image, ts) in enumerate(zip(tqdm(data['images']), data['frame_stamps'])): | ||
fname = 'frame_{:010d}.png'.format(i) | ||
cv2.imwrite(join(output_folder, fname), image) | ||
append_timestamp(ts_path, fname, ts) | ||
|
||
|
||
def main(args): | ||
data = load_data(args.data_path) | ||
ts_path = setup_output_folder(args.output_folder) | ||
save_images(data, args.output_folder, ts_path) | ||
|
||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument('data_path', type=str) | ||
parser.add_argument('output_folder', type=str) | ||
args = parser.parse_args() | ||
main(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters