コード例 #1
0
    def test_get_typename(self):
        # Returns C++ std::type_info.name values
        f = Feature(ctype=ctypes.c_double)
        nose.tools.assert_equal(f.type_name, 'd')

        f = Feature(ctype=ctypes.c_float)
        nose.tools.assert_equal(f.type_name, 'f')
コード例 #2
0
ファイル: test_track.py プロジェクト: nagyist/kwiver
    def test_ts_feat_desc(self):
        t = Track()

        f0 = Feature(mag=0)
        d0 = Descriptor(4)
        d0[:] = 0
        t.append(TrackState(0, f0, d0))

        f1 = Feature(mag=1)
        d1 = Descriptor(4)
        d1[:] = 1
        t.append(TrackState(1, f1, d1))

        nose.tools.assert_equal(t.size, 2)
        nose.tools.assert_equal(len(t), 2)
        ts0 = t.find_state(0)
        nose.tools.assert_equal(ts0.feature, f0)
        numpy.testing.assert_equal(ts0.descriptor, d0)

        ts1 = t.find_state(1)
        nose.tools.assert_equal(ts1.feature, f1)
        numpy.testing.assert_equal(ts1.descriptor, d1)

        # Delete local descriptor references, get track states and check
        # descriptor values manually
        del f0, f1, d0, d1, ts0, ts1
        # Now, only the track-state in C++ has feature/descriptor references
        numpy.testing.assert_equal(t.find_state(0).descriptor, [0, 0, 0, 0])
        numpy.testing.assert_equal(t.find_state(1).descriptor, [1, 1, 1, 1])
コード例 #3
0
    def test_get_color(self):
        dflt_color = RGBColor()
        f = Feature()
        nose.tools.assert_equal(f.color, dflt_color)

        c = RGBColor(5, 32, 10)
        f = Feature(rgb_color=c)
        nose.tools.assert_equal(f.color, c)
コード例 #4
0
ファイル: track.py プロジェクト: nagyist/kwiver
 def feature(self):
     f_ptr = self._call_cfunc("vital_track_state_feature",
                              [self.C_TYPE_PTR], [self],
                              Feature.c_ptr_type())
     # f_ptr may be null
     if f_ptr:
         return Feature(from_cptr=f_ptr)
     else:
         return None
コード例 #5
0
    def test_get_location(self):
        f = Feature()
        numpy.testing.assert_almost_equal(f.location, [[0], [0]])

        expected = [[12.3], [643]]
        f = Feature(loc=expected)
        numpy.testing.assert_almost_equal(f.location, expected)
        # iterable form
        f = Feature(loc=(12.3, 643))
        numpy.testing.assert_almost_equal(f.location, expected)
コード例 #6
0
ファイル: test_feature.py プロジェクト: ALouis38/vital
    def test_set_color(self):
        expected = RGBColor(4, 20, 0)

        f = Feature(ctype=ctypes.c_double)
        nose.tools.assert_equal(f.color, RGBColor())
        f.color = expected
        nose.tools.assert_equal(f.color, expected)

        f = Feature(ctype=ctypes.c_float)
        nose.tools.assert_equal(f.color, RGBColor())
        f.color = expected
        nose.tools.assert_equal(f.color, expected)
コード例 #7
0
ファイル: test_feature.py プロジェクト: ALouis38/vital
    def test_set_scale(self):
        f = Feature(ctype=ctypes.c_double)
        nose.tools.assert_equal(f.scale, 1)  # default value
        expected = random.random()
        f.scale = expected
        nose.tools.assert_almost_equal(f.scale, expected, 16)

        f = Feature(ctype=ctypes.c_float)
        nose.tools.assert_equal(f.scale, 1)  # default value
        expected = random.random()
        f.scale = expected
        nose.tools.assert_almost_equal(f.scale, expected, 6)
コード例 #8
0
ファイル: test_feature.py プロジェクト: Kitware/kwiver
    def test_set_angle(self):
        f = Feature(ctype='d')
        nose.tools.assert_equal(f.angle, 0)  # default value
        expected = random.random()
        f.angle = expected
        nose.tools.assert_almost_equal(f.angle, expected, 16)

        f = Feature(ctype='f')
        nose.tools.assert_equal(f.angle, 0)  # default value
        expected = random.random()
        f.angle = expected
        nose.tools.assert_almost_equal(f.angle, expected, 6)
