test_SimpleCamera.py
Go to the documentation of this file.
1 """
2 GTSAM Copyright 2010-2019, Georgia Tech Research Corporation,
3 Atlanta, Georgia 30332-0415
4 All Rights Reserved
5 
6 See LICENSE for the license information
7 
8 SimpleCamera unit tests.
9 Author: Frank Dellaert & Duy Nguyen Ta (Python)
10 """
11 import math
12 import unittest
13 
14 import numpy as np
15 
16 import gtsam
17 from gtsam import Cal3_S2, Point3, Pose2, Pose3, Rot3, PinholeCameraCal3_S2 as SimpleCamera
18 from gtsam.utils.test_case import GtsamTestCase
19 
20 K = Cal3_S2(625, 625, 0, 0, 0)
21 
22 
24 
25  def test_constructor(self):
26  pose1 = Pose3(Rot3(np.diag([1, -1, -1])), Point3(0, 0, 0.5))
27  camera = SimpleCamera(pose1, K)
28  self.gtsamAssertEquals(camera.calibration(), K, 1e-9)
29  self.gtsamAssertEquals(camera.pose(), pose1, 1e-9)
30 
31  def test_level2(self):
32  # Create a level camera, looking in Y-direction
33  pose2 = Pose2(0.4, 0.3, math.pi/2.0)
34  camera = SimpleCamera.Level(K, pose2, 0.1)
35 
36  # expected
37  x = Point3(1, 0, 0)
38  y = Point3(0, 0, -1)
39  z = Point3(0, 1, 0)
40  wRc = Rot3(x, y, z)
41  expected = Pose3(wRc, Point3(0.4, 0.3, 0.1))
42  self.gtsamAssertEquals(camera.pose(), expected, 1e-9)
43 
44 
45 if __name__ == "__main__":
46  unittest.main()
def gtsamAssertEquals(self, actual, expected, tol=1e-9)
Definition: test_case.py:18
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
Definition: Rot3.h:58
The most common 5DOF 3D->2D calibration.
Definition: Cal3_S2.h:34
Vector3 Point3
Definition: Point3.h:38


gtsam
Author(s):
autogenerated on Tue Jul 4 2023 02:37:46