File size: 2,084 Bytes
07444d1 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | from pathlib import Path
import cv2
import sys
import os
originalRootPath = '/home/paulo/Área de Trabalho/PLDs - Original'
organizedRootPath = '/home/paulo/Área de Trabalho/PLDs Separada'
raizOriginal = Path(originalRootPath)
pathImgs = raizOriginal.rglob('*.jpg')
dictOrig = {}
for path in pathImgs:
str = path.as_posix()
relativePath = str.replace(originalRootPath, '.')
fileName = os.path.basename(path)
if fileName in dictOrig:
print('Duplicated filename in the original dataset')
print(fileName)
exit(0)
dictOrig[fileName] = relativePath
raizOrganizado = Path(organizedRootPath)
pathImgs = raizOrganizado.rglob('*.jpg')
dictOrganizado = {}
listPaths = []
for path in pathImgs:
str = path.as_posix()
relativePath = str.replace(organizedRootPath, '.')
fileName = os.path.basename(path)
if fileName in dictOrganizado:
print('Duplicated filename in the organized dataset')
print(fileName)
exit(0)
dictOrganizado[fileName] = relativePath
listPaths.append(relativePath.replace(fileName,''))
setPaths = set(listPaths)
print('unrar e "./Sequences Test/All - 1000 frames/All_QRIDR.rar" "./Sequences Test/All - 1000 frames/All_QRIDR/"')
print('unrar e "./Sequences Test/All - 1000 frames/All_VXUSD.rar" "./Sequences Test/All - 1000 frames/All_VXUSD/"')
print('unrar e "./Sequences Train - 6616 Frames/Images_train.rar" "./Sequences Train - 6616 Frames/Images/"')
for str in setPaths:
print("mkdir -p " + str)
dictCp = {}
for key, value in dictOrig.items():
try:
print("cp \'" + value + "' " + "'" + dictOrganizado[key] + "'")
dictOrganizado.pop(key)
except KeyError:
print('Key not found in the organized dataset')
print(fileName)
exit(0)
print('rm -rf "./Sequences Test/All - 1000 frames/All_QRIDR/"')
print('rm -rf "./Sequences Test/All - 1000 frames/All_VXUSD/"')
print('rm -rf "./Sequences Train - 6616 Frames/Images/"')
if(len(dictOrganizado.keys()) > 0):
print("Error: some organized images were not found") |