What “detecting parking spaces” actually means in practice
When people say “detect parking spaces,” they often mean three different jobs that get mixed together: finding the stall geometry (where each space begins and ends), assigning a stable ID to each stall so it stays the same across frames and days, and deciding occupancy (free vs taken) with a confidence you can act on. Mask R-CNN can help with the first part by segmenting paint, curbs, or stall regions, but it doesn’t magically solve the other two.
In practice, the hard cases drive the design: a truck straddling a line, snow or glare erasing paint, shadows that look like cars, and cameras that shift after maintenance. You’ll also need a definition for edge cases (motorcycles, overhang, double-parking) and an evaluation target (per-stall accuracy over time, not just “nice masks”). That’s where effort and cost usually show up: labeling, tuning thresholds, and building rules for the messy 10%.
Where Mask R-CNN shines—and where it struggles
Mask R-CNN is strong when the visual cue you care about is genuinely segmentable: crisp stall paint, consistent curb edges, or a distinct stall surface that stands out from asphalt. It can separate overlapping shapes better than a plain detector, which helps when a car partially covers a line or when you want a mask you can later turn into geometry. It also adapts reasonably well if you fine-tune on your specific camera views instead of betting on a generic model.
It struggles when the “object” is more of an idea than a shape. Faded paint, puddle reflections, heavy shadows, nighttime headlight bloom, snow cover, and tight occlusions can collapse mask quality fast. Small perspective changes matter too: a camera bumped a few degrees can move masks enough to break stall boundaries unless you add calibration or re-train. The practical constraint is cost and latency—instance segmentation is heavier to train, label, and run, so you’ll feel it on edge devices and in annotation hours long before you feel “better masks.”
Choosing targets: segment stall lines, whole stalls, or curbs

A familiar fork in the road is deciding what the model should “see” as the thing to segment: the painted stall lines, the whole stall region, or fixed infrastructure like curbs and wheel stops. Segmenting lines can work well when paint is crisp, because a thin mask can be converted into clean geometry. The catch is that lines are small targets in the image, so label quality has to be high and performance drops quickly with glare, salt, or worn markings.
Segmenting whole stalls feels conceptually simpler (“this polygon is space #27”), but you’re asking the model to hallucinate boundaries under occlusion—exactly what happens when a parked car covers most of the stall. Curbs and wheel stops are often the most stable targets across seasons and occupancy, so they’re useful anchors, but they don’t exist everywhere and may be visually similar to other edges. The practical choice is usually driven by what’s consistently visible in your specific camera view, not what’s theoretically ideal.
Data and annotations: the real cost of “it works”
The first time a demo “works,” it’s usually because the camera view, time of day, and markings match the handful of images you tested. The real question is how many labeled examples it takes before it keeps working across noon glare, rainy pavement, night lighting, and the week after the lot gets restriped. For Mask R-CNN, that means masks, not boxes, and the labeling precision matters: a sloppy line mask turns into a crooked stall boundary, which turns into the wrong stall ID.
Budget for two kinds of data: breadth (different weather, seasons, cameras, and parking patterns) and the ugly tail (occlusions, trucks, cones, snowbanks, pooled water). If you segment thin paint, annotators will need zoomed, careful work; if you segment whole stalls, you need clear rules for “where the stall ends” when a car covers it. Either way, you’ll spend time on label QA, not just volume, because a small percentage of bad masks can dominate downstream geometry fitting.
New camera angles and resurfacing events are guaranteed, so plan for periodic relabeling or a lightweight “calibration set” per camera that you can refresh without restarting the project.
Camera geometry: fixed views, perspective, and calibration decisions

A common surprise is that the model can be “right” in pixel space and still be wrong in the real world because of perspective. The far end of a stall might be 15 pixels wide, while the near end is 80, so the same mask error changes from harmless to stall-flipping depending on where it lands. If you’re using a fixed, mounted camera, lock down everything you can: focus, exposure mode, and physical bracket. A small bump after maintenance is enough to shift every boundary and make yesterday’s stall IDs drift.
You then choose how much calibration you want to own. The low-effort route is per-camera zones: manually define stall polygons once, then treat the model as a “paint/curb evidence” layer inside those zones. The higher-effort route is camera calibration (homography to a ground plane) so you can fit geometry more consistently and tolerate small viewpoint changes. Calibration adds setup time, needs periodic re-checks, and becomes a field-ops task, not just a training problem.
Turning masks into reliable stall IDs and occupancy signals
A typical workflow is to treat Mask R-CNN as a noisy measurement layer, then convert each mask into something you can track. You simplify masks into polylines or polygons (skeletonize lines, fit edges, snap to expected angles), then intersect that evidence with your pre-defined stall polygons or a calibrated ground-plane grid. The goal is a stable stall ID that doesn’t change when the mask wiggles a few pixels, so most systems add hysteresis: don’t flip an ID or boundary unless the new geometry persists for N frames.
Occupancy usually works better as a separate decision than “did the stall mask exist.” Combine cues: vehicle detections inside the stall zone, foreground motion settling into a stationary blob, and mask coverage ratios (how much of the stall region is occluded). Then add time rules: require a minimum dwell time to mark “occupied,” and a longer clear time to mark “free,” because lighting flicker and brief occlusions are common. The practical cost is tuning per camera; one global threshold rarely survives different perspectives and night lighting.
Alternatives and hybrids that may beat Mask R-CNN
You’ll often get better reliability by treating stall geometry as mostly static and using simpler models for what changes. A common hybrid is: manually define stall polygons once, then run a lightweight vehicle detector (YOLO-style) and decide occupancy by “vehicle box overlap + dwell time.” It’s cheaper to label (boxes, not masks), runs faster on edge hardware, and tends to be more stable under glare where thin-line masks fall apart. If you need cleaner vehicle boundaries for overlap, a small segmentation model focused on “car vs background” can outperform full instance segmentation of stall features.
For stall layout, classical vision still earns its keep: line detection on fresh paint, curb-edge fitting, and a periodic “re-initialize geometry” job when the lot is empty. Another practical option is per-camera background modeling plus a learned classifier on each stall crop; it’s not glamorous, but it’s easy to debug and retrain when a single camera drifts. The trade-off is ongoing per-camera maintenance and explicit rules for edge cases like trailers or double-parking.
A practical go/no-go checklist for your parking project
Picture your first pilot camera after two weeks: if you can’t keep the view fixed (or can’t afford periodic re-calibration), don’t bet on Mask R-CNN to “average it out.” Go if you have stable mounting, consistent lighting control, and a clear annotation target that stays visible most of the year (curbs/stops beat thin paint in many lots). Go if you can fund mask labeling plus QA, per-camera threshold tuning, and a refresh process after restriping or resurfacing.
No-go if you need high confidence on edge cases (motorcycles, overhang, double-parking) without writing explicit rules. No-go if edge hardware can’t meet latency/thermal limits for instance segmentation. If the business only needs “mostly right occupancy,” start with fixed stall polygons + vehicle boxes + dwell-time logic, then add segmentation only where it measurably reduces mistakes.