That library has a kernel density estimator function called kdeplot: This is where the kernels have pushed the resulting KDE up the highest:Īnd that, ladies and gentlemen is how you create a heatmap from a file containing coordinate locations.Īnd what about some accompanying code? For the project that I worked on, I used the seaborn Python visualisation library. Notice the hot colours at the more congested locations. Here’s a top-down view example but with more kernels (at the locations of the white points). Take a look at the 3D picture of a single Gaussian kernel above and picture looking down at that curve from above. It’s just a fancy name for a concept that really, in it’s core, isn’t too hard to understand!Ī kernel density estimation can be performed in 3D as well and this is exactly what can be done with the coordinates in your “coords.txt” file. This final plot of Gaussian kernels is actually called a kernel density estimation (KDE). Gaussian kernels stacked on top of each other ( image source) The three congested kernels on the left push (by addition) the resulting curve up the highest. There are 6 coordinates (the black marks on the x-axis) and a kernel placed at each of these (red dashed lines). The following image shows this idea well. If you have clusters of points at a similar location, the Gaussian kernels at these locations would all push each other up. So, for example, with the 2D kernel image above, if we were to put another kernel at the exact same location, the peak of the kernel would reach 0.8 (0.4 + 0.4 = 0.8). The trick here is to notice that when Gaussian kernels overlap, their values are added together (where the overlapping occurs). With respect to our heatmaps, then, the idea is to place one of these Gaussian kernels at each coordinate location that we have in our “coords.txt” file. For this post, all you need to know is that it’s a specific type of curve. If you would like to read up on them, this pdf goes into a lot of explanatory detail and this page explains nicely why it is so commonly used in the trade. Now, I’m not going to go into too much detail on Gaussian kernels because it would involve venturing into university mathematics. That curve can also be drawn in 3D, like so (notice the hot and cold colours here!): That’s just a fancy name for a particular type of curve. If we were to generate a heatmap here, you would expect there to be hot colours around (210, 300) and cooler colours at (200, 300) through to (210, 300).īut how do we get these hot and cold colours around our points and make the heatmap look smooth and beautiful? Well, some of you may have heard of a thing called a Gaussian kernel. In this example we have somebody moving horizontally 5 pixels for two time intervals and then standing still for 3 time intervals. For example, you might have something like this in a file called “coords.txt”: Each line in the file is a coordinate at a specific point in time. I’m going to assume that you have a list of coordinates in a file denoting the location of people on a 2D floor plan (see my previous post for how to obtain such a file from CCTV footage). In this post I will present you one way with some supporting code at the end. There are many ways to create these heatmaps. There, the hotter regions denote where more time was spent gazing by viewers. The diagram at the top of this post shows an example heatmap for eye-tracking data (I did my PhD in eye-tracking, so this brings back memories :P) on a Wikipedia page. Generally speaking, the more congested data is at a particular location, the hotter will be the colour used to represent this data. There is, however, another thing that can be done with these extracted 2D coordinates of tracked people: generation of heatmaps.Ī heatmap is a visual representation or summary of data that uses colour to represent data values. This is an example of video analytics and data mining that can be performed on standard CCTV footage that can give you insightful information such as common movement patterns or common places of congestion at particular times of the day. In last week’s post I talked about plotting tracked customers or staff from video footage onto a 2D floor plan.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |