Example #1
0
def load_tracks(path, type):
    database = DataFileExtended(path)
    Tracks = {}
    if database.getTracks(type=type)[0].markers[0].measurement is not None:
        for track in database.getTracks(type=type):
            Tracks.update({track.id: Filter(VariableSpeed(dim=3))})
            for m in track.markers:
                meas = Measurement(1., [m.measurement[0].x,
                                        m.measurement[0].y,
                                        m.measurement[0].z])
                Tracks[track.id].update(z=meas, i=m.image.sort_index)
    else:
        for track in database.getTracks(type=type):
            Tracks.update({track.id: Filter(VariableSpeed(dim=3))})
            for m in track.markers:
                meas = Measurement(1., [m.x,
                                        m.y,
                                        0])
                Tracks[track.id].update(z=meas, i=m.image.sort_index)
    return Tracks
Example #2
0
import numpy as np
import seaborn as sn
import matplotlib.pyplot as plt
from PenguTrack.DataFileExtended import DataFileExtended

file_path = "/home/user/Desktop/Birdflight.cdb"
db = DataFileExtended(file_path)

PT_Track_Type = db.getMarkerType(name="PT_Track_Marker")
PT_Detection_Type = db.getMarkerType(name="PT_Detection_Marker")
PT_Prediction_Type = db.getMarkerType(name="PT_Prediction_Marker")
GT_Type = db.getMarkerType(name="GT")

Tracks = db.getTracks(type=PT_Track_Type)

mean_phi = []
phies = []
std_phi = []
mean_len = []
lens = []

for track in Tracks:
    if track.markers.count() < 3:
        continue
    x = np.asarray([[m.x, m.y] for m in track.markers])
    del_x = x[1:] - x[:-1]
    del_x_norm = np.linalg.norm(del_x, axis=1)
    try:
        # phi = np.tensordot(del_x[1:],del_x[:-1].T, axes=1)/del_x_norm[1:]/del_x_norm[:-1]
        phi = np.diag(np.tensordot(del_x[1:], del_x[:-1].T,
                                   axes=1)) / del_x_norm[1:] / del_x_norm[:-1]
Example #3
0
from PenguTrack.DataFileExtended import DataFileExtended
import numpy as np

db = DataFileExtended(
    "/home/alex/Masterarbeit/Data/Cells/DataBases/PT_Cell_T850_A75_inf_3d_backup.cdb"
)
tracks = db.getTracks(type="PT_Track_Marker")

# db = DataFileExtended("/home/alex/Desktop/PT_Cell_GT_Track.cdb")
# tracks = db.getTracks(type="GroundTruth")
V = []
vals = {}
for track in tracks:
    if track.markers.count() < 4:
        continue
    x, y, z, t = np.array([[
        m.measurement[0].x * 0.646, m.measurement[0].y * 0.645,
        m.measurement[0].z * 0.645, m.image.timestamp
    ] for m in track.markers]).T
    # x,y,z,t = np.array([[m.x*0.646, m.y*0.645, 0, m.image.timestamp] for m in track.markers]).T
    n = 10.
    # z = np.convolve(z, np.ones(n)/n, mode="same") if len(z)>n else z
    t = (np.array([tt.total_seconds() for tt in t[1:] - t[:-1]], dtype=float))
    vx = ((x[1:] - x[:-1]) / t).astype(float)
    vy = ((y[1:] - y[:-1]) / t).astype(float)
    vz = ((z[1:] - z[:-1]) / t).astype(float)
    # vz = np.convolve(vz, np.ones(10)/10., mode="same") if len(vz)>10 else vz

    # v = (vx**2+vy**2+vz**2)**0.5
    v = (vx**2 + vy**2)**0.5
    print(np.nanmean(v), np.mean(np.abs(vz)), np.mean(vx), np.mean(vy))
Example #4
0
                                  log=meas.Log_Probability,
                                  x=x,
                                  y=y)
    print("Got %s Filters" % len(MultiKal.ActiveFilters.keys()))

print('done with Tracking')


def trans_func(pos):
    x, y, z = pos
    x_px = x * (VB.height / VB.Max_Dist)
    y_px = y * (VB.height / VB.Max_Dist)
    x_new, y_new = VB.warp_orth(
        [VB.Res * (y_px - VB.width / 2.), VB.Res * (VB.height - x_px)])
    return x_new, y_new, z


# Initialize Stitcher
stitcher = Heublein_Stitcher(25, 0., 50, 60, 200, 5)
stitcher.add_PT_Tracks_from_Tracker(MultiKal.Filters)
print("Initialized Stitcher")
stitcher.stitch()
stitcher.save_tracks_to_db(file_path, marker_type4, function=trans_func)
print("Written Stitched Tracks to DB")

db.deleteTracks(id=[
    track.id for track in db.getTracks(type=marker_type4)
    if len(track.markers) < 3
])
print("Deleted short tracks")