Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import cv2
- import numpy as np
- from hdf5storage import savemat
- import os
- # Set the environment variable to enable OpenEXR codec
- os.environ["OPENCV_IO_ENABLE_OPENEXR"] = "1"
- rridx = sys.argv[-1]
- def saveasmat(file_path, dst_path):
- img = cv2.imread(file_path, cv2.IMREAD_ANYDEPTH | cv2.IMREAD_UNCHANGED)
- savemat(dst_path, {'uv': img})
- import multiprocessing
- pool = multiprocessing.Pool(processes=2)
- src_dir = '../uv/{}/'.format(rridx)
- dst_dir = '../uvmat/{}/'.format(rridx)
- if not os.path.exists(dst_dir):
- os.makedirs(dst_dir)
- for fname in os.listdir(src_dir):
- if '.exr' in fname:
- file_name = os.path.join(src_dir, fname)
- if not os.path.isfile(file_name):
- continue
- t = dst_dir
- if not os.path.exists(t):
- os.makedirs(t)
- dst_name = os.path.join(t, fname[:-4])
- pool.apply_async(saveasmat, (file_name, dst_name))
- pool.close()
- pool.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement