Room Detection from Floor Plans: OCR, Masks & Areas
By Floor Plan Analyzer, an AxcelerateAI practice
A room-shaped patch of colour is a useful visual check. A product team, estimator or facilities analyst also needs to know which space it represents, which boundary was measured and whether the number is ready to use. A segmentation mask alone leaves those questions open.
This guide follows the decisions between an architectural sheet and a reviewed room record. The examples and proposed acceptance checks are original engineering guidance, not measured performance claims. The downloadable fixture lets you independently reproduce the area calculation and see how exclusions and uncertain labels should be recorded.

At a glance
AI room detection combines boundary segmentation, room instance separation, text extraction and scale calibration. A useful output pairs each room polygon with its source view, observed label, measurement rule and review state. Calculate area from verified geometry and scale; keep physical units unresolved when calibration is missing.
Download the fictional room extraction and measurement example
Define the room record before choosing a model
Start with the consuming task. Listing search needs normalized room types and credible counts. Finish takeoff needs boundaries and deductions on an agreed basis. Facilities software needs persistent space identifiers and source history. These uses can share observations while requiring different derived records.
Agree which spaces count: enclosed rooms, corridors, closets, shafts, balconies and open-plan zones. Decide whether a bathroom cubicle or kitchen zone is an independent instance. Keep the physical enclosure separate from a functional subdivision so totals do not count the same area twice.
Separate observed evidence, model proposals and accepted values. A printed “OFFICE 101” tag is evidence. “Office” as a normalized category is an interpretation. A reviewer-approved polygon is a decision with provenance. Store all three rather than replacing the observation with the final label.
| Reader task | Minimum useful record | Failure to test |
|---|---|---|
| Overlay or search | Room instance, type, source polygon | Merges and wrong room categories |
| Finish takeoff | Measured polygon, exclusions, calibration, finish rule | Unjustified area or duplicate coverage |
| Facilities integration | Stable space ID, level, revision, accepted label | Broken identity after renaming |
| Navigation preparation | Room polygon and sourced openings | False connection across a shared wall |
Select the right sheet, view and coordinate frame
A drawing set can include existing, demolition and proposed plans, enlarged rooms, ceiling plans and detail views of the same level. Build a sheet and view manifest first. Record the issue and intended state, then select the authoritative view for each extraction. A room repeated in an enlarged plan should remain one space with multiple sources.
Inspect whether the PDF contains usable vectors and text, a raster scan, or both. Vector paths can help recover wall edges but can also include hatch strokes, dimensions and furniture. Scans need image segmentation and OCR. A hybrid page may require both; choose by view evidence rather than treating every PDF as vector geometry.
Preserve the original source and record crop, rotation and rendering transforms. PyMuPDF documents page coordinates in points and distinguishes its top-left origin from PDF’s bottom-left convention. A cropped or rotated pixel image needs an explicit mapping back to that source. Text boxes and room polygons must share a frame before you can associate them.
References: PyMuPDF: coordinate systems, points and transformation matrices
Segment room regions, then separate individual spaces
Semantic segmentation classifies pixels, for example as wall, room interior or background. Room instance extraction must additionally decide which interior pixels belong to each separate space. Two adjoining offices can have the same semantic class and still need distinct polygons and identifiers.
Combine wall evidence, opening detections and region proposals. Close a verified doorway in the room boundary for enclosure measurement, while retaining the opening as a separate object. Unrestricted filling through a door gap can merge a room into a hallway. Blindly closing every gap can invent a wall across an open-plan zone.
Keep shafts, columns and voids explicit when the measurement policy excludes them. Small regions deserve classification and review; an area cutoff alone can remove a real store or WC. Furniture outlines, hatch cells and annotation boxes can also form closed shapes without being rooms.
CubiCasa5K is an established research reference for floor-plan parsing, with 5,000 annotated plans and more than 80 object categories in the authors’ repository. It demonstrates a multi-task research approach. Its dataset size or reported results do not establish accuracy on your drawing conventions; use a separate representative evaluation set for that decision.
References: CubiCasa5K authors’ dataset and implementation
Associate OCR labels with geometry without guessing identity
Extract room names, numbers and printed area strings as separate observations with bounding boxes and source references. Use existing PDF text where reliable, and OCR for image text or unusable text layers. Check rotation, tiny characters and characters such as O/0 and I/1. Preserve the literal string before normalizing spelling or categories.
For a simple plan, label containment is a good first candidate rule. Then consider the overlap of the text region with the polygon, leader-line evidence and nearby competing candidates. A label moved outside a small room should not be attached automatically to the nearest room centroid. A schedule row is evidence only after its reference is matched.
Keep name, number and type separate. “101” is not globally unique across buildings and levels, and a room can change use without changing its identity. Use an internal ID, retain the printed reference and record how it was matched. Unresolved or conflicting labels need a review status rather than a fabricated room name.
Printed area and computed area should also remain separate fields. A disagreement can come from an OCR error, a different measurement basis, a stale annotation, an incorrect boundary or scale. Do not change calibration merely to force the two totals to agree.
Calibrate each view before reporting square metres
Pixels, PDF points and CAD drawing units describe coordinates. They are not automatically metres on site. Record a verified reference length and its measured span within the same view. If a known 6 m dimension spans 600 pixels, the example’s scale is 6 / 600 = 0.01 m per pixel. With uniform scale, physical area equals polygon area in square pixels multiplied by scale squared.
Check an independent dimension, preferably in the other axis and elsewhere in the view. A sheet-level scale note may not apply to an enlarged inset, a reduced print or a resized image. A nominal door width or assumed paper size is not independent calibration evidence. Keep metric area null when scale cannot be justified.
Skewed or photographed plans can have nonuniform distortion. A single scalar may be unsuitable. Rectify against verified control geometry, record the transform and inspect residual disagreement. If reliable control is unavailable, limit the output to pixel geometry and explicitly unresolved measurements.
A 2% increase in a uniform linear scale produces a factor of 1.02² = 1.0404 in area, a 4.04% increase. This arithmetic sensitivity is one reason scale verification deserves its own acceptance check, separate from segmentation quality.
Choose the area basis and exclusion policy explicitly
Inside-face room area, whole-floor internal area and rentable or reportable area can have different boundaries and inclusions. Do not label a sum of room polygons “gross area” or “IPMS-compliant” without applying the relevant method. A useful record names its policy and version, and retains the measured geometry.
For this guide’s fictional inside-face policy, subtract the column footprint from the enclosed Office polygon. That is an example rule, not a universal instruction to deduct every column under every standard. Thresholds, recesses, shafts, stairs, built-ins and open-plan zones need their own stated treatment.
The IPMS Coalition explains that measurement standards define what is included in floor space, rather than simply selecting feet or metres. Select the applicable standard and qualified review for the actual purpose. Preserve any reconciliation between the room extraction policy and the measurement basis required by the consumer.
References: IPMS Coalition: questions on measurement scope and units
Work through an Office polygon with an excluded column
The downloadable fictional fixture uses a top-left image coordinate frame with x increasing right and y increasing down. Office R101 runs from (100, 100) to (700, 500): 600 × 400 = 240,000 square pixels. Column C1 runs from (350, 250) to (450, 350): 100 × 100 = 10,000 square pixels.
At the stipulated verified scale of 0.01 m per pixel, the Office enclosure is 24 m². The column deduction is 1 m². The area after that deduction is (240,000 − 10,000) × 0.01² = 23 m². Meeting R102 spans (720, 100) to (1020, 500) and has no deductions in this fixture: 120,000 square pixels, or 12 m².
The rooms sum to 35 m² under this policy. The drawing gap between them represents wall space excluded from both polygons. This sum is not the gross floor area of a building. No outer building boundary, complete floor inventory or external measurement certification is supplied.
The fixture stipulates a printed Office area of 24 m² on an unspecified basis. Keep that observation alongside the 23 m² calculation and an unresolved area-basis discrepancy. Arithmetic can be correct while the record still requires review. The sample therefore leaves both rooms unreleased for operational use.
Changing the linear scale to 0.0102 m per pixel changes the Office result to 23.9292 m². The geometry has not improved or deteriorated; the calibration assumption changed. Retain unrounded values for computation and apply display rounding only at the handoff boundary.
| Quantity | Image geometry | At 0.01 m/px |
|---|---|---|
| Office enclosure | 240,000 px² | 24 m² |
| Column C1 deduction | 10,000 px² | 1 m² |
| Office after deduction | 230,000 px² | 23 m² |
| Meeting, no deductions | 120,000 px² | 12 m² |
| Policy-specific room total | 350,000 px² | 35 m² |
Validate geometry before accepting the area
Check closed rings, self-intersections, duplicate vertices, holes outside shells and unintended overlaps between rooms. Confirm excluded regions lie within their intended room and that the chosen coordinate units are consistent. A polygon can look plausible at page scale while containing a crossing edge that changes its interpretation.
Shapely exposes polygon area computation and geometry repair, but its make_valid documentation warns that repair can return a GeometryCollection or lower-dimensional result. A successful library call does not prove the repaired result represents a room. Inspect its type, components, area change and source overlay before accepting it.
Retain the pre-repair geometry and a repair log. Compare the repaired outline with walls and openings, and escalate substantial changes. Set review thresholds using the downstream task and representative evidence. An arbitrary universal tolerance could accept a damaging error in a small room or overwhelm reviewers on harmless line noise.
References: Shapely: area computation · Shapely: geometry repair and possible output types
Evaluate complete room records, not just coloured pixels
Build a held-out set that reflects the actual incoming documents: relevant offices, plan types, scales, revisions, scan quality and difficult rooms. Keep related views and revisions from leaking between training and evaluation. Have reviewers agree the enclosure and measurement rules before scoring.
Match predicted room instances to reference rooms under an agreed rule. Count missing rooms, spurious rooms, merges and splits. Compare polygon intersection-over-union for matched instances, but also examine important boundary errors and area differences. Similar total area can conceal a room assigned to the wrong identifier.
Report OCR field correctness and correct label-to-room association separately. Track absolute area error in the delivery unit and relative error where the reference area is nonzero. Group results by document type and difficult cases rather than presenting one number that hides an entire failure mode.
For a fictional reference room of 23 m² and a proposed 22.54 m², absolute error is 0.46 m² and relative error is 0.46 / 23 = 2%. This is a scoring example, not a benchmark or acceptable threshold. The buyer must decide the consequences and tolerances for its use.
Measure the remaining review task: which records need attention, why, and whether reviewers can resolve them from the supplied evidence. Do not describe model confidence as calibrated probability or promise time savings without evaluating those properties.
| Acceptance case | Expected behavior to agree | Evidence to inspect |
|---|---|---|
| Known rectangular room | Correct instance and independently reproduced area | Polygon, calibration and arithmetic |
| Open-plan kitchen/living | Agreed zone policy; no duplicate counted area | Convention version and parent enclosure |
| Label outside enclosure | Correct leader match or explicit exception | OCR region and candidate association |
| Missing scale | Pixel geometry; metric area unresolved | Null metric output and reason |
| Office printed/computed mismatch | Both values retained; not released | Area-basis discrepancy |
| Two adjacent rooms | No merged room through doorway | Boundary and opening overlay |
Specify the handoff, corrections and revision behavior
Deliver an overlay with stable room IDs and a structured record containing document, page, view, level, issue, coordinate frame, shell and holes. Include raw label observations, normalized values, calibration evidence, computed areas, measurement policy, exceptions and approval status. The downloadable JSON demonstrates those distinctions without claiming to be a published Floor Plan Analyzer API contract.
Keep reviewer corrections traceable. Changing a room name should not silently replace the geometry; changing a boundary should recalculate the affected quantities and invalidate any stale approval. Revisions can split or merge rooms, so maintain superseded IDs and explicit lineage rather than assigning identity from room names alone.
Agree an ownership boundary with the consuming system: who approves measurements, who resolves conflicting tags, when a record is eligible for export, and how reruns avoid duplicate records. Keep proposed, accepted and released states distinct. A drawing-derived record also needs an explicit statement about whether it has been field verified.
Floor Plan Analyzer is AxcelerateAI’s drawing-intelligence practice. We fine-tune models on the drawing conventions and fields a client needs and engineer the review and integration workflow around them. A practical feasibility review starts with representative sheets, a sample room schedule and an agreed measurement basis; performance and delivery scope follow from that evidence.
- Provide several representative and difficult views, with permission to use them for the agreed evaluation.
- Name the enclosure, zone and exclusion rules and the required output units.
- Supply reviewer-checked rooms and expected labels for a held-out evaluation.
- Define which exceptions block release and which team resolves them.
- Choose the consumer’s schema, stable IDs, revision behavior and acceptance criteria.
Frequently asked questions
Can room detection work on scanned floor plans?
Yes, image segmentation and OCR can propose rooms and labels from scans. Resolution, distortion, boundary conventions and calibration determine which outputs can be supported. Physical area should stay unresolved without trustworthy scale.
Can OCR alone calculate room area?
OCR can read a printed area string, but that does not establish its boundary or measurement basis. A computed area needs geometry, calibration and an explicit inclusion policy.
Is room segmentation the same as room detection?
Segmentation classifies image regions. A usable room-detection workflow also separates instances, associates labels and produces identifiable records. Ask which of these outputs a proposed system actually delivers.
How are open-plan rooms handled?
Define whether the result is one physical enclosure or several functional zones. If zones are required, agree their boundaries and parent relationships before annotation and evaluation to prevent duplicate area.
Does the room total equal building floor area?
Only when the inventory and measurement rules support that interpretation. The sum can omit wall footprints, circulation, shafts or unprocessed views. Report its scope instead of relabeling it as a gross or certified area.