コード例 #9
0
ファイル: test_feature.py プロジェクト: Kitware/kwiver
    def test_set_color(self):
        expected = RGBColor(4, 20, 0)

        f = Feature(ctype='d')
        nose.tools.assert_equal(f.color, RGBColor())
        f.color = expected
        nose.tools.assert_equal(f.color, expected)

        f = Feature(ctype='f')
        nose.tools.assert_equal(f.color, RGBColor())
        f.color = expected
        nose.tools.assert_equal(f.color, expected)
コード例 #10
0
ファイル: test_feature.py プロジェクト: Kitware/kwiver
    def test_set_location(self):
        f = Feature(ctype='d')
        expected = [random.random(),
                    random.random()]
        f.location = expected
        # making sure that we went through the setter, and not just setting the
        # exact value to the property
        numpy.testing.assert_almost_equal(f.location, expected, 16)

        f = Feature(ctype='f')
        expected = [random.random(),
                    random.random()]
        f.location = expected
        numpy.testing.assert_almost_equal(f.location, expected, 6)
コード例 #11
0
ファイル: test_feature.py プロジェクト: ALouis38/vital
    def test_set_location(self):
        f = Feature(ctype=ctypes.c_double)
        expected = [[random.random()],
                    [random.random()]]
        f.location = expected
        # making sure that we went through the setter, and not just setting the
        # exact value to the property
        nose.tools.assert_is_instance(f.location, EigenArray)
        numpy.testing.assert_almost_equal(f.location, expected, 16)

        f = Feature(ctype=ctypes.c_float)
        expected = [[random.random()],
                    [random.random()]]
        f.location = expected
        nose.tools.assert_is_instance(f.location, EigenArray)
        numpy.testing.assert_almost_equal(f.location, expected, 6)
コード例 #12
0
ファイル: test_feature.py プロジェクト: ALouis38/vital
    def test_set_covar(self):
        f = Feature(ctype=ctypes.c_double)
        nose.tools.assert_equal(f.covariance, Covariance())

        expected = [[1, 2],
                    [3, 4]]
        c = Covariance(2, ctypes.c_double, expected)
        f.covariance = c
        nose.tools.assert_equal(f.covariance, c)
        # Should also work if we just give it the raw iterable
        f.covariance = expected
        nose.tools.assert_equal(f.covariance, c)

        # And for floats...
        f = Feature(ctype=ctypes.c_float)
        nose.tools.assert_equal(f.covariance, Covariance())

        expected = [[1, 2],
                    [3, 4]]
        c = Covariance(2, ctypes.c_float, expected)
        f.covariance = c
        nose.tools.assert_equal(f.covariance, c)
        # Should also work if we just give it the raw iterable
        f.covariance = expected
        nose.tools.assert_equal(f.covariance, c)
コード例 #13
0
    def test_new_ts(self):
        TrackState(0)
        TrackState(23456)

        # With feat, desc, feat/desc
        f = Feature()
        d = Descriptor()
        TrackState(0, feature=f)
        TrackState(0, descriptor=d)
        TrackState(0, f, d)

        # Only integers
        nose.tools.assert_raises(ctypes.ArgumentError, TrackState, 1.2)
        nose.tools.assert_raises(ctypes.ArgumentError, TrackState, 'foo')
コード例 #14
0
    def _new(self, frame, feature, descriptor):
        """
        :param feature: Optional Feature instance associated with this state.
        :type feature: vital.types.Feature

        :param descriptor: Optional Descriptor instance associated with this
            state.
        :type descriptor: vital.types.Descriptor
        """
        return self._call_cfunc(
            "vital_feature_track_state_new",
            [ctypes.c_int64, Feature.c_ptr_type(), Descriptor.c_ptr_type()],
            [frame, feature, descriptor],
            self.C_TYPE_PTR
        )
