Beispiel #1
0
 def test_transform_from_static_exceptions(self, key, useables, s):
     """
     We test exceptions raised when there are not enough usable markers,
     the frame number is out of range, or the marker name does not exist.
     """
     data = self.data 
     static = self.static
     with pytest.raises(Exception):
         Pipelines.transform_from_static(data,static,key,useables,s)
Beispiel #2
0
    def test_transform_from_static_SampleData(self, key, useables, s, expected_result):
        """
        This function tests Pipelines.transform_from_static(data,static,key,useables,s),
        where data is an array of dictionaries of marker data,
        static is an array of static marker data, key is the name of the
        missing marker to perform gap filling for,
        useables is a list of markers in the same cluster as key,
        and s is the frame number that the marker data is missing for.

        We use files from SampleData/Sample_2/ for testing.
        We test for 6 missing frames from the loaded data.
        """
        data = self.data
        static = self.static
        #Clear given key and frame to test gap filling
        data[key][s] = np.array([np.nan, np.nan, np.nan])
        result = Pipelines.transform_from_static(data,static,key,useables,s)
        np.testing.assert_almost_equal(result, expected_result, self.rounding_precision)
Beispiel #3
0
    def test_transform_from_static(self):
        """
        This function tests Pipelines.transform_from_static().

        Pipelines.transform_from_static() uses a transformation that is stored between a 4 marker cluster.  
        It requires an inverse transformation matrix to be stored between the 
        combination of 3 marker groupings, with the 4th marker stored in relation to that frame. 
        
        Pipelines.transform_from_static() takes in as input the missing marker, and uses static data to 
        create an inverse transformation matrix, multiplying the new frame by the stored 
        inverse transform to get the missing marker position.

        We test that Pipelines.transform_from_mov() is accurate by creating four markers
        in a square in static data, and adding one to all but one of their x-coordinates
        for motion data.

        We ensure that the correct position is reconstructed from the static 
        data.
        """
        #Define the four markers, A, B, C, D, as the four corners of a square.
        static = {
            'A': np.array([[1, 1, 0]]),
            'B': np.array([[-1, 1, 0]]),
            'C': np.array([[1, -1, 0]]),
            'D': np.array([[-1, -1, 0]])
        }

        #Use the three markers, B, C, D to reconstruct the position of A
        useables = ['B', 'C', 'D']

        #Add one to all of the x-coordinates of B, C, D
        data = {
            'B': np.array([[0, 1, 0]]),
            'C': np.array([[2, -1, 0]]),
            'D': np.array([[0, -1, 0]])
        }

        #We expect that A is at [2, 1, 0]
        expected = np.array([2, 1, 0])
        result = Pipelines.transform_from_static(data, static, 'A', useables, 0)
        np.testing.assert_equal(result, expected)