# -*- coding: utf-8 -*- """toHHA.ipynb Automatically generated by Colaboratory. Original file is located at https://colab.research.google.com/drive/1S02gQ1QkqCgNJn1g6GFvxW6eLyLPq8gd """ ! git clone 'https://github.com/charlesCXK/Depth2HHA-python.git' cd Depth2HHA-python/ # Do this: Move getHHA.py inside utils folder. Then run this cell import math import cv2 import os import math from utils.rgbd_util import * from utils.getCameraParam import * from utils.getHHA import * # Unzipping test folder ! unzip "/content/drive/MyDrive/Colab Notebooks/RGBD_for_test.zip" -d "/content/" save_path='/content/RGBD_for_test/NLPR/depth_after_HHA/' if not os.path.exists(save_path): os.makedirs(save_path) import glob filelist=glob.glob('/content/RGBD_for_test/NLPR/depth/*.bmp') print(len(filelist)) # 300 in NLPR test dataset #print(filelist) def getImage(filename): D = cv2.imread(filename, cv2.COLOR_BGR2GRAY)/10000 return D for eachFile in filelist: print(eachFile) D=getImage(eachFile) camera_matrix = getCameraParam('color') print('max gray value: ', np.max(D)) hha = getHHA(camera_matrix, D, D) myFilename=eachFile[:-4] #/content....../filename without .mat extension myFilename=myFilename.split("/") #index 10 contains file name myFilename= myFilename[5] cv2.imwrite(save_path+myFilename+'_HHA'+'.png',hha)