Skip to content

Instantly share code, notes, and snippets.

@PirosB3
Created September 8, 2014 09:21
Show Gist options
  • Save PirosB3/65cd44b040b404b2b867 to your computer and use it in GitHub Desktop.
Save PirosB3/65cd44b040b404b2b867 to your computer and use it in GitHub Desktop.
[11:02am] PirosB3: Hi all, question of the day: if I have a array of [x,y,timestamp] vectors, taken every 1-2 seconds, can I calculate it’s path (or the function that passes through every point) ?
[11:02am] PirosB3: I was thinking of something like PCA + some function fitting algorithm
[11:03am] PirosB3: anyone have any suggestions? thanks
[11:03am] duschendestroyer: when you want a function that passes through every point, that is called interpolation
[11:03am] duschendestroyer: https://docs.scipy.org/doc/scipy-0.14.0/reference/tutorial/interpolate.html
[11:04am] PirosB3: oh great, thanks
[11:04am] PirosB3: if I have some noise in the x,y vectors
[11:04am] PirosB3: do you think PCA is any good to remove it?
[11:04am] duschendestroyer: algorithms in scikit-learn do regression, which does fit a function which has specific characteristics but doesn't necessary pass through every point
[11:05am] PirosB3: duschendestroyer: I don’t want to necessarily use this for prediction
[11:06am] duschendestroyer: PCA can reduce noise as long as the signal has a higher variance than the noise
[11:06am] PirosB3: I mostly need it to track the path of a given person throughout the system
[11:06am] duschendestroyer: maybe you want something like a kalman filter
[11:06am] PirosB3: interesting let me check that out
[11:07am] PirosB3: yes! kalman looks great!
[11:07am] PirosB3: are there any np, scipy, sckit implementations?
[11:08am] duschendestroyer: it's commonly used in person tracking
[11:08am] duschendestroyer: opencv has an implementation
[11:08am] PirosB3: very cool
[11:09am] PirosB3: so I assiume the output is some sort of function you can plot, correct?
[11:09am] duschendestroyer: but you can do it yourself easily: http://wiki.scipy.org/Cookbook/KalmanFiltering
[11:10am] PirosB3: yep! was just looking at that
[11:11am] PirosB3: could this be used to plot the path of a person in a closed area?
[11:11am] duschendestroyer: I think so
[11:12am] PirosB3: that’s great!
[11:12am] PirosB3: thanks so much duschendestroyer
[11:13am] darkelda left the chat room. (Ping timeout: 240 seconds)
[11:13am] PirosB3: duschendestroyer: are I know your a pro
[11:13am] PirosB3: I have another question for you
[11:14am] PirosB3: so, let’s say you have a array of [x,y] vectors, and you need to find the heat spots, the areas that are most “used”
[11:14am] dharmit joined the chat room.
[11:14am] dharmit left the chat room. (Changing host)
[11:14am] dharmit joined the chat room.
[11:14am] PirosB3: so I was thinking, simple unsupervised clustering
[11:15am] PirosB3: but what if I don’t know K? it can be different at times..
[11:15am] PirosB3: is there any way to “find” k? for something like knn?
[11:16am] duschendestroyer: you want kernel density estimation
[11:16am] PirosB3: and kernel density esitmation would give you a K?
[11:17am] PirosB3: so it would be kernel_density_estimation -> kmeans
[11:17am] duschendestroyer: kernel density estimation would give you something like a heatmap
[11:17am] PirosB3: ooooh, nice
[11:18am] PirosB3: and laaaast question then you can ask me questions (assuming I might not know the answers!)
[11:19am] PirosB3: if I have a array of vector [x,y]
[11:19am] PirosB3: oops, [x,y,timestamp]
[11:19am] PirosB3: how do I find out if a person has reached a specific area?
[11:19am] PirosB3: like: “has the person reached the area [x,y, width, height] ?”
[11:20am] PirosB3: is it possible to answer a question like this?
[11:20am] PirosB3: thanks again duschendestroyer
[11:20am] duschendestroyer: just check every point if it's in the area
[11:21am] duschendestroyer: x_area < x < x_area+width and y_area < y y y_area+height
[11:21am] PirosB3: oh okay, but what if it’s near “enough” to the area?
[11:21am] duschendestroyer: x_area < x < x_area+width and y_area < y < y_area+height
[11:21am] PirosB3: shoild I just add a threshold to the area?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment