how to label all 40000 rooms in mit
Jieruei Chang | 8/18/2025
MapIT’s pitch is simple: a campus map, but with room-level resolution. You’d be able to figure out exactly where that lecture is, hyperoptimize your class movement schedule, and not get lost trying to find your first-year advisor’s office at the end of freshman year (oops).
We made MapIT’s user interface as straightforward as possible―there’s only one search box. But behind it is a surprisingly complex jenga pipeline of computer vision, SVG parsers, and optical character recognition that's necessary to pinpoint the location of every single MIT room. It’s not that theoretically difficult; MIT has floorplans available online. The slight issue is that there are a lot of them. There’s nearly a thousand floorplans. There’s over forty thousand rooms. Herein we document my (Jieruei’s) slow descent into insanity as they tried to annotate, digitize, and make sense of every last classroom, closet, and broom cupboard on campus.
con-text-ualization
"Just run OCR on the floorplan," I hear you say. The reality is that all the lines and shapes and arcs in the floorplan create a surprisingly hostile environment for text recognition. In order to run OCR, we need some way of separating text from the rest of the geometry.
I experimented with geometry heuristics: detect long straight segments, classify near-horizontal or vertical lines, filter by aspect ratios, and erase everything that looks “architectural.” All of these ideas worked sometimes, but there were always edge cases. It would be too trigger-happy deleting SVG paths that it thought were part of the room layout and accidentally cut parts out of letters. It would be too conservative and leave a bunch of extra lines that messed with optical character recognition. I tried template matching using a set of predefined number and letter templates, but 1s look a lot like vertical lines. I tried morphological operations and contour detection, but text sometimes overlaps with the rest of the geometry.
In the end, I discovered that text is displayed slightly differently in SVG than the rest of the geometry. It's rendered with a slightly thicker stroke, and filtering by that solves the problem perfectly.
rooms for thought
Once we've separated geometry from text, we can also do some fun things like run a connected components floodfill on the de-textified floorplan to isolate all the different rooms. I’m sure there’s an algorithm out there to calculate intersections between lines and to analyze polygon geometry to find connected regions, but my background is in computer vision and when all you have is an image processing hammer, everything looks like an OpenCV-shaped nail. The code that generated the image below actually renders the entire SVG into a PNG file, runs floodfill and contour detection, and then finally redraws those contours back into the original SVG.