Okay, so I wanted to figure out how people move through train stations. You know, see the patterns, where they go, stuff like that. It seemed like a cool project, so I dove in.

First, I needed data. Obviously, I couldn’t just stand there with a notepad, that’s insane. So, I looked into getting access to some security camera footage. Turns out, that’s a whole can of worms with privacy rules and everything. I did manage to find some publicly available datasets, that had footage that was already blurred and anonymized, perfect!

Next, I had to get my hands dirty with some software. I’m not a coder, I am a blogger, but I’ve messed around with Python before. I found this thing called OpenCV, which is apparently the library for messing with images and videos. I also used another library called YOLO(you look only once), which is for detecting the object.

  • Installed Python (if you don’t have it already, it’s easy to find online).
  • Used pip (a Python package installer) to get OpenCV and YOLO. It was basically just typing pip install opencv-python and some other similar commands in the terminal. Don’t be scared, it’s easier than it sounds.

Then came the actual tracking part. This was tricky. I found some tutorials online (thank goodness for those!), and after a lot of trial and error, I managed to cobble together a script that:

  • Loaded the video file.
  • Used YOLO to detect people in each frame. It basically draws a box around each person it sees.
  • Assigned a unique ID to each person. This was the key to tracking them.
  • Tracked the movement of those boxes across frames. So, if box #1 moved from left to right, the script would “know” it was the same person.
  • Tracked the movement of each person with trajectory path.

It wasn’t perfect, not at all. Sometimes the script would lose track of someone, or mix up two people if they got too close. And the bounding boxes were sometimes jittery. But, it was working. I could see little boxes moving around, representing people flowing through the station!

Finally, I wanted to visualize the data. Just watching the boxes was okay, but I wanted something more…clear. I ended up using another Python library called Matplotlib to create a simple heatmap. Basically, it showed which areas of the station were most crowded, based on where the tracked people spent the most time.

I am so happy, that I have implemented it.