Exemplo n.º 1
0
    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])
Exemplo n.º 2
0
    def test_track_find(self):
        t = Track()
        t.append(TrackState(0))
        t.append(TrackState(1))
        t.append(TrackState(5))
        t.append(TrackState(9))

        ts = t.find_state(0)
        nose.tools.assert_is_not_none(ts)
        nose.tools.assert_equal(ts.frame_id, 0)

        ts = t.find_state(1)
        nose.tools.assert_is_not_none(ts)
        nose.tools.assert_equal(ts.frame_id, 1)

        ts = t.find_state(5)
        nose.tools.assert_is_not_none(ts)
        nose.tools.assert_equal(ts.frame_id, 5)

        ts = t.find_state(9)
        nose.tools.assert_is_not_none(ts)
        nose.tools.assert_equal(ts.frame_id, 9)

        nose.tools.assert_raises(
            IndexError,
            t.find_state, 10
        )
        t.append(TrackState(10))
        nose.tools.assert_is_not_none(t.find_state(10))
        nose.tools.assert_equal(t.find_state(10).frame_id, 10)
Exemplo n.º 3
0
    def test_track_find(self):
        t = Track()
        t.append(TrackState(0))
        t.append(TrackState(1))
        t.append(TrackState(5))
        t.append(TrackState(9))

        ts = t.find_state(0)
        nose.tools.assert_is_not_none(ts)
        nose.tools.assert_equal(ts.frame_id, 0)

        ts = t.find_state(1)
        nose.tools.assert_is_not_none(ts)
        nose.tools.assert_equal(ts.frame_id, 1)

        ts = t.find_state(5)
        nose.tools.assert_is_not_none(ts)
        nose.tools.assert_equal(ts.frame_id, 5)

        ts = t.find_state(9)
        nose.tools.assert_is_not_none(ts)
        nose.tools.assert_equal(ts.frame_id, 9)

        nose.tools.assert_raises(IndexError, t.find_state, 10)
        t.append(TrackState(10))
        nose.tools.assert_is_not_none(t.find_state(10))
        nose.tools.assert_equal(t.find_state(10).frame_id, 10)