#!/usr/bin/python3 import os import numpy as np def clamp(a,b,c): return a+b+c-max(a,b,c)-min(a,b,c) def depthFrame(depths,spacing,w,h): ret=[] for i in range(h): ret.append([20000]*w) count=0; total=0 for key in depths.keys(): tmp=depths[key] #print(tmp) count+=1 total+=tmp ret[h-round(key[1]/spacing)][round(key[0]/spacing)]=tmp maxD=4#total/count*3 for y in range(w): for x in range(h): prog=ret[x][y]/float(maxD); ret[x][y]= (clamp(255,0,round(255*(prog*2))),clamp(255,0,round(255*(2.3-prog*3))),clamp(255,0,round(255*(1-prog*3)))); return np.array(ret).astype(np.uint8)