コード例 #15
0
    def test_set_angle(self):
        f = Feature(ctype=ctypes.c_double)
        nose.tools.assert_equal(f.angle, 0)  # default value
        expected = random.random()
        f.angle = expected
        nose.tools.assert_almost_equal(f.angle, expected, 16)

        f = Feature(ctype=ctypes.c_float)
        nose.tools.assert_equal(f.angle, 0)  # default value
        expected = random.random()
        f.angle = expected
        nose.tools.assert_almost_equal(f.angle, expected, 6)
コード例 #16
0
ファイル: test_feature.py プロジェクト: vanthaiunghoa/kwiver
    def test_set_color(self):
        expected = RGBColor(4, 20, 0)

        f = Feature(ctype='d')
        nose.tools.assert_equal(f.color, RGBColor())
        f.color = expected
        nose.tools.assert_equal(f.color, expected)

        f = Feature(ctype='f')
        nose.tools.assert_equal(f.color, RGBColor())
        f.color = expected
        nose.tools.assert_equal(f.color, expected)
コード例 #17
0
ファイル: test_feature.py プロジェクト: vanthaiunghoa/kwiver
    def test_set_location(self):
        f = Feature(ctype='d')
        expected = [random.random(), random.random()]
        f.location = expected
        # making sure that we went through the setter, and not just setting the
        # exact value to the property
        numpy.testing.assert_almost_equal(f.location, expected, 16)

        f = Feature(ctype='f')
        expected = [random.random(), random.random()]
        f.location = expected
        numpy.testing.assert_almost_equal(f.location, expected, 6)
コード例 #18
0
ファイル: test_feature.py プロジェクト: vanthaiunghoa/kwiver
    def test_set_scale(self):
        f = Feature(ctype='d')
        nose.tools.assert_equal(f.scale, 1)  # default value
        expected = random.random()
        f.scale = expected
        nose.tools.assert_almost_equal(f.scale, expected, 16)

        f = Feature(ctype='f')
        nose.tools.assert_equal(f.scale, 1)  # default value
        expected = random.random()
        f.scale = expected
        nose.tools.assert_almost_equal(f.scale, expected, 6)
コード例 #19
0
    def test_set_color(self):
        expected = RGBColor(4, 20, 0)

        f = Feature(ctype=ctypes.c_double)
        nose.tools.assert_equal(f.color, RGBColor())
        f.color = expected
        nose.tools.assert_equal(f.color, expected)

        f = Feature(ctype=ctypes.c_float)
        nose.tools.assert_equal(f.color, RGBColor())
        f.color = expected
        nose.tools.assert_equal(f.color, expected)
コード例 #20
0
    def test_set_location(self):
        f = Feature(ctype=ctypes.c_double)
        expected = [[random.random()], [random.random()]]
        f.location = expected
        # making sure that we went through the setter, and not just setting the
        # exact value to the property
        nose.tools.assert_is_instance(f.location, EigenArray)
        numpy.testing.assert_almost_equal(f.location, expected, 16)

        f = Feature(ctype=ctypes.c_float)
        expected = [[random.random()], [random.random()]]
        f.location = expected
        nose.tools.assert_is_instance(f.location, EigenArray)
        numpy.testing.assert_almost_equal(f.location, expected, 6)
コード例 #21
0
ファイル: test_feature.py プロジェクト: vanthaiunghoa/kwiver
    def test_set_covar(self):
        f = Feature(ctype='d')
        #nose.tools.assert_equal(f.covariance, Covariance.new_covar())

        expected = [[1, 2], [3, 4]]
        c = Covariance.from_matrix(2, 'd', expected)
        f.covariance = c
        #nose.tools.assert_equal(f.covariance, c)
        # Should also work if we just give it the raw iterable
        f.covariance = expected
        #nose.tools.assert_equal(f.covariance, c)

        # And for floats...
        f = Feature(ctype='f')
        #nose.tools.assert_equal(f.covariance, Covariance())

        expected = [[1, 2], [3, 4]]
        c = Covariance.from_matrix(2, 'f', expected)
        f.covariance = c
        #nose.tools.assert_equal(f.covariance, c)
        # Should also work if we just give it the raw iterable
        f.covariance = expected
