Exemplo n.º 1
0
def cvpred(X1, X2):
    """Make prediction (target) based on two observations.
    Expects two EllipseLists, returns a single EllipseList."""

    X3 = ell.TargetList()
    # set position and size as an extrapolation
    for ee in X2.iterkeys():
        if X1.hasItem(ee):

            # only use the cv prediction if not jumping
            dx = X2[ee].center.x - X1[ee].center.x
            dy = X2[ee].center.y - X1[ee].center.y
            centerd = num.sqrt((dx**2. + dy**2.))
            if centerd >= params.min_jump:
                new_x = X2[ee].center.x
                new_y = X2[ee].center.y
                dangle = X2[ee].angle
            else:
                new_x = X2[ee].center.x + (1. - params.dampen) * dx
                new_y = X2[ee].center.y + (1. - params.dampen) * dy
                dangle = ((X2[ee].angle - X1[ee].angle + num.pi/2.) \
                    % (num.pi)) - (num.pi/2.)

            new_w = X2[ee].size.width
            new_h = X2[ee].size.height
            new_angle = X2[ee].angle + (1. - params.angle_dampen) * dangle
            X3.append(
                ell.Ellipse(new_x, new_y, new_w, new_h, new_angle,
                            X2[ee].identity))
        else:
            X3.append(X2[ee].copy())

    return X3
Exemplo n.º 2
0
    return h


try:
    os.remove('tmp.ann')
except:
    pass
tracks = ann.AnnotationFile('tmp.ann', None, True, False, False)
tracks.InitializeData(0, -1)
tracks.InitializeBufferForTracking(0)
# tracks = []

# frame 0
tracks.append(ell.TargetList())
# just one ellipse with id = 0
tracks[0][0] = ell.Ellipse(10., 10., 1., 2., num.pi / 3, 0., 0)
tracks[0][0].compute_area()
# frame 1
# just one ellipse with id = 0
tracks.append(ell.TargetList())
tracks[1][0] = tracks[0][0].copy()
tracks[1][0].x += 10.
tracks[1][0].y += 10.
# frame 2
# detection missed at pred
# new ellipse at another location
tracks.append(ell.TargetList())
#tracks[2][1] = ell.Ellipse(20.,20.,1.,2.,num.pi/3,0.,1)
prev = tracks[0].copy()
curr = tracks[1].copy()
pred = matchidentities.cvpred(prev, curr)
Exemplo n.º 3
0
    # append the targets that didn't match any observation
    for oo in range(len(obs)):
        if unass_obs[oo]:
            obs[oo].identity = params.nids
            params.nids += 1
            flies.append(obs[oo])

    return (flies, obs_for_target, unass_obs)


tracks_true = []
cc = []

# frame 0
tracks_true.append(ell.TargetList())
tracks_true[0][0] = ell.Ellipse(50., 10., 2., 4., num.pi / 3, 0., 0)
tracks_true[0][0].compute_area()
# frame 1
tracks_true.append(ell.TargetList())
tracks_true[1][0] = ell.Ellipse(50., 20., 2., 4., num.pi / 3, 0., 0)
tracks_true[1][0].compute_area()
for t in range(2, 9):
    tracks_true.append(matchidentities.cvpred(tracks_true[-2],
                                              tracks_true[-1]))

bw = []
bounds = [0, 100, 0, 100]
nr = bounds[1] - bounds[0]
nc = bounds[3] - bounds[2]
for track_true in tracks_true:
    tmp = num.zeros((nr, nc), dtype=bool)
Exemplo n.º 4
0
def add_fly(annfile, x, y, theta):
    flies = ell.TargetList()
    flies.append(ell.Ellipse(x, y, 5., 10., theta, 25., 0))
    annfile.append(flies)
Exemplo n.º 5
0
    # append the targets that didn't match any observation
    for oo in range(len(obs)):
        if unass_obs[oo]:
            obs[oo].identity = params.nids
            params.nids += 1
            flies.append(obs[oo])

    return (flies, obs_for_target, unass_obs)


tracks_true = []
cc = []

# frame 0
tracks_true.append(ell.TargetList())
tracks_true[0][0] = ell.Ellipse(37., 70., 2., 4., num.pi / 3, 0., 0)
tracks_true[0][0].compute_area()
tracks_true[0][1] = ell.Ellipse(60., 70., 2., 4., num.pi / 3, 0., 1)
tracks_true[0][1].compute_area()
# frame 1
tracks_true.append(ell.TargetList())
tracks_true[1][0] = ell.Ellipse(37., 62., 2., 4., num.pi / 3, 0., 0)
tracks_true[1][0].compute_area()
tracks_true[1][1] = ell.Ellipse(53., 62., 2., 4., num.pi / 3, 0., 1)
tracks_true[1][1].compute_area()
for t in range(2, 8):
    tracks_true.append(matchidentities.cvpred(tracks_true[-2],
                                              tracks_true[-1]))

bw = []
bounds = [0, 100, 0, 100]