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)
def test_set_magnitude(self): f = Feature(ctype=ctypes.c_double) nose.tools.assert_equal(f.magnitude, 0) # default value expected = random.random() f.magnitude = expected nose.tools.assert_almost_equal(f.magnitude, expected, 16) f = Feature(ctype=ctypes.c_float) nose.tools.assert_equal(f.magnitude, 0) # default value expected = random.random() f.magnitude = expected nose.tools.assert_almost_equal(f.magnitude, expected, 6)
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)
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)
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)
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
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
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)
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')
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)
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)
def test_get_covar(self): dflt_covar = Covariance(2) f = Feature() nose.tools.assert_equal(f.covariance, dflt_covar)
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)
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)
def test_new(self): f1 = Feature() f2 = Feature([1, 1], 1, 2, 1)
def test_get_covar(self): dflt_covar = Covariance.new_covar(2) f = Feature()
def test_feat(self): f = Feature() ts = TrackState(0, f) nose.tools.assert_equal(ts.feature, f)