Commit 6181d1c8 authored by VIOLANTE Nicolas's avatar VIOLANTE Nicolas
Browse files

compute statistics

parent f2dfff8d
import json
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
with open("/data/nviolant/data_eg3d/lsun-cars-100k-256x256/dataset.json", "r+") as f:
data = json.load(f)
print()
arr = np.array([np.array(a[1][:16]).reshape(4, 4)[:3,-1] for a in data['labels']])
rots = np.array([np.array(a[1][:16]).reshape(4, 4)[:3,:3].T for a in data['labels']])
rvecs = np.array([cv.Rodrigues(rot)[0] for rot in rots])[:, :, 0]
rvecs = rvecs * 180.0 / np.pi
fig, ax = plt.subplots()
i = 0
titles = ['yaw']
total = 360
bins = 36
hist, edges = np.histogram(rvecs[:, -1], bins=bins, density=True)
ax.bar(np.arange(len(hist)), hist)
ax.set_title(titles[i])
ax.set_xlabel('degrees')
ax.set_xticks(np.arange(len(hist), step=5), (np.arange(len(hist), step=5) * total / bins).astype(int))
plt.show()
avg_camera_radius = np.mean(np.sqrt(np.sum(arr ** 2, 1)))
print(f"Averga camera distance {avg_camera_radius}")
print()
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment