コード例 #1
0
 def test_max_values_are_mapped_to_upper_bound(self):
     flow = np.array([20], dtype=np.float32)
     quantised_flow = quantise_flow(flow, bound=20)
     assert_array_equal(np.array([255], dtype=np.uint8), quantised_flow)
コード例 #2
0
 def test_negative_half_bound_is_mapped_to_quarter_of_255(self):
     bound = 20
     flow = np.array([-bound / 2], dtype=np.float32)
     quantised_flow = quantise_flow(flow, bound=20)
     assert_array_equal(np.array([(255 / 4)], dtype=np.uint8),
                        quantised_flow)
コード例 #3
0
 def test_values_below_bound_are_mapped_to_lower_bound(self):
     flow = np.array([-25], dtype=np.float32)
     quantised_flow = quantise_flow(flow, bound=20)
     assert_array_equal(np.array([0], dtype=np.uint8), quantised_flow)
コード例 #4
0
 def test_0_is_mapped_to_127(self):
     flow = np.array([0], dtype=np.float32)
     quantised_flow = quantise_flow(flow, bound=20)
     assert_array_equal(np.array([255 // 2], dtype=np.uint8),
                        quantised_flow)
コード例 #5
0
    def write(self, flow: np.ndarray) -> None:
        verify_flow_preconditions(flow)

        quantised_flow = quantise_flow(flow, bound=self.bound)
        self._write_uv_images(quantised_flow)
        self.frame_index += 1