コード例 #1
0
    def test_reconstruct3D(self):
        ImgPtsA = self.TypeFunc([[320], [240]])
        ImgPtsB = self.TypeFunc([[320], [240]])
        CameraMatrixA = self.TypeFunc([[100, 0, 320], [0, 100, 240], [0, 0,
                                                                      1]])
        CameraMatrixB = self.TypeFunc([[100, 0, 320], [0, 100, 240], [0, 0,
                                                                      1]])
        Tx2CamA = self.TypeFunc([[1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0],
                                 [0, 0, 0, 1]])

        Deg45 = np.sqrt(2) / 2
        Tx2CamB = self.TypeFunc([[1, 0, 0, 0], [0, Deg45, -Deg45, 10],
                                 [0, Deg45, Deg45, 0], [0, 0, 0, 1]])
        DistA = self.TypeFunc([])
        DistB = self.TypeFunc([])
        GTPInX = np.array([0, 0, np.sqrt(2) * 10]).reshape(3, 1)
        GTPInB = np.array([0, 0, 10]).reshape(3, 1)
        PtsInX_3xn, ErrA, ErrB = \
            VGL.reconstruct3DPts(imgPtsA_2xn=ImgPtsA, imgPtsB_2xn=ImgPtsB, cameraMatrixA=CameraMatrixA,
                                 cameraMatrixB=CameraMatrixB, distCoeffsA=DistA, distCoeffsB=DistB,
                                 Tx2CamA=Tx2CamA, Tx2CamB=Tx2CamB, calcReprojErr=True)
        PtsInB_3xn = VGL.projectPts(PtsInX_3xn, Tx2CamB)
        testNumpy.assert_allclose(PtsInX_3xn, GTPInX, atol=1e-7)
        testNumpy.assert_allclose(PtsInB_3xn, GTPInB, atol=1e-7)
        testNumpy.assert_allclose(ErrA, 0, atol=1e-7)
        testNumpy.assert_allclose(ErrB, 0, atol=1e-7)
コード例 #2
0
 def testTransform_NotAlign(self):
     Line0 = self.TypeFunc([[3, 6], [3, 6], [3, 6]])
     Line1 = self.TypeFunc([[3, 5], [3, 5], [-3, -5]])
     GTTransLine = np.array([[3, 6], [3, 6], [-3, -6]])
     T = VGL.getTransformWith2LineSegment(Line0, Line1)
     TransLine0 = VGL.projectPts(Line0, T)
     testNumpy.assert_allclose(TransLine0, GTTransLine)
コード例 #3
0
 def test_computeRotateVec_180RotateAxisValid(self):
     Vec0 = self.TypeFunc([[1], [0], [0]])
     Vec1 = self.TypeFunc([[-1], [0], [0]])
     AxisAngle = VGL.computeRotateVec(Vec0, Vec1, rotateAxis=[0, 0, 1])
     R = cv2.Rodrigues(AxisAngle)[0]
     NewVec = VGL.projectPts(pts_dxn=Vec0, projectMatrix=R)
     testNumpy.assert_allclose(Vec1, NewVec, atol=1e-7)
コード例 #4
0
 def test_projectPts_NotMatch(self):
     Pts = self.TypeFunc([[0, 2], [1, 3]])
     ProjectMatrix = self.TypeFunc([[0, -1, 0, 11], [1, 0, 0, 22],
                                    [0, 0, 1, 33], [0, 0, 0, 1]])
     with testNumpy.assert_raises(VGL.VGLError):
         VGL.projectPts(pts_dxn=Pts, projectMatrix=ProjectMatrix)
コード例 #5
0
 def test_projectPts_MatrixErr(self):
     Pts = self.TypeFunc([[0, 2], [1, 3]])
     ProjectMatrix = self.TypeFunc([[0, -1, 10], [1, 0, 20]])
     with testNumpy.assert_raises(VGL.VGLError):
         VGL.projectPts(pts_dxn=Pts, projectMatrix=ProjectMatrix)
コード例 #6
0
 def test_projectPts_D1(self):
     Pts = self.TypeFunc([[0, 2], [1, 3]])
     ProjectMatrix = self.TypeFunc([[0, -1, 10], [1, 0, 20], [0, 0, 1]])
     GT = np.array([[9, 7], [20, 22]])
     ProjectedPts = VGL.projectPts(pts_dxn=Pts, projectMatrix=ProjectMatrix)
     testNumpy.assert_allclose(GT, ProjectedPts)
コード例 #7
0
 def test_projectPts_SameD(self):
     Pts = self.TypeFunc([[0, 2], [1, 3]])
     ProjectMatrix = self.TypeFunc([[0, -1], [1, 0]])
     GT = np.array([[-1, -3], [0, 2]])
     ProjectedPts = VGL.projectPts(pts_dxn=Pts, projectMatrix=ProjectMatrix)
     testNumpy.assert_allclose(GT, ProjectedPts)
コード例 #8
0
 def testTransform(self):
     Line0 = self.TypeFunc([[3, 5], [3, 5], [3, 5]])
     Line1 = self.TypeFunc([[3, 5], [3, 5], [-3, -5]])
     T = VGL.getTransformWith2LineSegment(Line0, Line1)
     TransLine0 = VGL.projectPts(Line0, T)
     testNumpy.assert_allclose(TransLine0, Line1)