コード例 #22
0
    def test_set_covar(self):
        f = Feature(ctype=ctypes.c_double)
        nose.tools.assert_equal(f.covariance, Covariance())

        expected = [[1, 2], [3, 4]]
        c = Covariance(2, ctypes.c_double, expected)
        f.covariance = c
        nose.tools.assert_equal(f.covariance, c)
        # Should also work if we just give it the raw iterable
        f.covariance = expected
        nose.tools.assert_equal(f.covariance, c)

        # And for floats...
        f = Feature(ctype=ctypes.c_float)
        nose.tools.assert_equal(f.covariance, Covariance())

        expected = [[1, 2], [3, 4]]
        c = Covariance(2, ctypes.c_float, expected)
        f.covariance = c
        nose.tools.assert_equal(f.covariance, c)
        # Should also work if we just give it the raw iterable
        f.covariance = expected
        nose.tools.assert_equal(f.covariance, c)
コード例 #23
0
ファイル: helpers.py プロジェクト: nagyist/kwiver
def projected_tracks(lmap, cmap):
    """
    Use the cameras to project the landmarks back into their images.
    :type lmap: LandmarkMap
    :type cmap: CameraMap
    """
    tracks = []

    cam_d = cmap.as_dict()
    landmark_d = lmap.as_dict()

    for lid, l in landmark_d.iteritems():
        t = Track(lid)
        tracks.append(t)

        # Sort camera iteration to make sure that we go in order of frame IDs
        for fid in sorted(cam_d):
            cam = cam_d[fid]
            f = Feature(cam.project(l.loc))
            t.append(TrackState(fid, f))

        assert t.size == len(cam_d)

    return TrackSet(tracks)
コード例 #24
0
ファイル: test_feature.py プロジェクト: Kitware/kwiver
    def test_set_covar(self):
        f = Feature(ctype='d')
        #nose.tools.assert_equal(f.covariance, Covariance.new_covar())

        expected = [[1, 2],
                    [3, 4]]
        c = Covariance.from_matrix(2, 'd', expected)
        f.covariance = c
        #nose.tools.assert_equal(f.covariance, c)
        # Should also work if we just give it the raw iterable
        f.covariance = expected
        #nose.tools.assert_equal(f.covariance, c)

        # And for floats...
        f = Feature(ctype='f')
        #nose.tools.assert_equal(f.covariance, Covariance())

        expected = [[1, 2],
                    [3, 4]]
        c = Covariance.from_matrix(2, 'f', expected)
        f.covariance = c
        #nose.tools.assert_equal(f.covariance, c)
        # Should also work if we just give it the raw iterable
        f.covariance = expected
コード例 #25
0
ファイル: test_feature.py プロジェクト: vanthaiunghoa/kwiver
 def test_get_covar(self):
     dflt_covar = Covariance.new_covar(2)
     f = Feature()
コード例 #26
0
 def test_get_covar(self):
     dflt_covar = Covariance(2)
     f = Feature()
     nose.tools.assert_equal(f.covariance, dflt_covar)
コード例 #27
0
    def test_get_angle(self):
        f = Feature()
        nose.tools.assert_equal(f.angle, 0)

        f = Feature(angle=1.1)
        nose.tools.assert_equal(f.angle, 1.1)
コード例 #28
0
    def test_get_scale(self):
        f = Feature()
        nose.tools.assert_equal(f.scale, 1)

        f = Feature(scale=2.1)
        nose.tools.assert_equal(f.scale, 2.1)
コード例 #29
0
    def test_get_mag(self):
        f = Feature()
        nose.tools.assert_equal(f.magnitude, 0)

        f = Feature(mag=1.1)
        nose.tools.assert_equal(f.magnitude, 1.1)
コード例 #30
0
 def test_new(self):
     f1 = Feature()
     f2 = Feature([1, 1], 1, 2, 1)
コード例 #31
0
 def test_feat(self):
     f = Feature()
     ts = TrackState(0, f)
     nose.tools.assert_equal(ts.feature, f)