in ParametricLights.py [0:0]
def calculate_angular_error_metric(gt_lights, my_lights, top_k=5):
# for each gt light find closest predicted light
if len(gt_lights) < 1 or len(my_lights) < 1:
print('No lights here')
return -1
# trying to compensate for python sizing
if len(np.shape(gt_lights)) < 2:
# there is just 1 light
gt_lights = np.stack((gt_lights, gt_lights))
if len(np.shape(my_lights)) < 2:
# there is just 1 light
my_lights = np.stack((my_lights, my_lights))
top_k = np.minimum(top_k, np.shape(gt_lights)[0])
top_k = np.minimum(top_k, np.shape(my_lights)[0])
err = 0.0
if len(gt_lights) > 0 and len(my_lights) > 0:
for i in range(0, top_k):
mne = float("inf")
for j in range(0, top_k):
e_ = angularErrorBetweenLights(gt_lights[i], my_lights[j])
if e_ < mne:
mne = e_
err += mne
for i in range(0, top_k):
mne = float("inf")
for j in range(0, top_k):
e_ = angularErrorBetweenLights(my_lights[i], gt_lights[j])
if e_ < mne:
mne = e_
err += mne
err /= (top_k + top_k)
return err