# Julian "trackpy" alternative?

**URL:** <https://discourse.julialang.org/t/julian-trackpy-alternative/32634>\
**Category:** Offtopic\
**Created:** [December 23, 2019, 8:46pm UTC](https://discourse.julialang.org/t/julian-trackpy-alternative/32634 "2019-12-23T20:46:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![francesco.alemanno](https://avatars.discourse-cdn.com/v4/letter/f/e8c25b/32.png) [@francesco.alemanno](https://discourse.julialang.org/u/francesco.alemanno)\
**Post date:** [December 23, 2019, 8:46pm UTC](https://discourse.julialang.org/t/julian-trackpy-alternative/32634/1 "2019-12-23T20:46:47Z")

</div>

does anyone know or is working on a Particle Tracking toolkit for Julia, in python there is a good package  
called “trackpy” :

[https://github.com/soft-matter/trackpy](https://github.com/soft-matter/trackpy)

is there any workable alternative for Julia?

---

<div class="post-metadata">

**Author:** ![ElOceanografo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eloceanografo/32/624_2.png) [@ElOceanografo](https://discourse.julialang.org/u/ElOceanografo)\
**Post date:** [January 2, 2020, 8:26pm UTC](https://discourse.julialang.org/t/julian-trackpy-alternative/32634/2 "2020-01-02T20:26:42Z")

</div>

I don’t know of one, though I have wished for something like this myself. A few years ago I started a package for Markov-chain Monte Carlo data association ([https://github.com/ElOceanografo/MCMCDA.jl](https://github.com/ElOceanografo/MCMCDA.jl)), which includes some data structures for target tracking in a radar context, but I never really finished it. This is something I would be potentially interested in contributing to, though I don’t have the time at the moment to take the lead on it…

---

<div class="post-metadata">

**Author:** ![ElOceanografo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eloceanografo/32/624_2.png) [@ElOceanografo](https://discourse.julialang.org/u/ElOceanografo)\
**Post date:** [January 14, 2020, 6:24pm UTC](https://discourse.julialang.org/t/julian-trackpy-alternative/32634/3 "2020-01-14T18:24:46Z")

</div>

In an odd and happy coincidence, @baggepinnen [announced](https://discourse.julialang.org/t/ann-blobtracking/33291) BlobTracking.jl a week after I posted the above. I haven’t played with it myself, but it is definitely worth checking out: [https://github.com/baggepinnen/BlobTracking.jl](https://github.com/baggepinnen/BlobTracking.jl)

---

<div class="post-metadata">

**Author:** ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)\
**Post date:** [January 15, 2020, 6:03am UTC](https://discourse.julialang.org/t/julian-trackpy-alternative/32634/4 "2020-01-15T06:03:26Z")

</div>

All the tracking in BlobTracking.jl is handled by [LowLevelParticleFilters.jl](https://github.com/baggepinnen/LowLevelParticleFilters.jl) which implements a few different flavors of particles filters, as well as (extended/unscented/vanilla) Kalman filters (used in BlobTracking).

The Markov-chain Monte Carlo data association stuff looks interesting 🙂 The data association in BlobTracking is rather primitive, only two methods are implemented, assignment using the hungarian algorithm or nearest neighbor.

---

<div class="post-metadata">

**Author:** ![ElOceanografo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/eloceanografo/32/624_2.png) [@ElOceanografo](https://discourse.julialang.org/u/ElOceanografo)\
**Post date:** [January 16, 2020, 6:00am UTC](https://discourse.julialang.org/t/julian-trackpy-alternative/32634/5 "2020-01-16T06:00:57Z")

</div>

Yeah, I never really finished the MCMCDA package. Particle/target tracking is not my expertise, but I keep needing to do it for one project or another.

I think it’s a task that Julia is well-suited for, and I’ve thought a bit about what kind of general interface might work for a more fully-featured tracking suite. I think the general pieces of this problem are:

1. Directed-graph-like data structure for keeping track of particles and their associations
2. Prediction functions to project where each particle will be in the next time step
3. A cost function for distance between a prediction and an observed particle
4. Models for the likelihood of missed detections and false positives
5. An association algorithm (nearest-neighbor, Hungarian, joint-probability data association, multiple-hypothesis tracking, MCMCDA, probability hypothesis density…)

I’d envision the user providing the data and defining functions for items 2-4, and the package having implementations of various association algorithms that could be dropped in and compared. Kind of like in `DifferentialEquations`, where the user defines a single derivative function and can run it using different solvers and compare results. Or in `Turing`, where the user defines a single model and can then sample it using different MCMC algorithms.

```julia
predict(particle, t) = ...
cost(predicted_x, detected_x) = ...
false_detection_rate(x, t) = ...
missed_detection_rate(x, t) = ...
algo1 = NearestNeighbor(predict)
algo2 = JPDA(predict, cost, false_detection_rate, missed_detection_rate)
tracks1 = associate(data, algo1)
tracks2 = associate(data, algo2)

```

Maybe some day I’ll even get around to working on something like this 🙃
