Skip to content

Commit

Permalink
Add test for scene.camera.Camera
Browse files Browse the repository at this point in the history
  • Loading branch information
wkentaro committed Nov 21, 2018
1 parent 1214f92 commit 0e546bd
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions tests/test_camera.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
try:
from . import generic as g
except BaseException:
import generic as g

import numpy as np


class CameraTests(g.unittest.TestCase):

def test_K(self):
resolution = (320, 240)
fovxy = (60, 40)
camera = g.trimesh.scene.Camera(
resolution=resolution,
fovxy=fovxy,
)
K_expected = np.array([
[277.128, 0, 160],
[ 0, 329.697, 120],
[ 0, 0, 1],
], dtype=np.float64)
np.testing.assert_allclose(camera.K, K_expected, rtol=1e-3)

def test_consistency(self):
resolution = (320, 240)
fxfy = None
fovxy = (60, 40)
camera = g.trimesh.scene.Camera(
resolution=resolution,
fxfy=None,
fovxy=fovxy,
)
camera = g.trimesh.scene.Camera(
resolution=resolution,
fxfy=camera.fxfy,
fovxy=None
)
np.testing.assert_allclose(camera.fovxy, fovxy)

0 comments on commit 0e546bd

Please sign in to comment.