Commit 6b07f876 authored by VIOLANTE Nicolas's avatar VIOLANTE Nicolas
Browse files

add statistics

parent 165c79ca
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
import json
import numpy as np
import cv2 as cv
import matplotlib.pyplot as plt
import click
@click.command()
@click.option("--source", type=str, help="json file with camera annotations")
def main(source):
with open(source, "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()
total = 360
bins = 36
hist, edges = np.histogram(rvecs[:, -1], bins=bins, density=True)
ax.bar(np.arange(len(hist)), hist)
ax.set_title("yaw")
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}")
if __name__ == "__main__":
main()
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