diff --git a/common/research_common/dataset/twitch/aerial_view_detector.py b/common/research_common/dataset/twitch/aerial_view_detector.py new file mode 100644 index 0000000000000000000000000000000000000000..de15b43542a879b1dc36f57acb8dc2dcf75a7d6e --- /dev/null +++ b/common/research_common/dataset/twitch/aerial_view_detector.py @@ -0,0 +1,23 @@ +from pathlib import Path + +from skimage import io + +from research_common.constants import TWITCH_DSET +from research_common.dataset.twitch.mask_detector import MaskDetector + +aerial_view_detector = MaskDetector( + Path(__file__).parent / 'mask_aerial.jpg', + [ + (527, 528, 292, 297, 20), + (527, 531, 303, 303, 20), + (532, 537, 286, 287, 20), + (536, 541, 302, 303, 20), + (543, 544, 292, 297, 20), + (535, 535, 292, 297, 20), + ] +) + +if __name__ == '__main__': + for file_path in sorted((TWITCH_DSET / 'robots-views').glob('*.jpg')): + if aerial_view_detector.is_matching(io.imread(str(file_path))): + print(file_path.name) diff --git a/common/research_common/dataset/twitch/mask_aerial.jpg b/common/research_common/dataset/twitch/mask_aerial.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3eac40eef546884cf70acb585cb49c140c272cbc Binary files /dev/null and b/common/research_common/dataset/twitch/mask_aerial.jpg differ diff --git a/common/research_common/scripts/move_aerial_views.py b/common/research_common/scripts/move_aerial_views.py new file mode 100644 index 0000000000000000000000000000000000000000..0ed6b86d224dd3eb16e6b0003229aac3f7c87034 --- /dev/null +++ b/common/research_common/scripts/move_aerial_views.py @@ -0,0 +1,22 @@ +from shutil import move + +from skimage import io +from tqdm import tqdm + +from research_common.constants import TWITCH_DSET +from research_common.dataset.twitch.aerial_view_detector import aerial_view_detector + + +ROBOTS_VIEWS_DIR = TWITCH_DSET / 'robots-views' +AERIAL_VIEWS_DIR = TWITCH_DSET / 'aerial-views' + +AERIAL_VIEWS_DIR.mkdir(parents=True, exist_ok=True) + +if __name__ == '__main__': + n = 0 + for file_path in tqdm(list(ROBOTS_VIEWS_DIR.glob('*.jpg')), unit='image', desc='Moving aerial views'): + if aerial_view_detector.is_matching(io.imread(str(file_path))): + move(str(file_path), str(AERIAL_VIEWS_DIR / file_path.name)) + n += 1 + + print(f'Moved {n} images')