Skip to content

Add Create Shapes to Tools > Auto-Mapping, a layer on each flat face found - #708

Merged
aalex merged 10 commits into
devfrom
feat-camera-auto-mapping-faces
Dec 4, 2026
Merged

aalex merged 10 commits into
devfrom
feat-camera-auto-mapping-faces

Conversation

@aalex

@aalex aalex commented Dec 4, 2026

Copy link
Copy Markdown
Member

Summary

Second part of the slice "Caler les formes tout seul grâce à une caméra" (automatic mapping with a camera), after #702: from what the scan read, MapMap finds the flat faces of the scene and makes a quadrilateral layer of each.

  • After a scan, the faces found are drawn over the output editor: plain, white and numbered when four corners fit them; dashed and yellow when they do not (the gable of a house, a block half hidden behind another), to place by hand. The window says how many: "5 faces found, 2 outlines to place by hand". The outlines come and go with Tools > Show Auto-Mapping Image, Tools > Clear Auto-Mapping Image forgets them, and they are never saved.
  • Create Shapes, in the window, makes a quadrilateral layer of each face: "Face 1", "Face 2"… from left to right, each with a colour source of its own (hues far apart, even with many faces), one pixel inside its face so as not to light the wall behind, the largest under the others. The first is selected. It is all one step of Undo, "Auto-Mapping".
  • Made again (a projector knocked, a block added), the button becomes Update Shapes: the layers of the previous scan follow their face, keeping their source and their effects; only their corners move, and a corner moved by hand is replaced. New faces get new layers. The layers whose face is not found again are listed by name, then removed or kept, as chosen. A box says all of it, with the numbers, before anything changes; one Undo takes it all back.
  • The layers of the automatic mapping are only known while the project stays open: after it is opened again, a new scan adds new layers. Writing it in the project file is left for later.

How:

  • PlaneSegmenter, new: the points read go into a grid laid over the output, about one point of the camera per cell. Four nearby cells drawn at random give a perspective transform; the one followed by the most cells to 1.5 pixels, out of 400 draws scored on 4000 cells, is fitted again by least squares without a band of 2 pixels along the edges of its face, where the stripes blur; the largest block of cells that follows it is a face. The search starts again on what is left, until it is smaller than 0.5 % of the output. The draws have a fixed seed: a scan always gives the same faces.
  • ContourSimplifier, new: the outer outline of a face along the edges of its cells, reduced to four corners (Douglas-Peucker), each corner then put where the straight lines fitted on its two sides cross. FaceFinder keeps the quadrilateral when it is convex and its area is within 10 % of that of the face, and gives the faces in the order of reading.
  • FaceMatcher, new: a face found again is the previous face that shares the most of the output they cover together, from a quarter up; and the colours, turning the hue by the golden angle.
  • SetOutputVerticesCommand moves all the vertices of a layer in one step; the inner vertices of a mesh keep their place on the face. MapperGLCanvas::setOutlines() draws the outlines.
  • SyntheticScene now shades what is behind a block: the camera, beside the projector, sees a little of the table around a block, which the projector cannot light. Before, that part was lit, and the points of the two faces mixed along the edges of the blocks.
  • No new dependency, no computer vision library.

Found while trying it, in their own commits:

  • A disabled button looked like the others, as the style sheet gave it no look of its own: Create Shapes seemed ready before any scan. A disabled button now has the grey text of a disabled list or menu item, everywhere in MapMap.
  • A layer put back by Undo or Redo (of Add layer, Delete layer, Remove source) kept its old depth, while the others had been renumbered: after Undo then Redo of the five faces, four had the depth 0 over MCP. The commands now renumber the depths, as removing a layer already did; opening a project still keeps the depths of its file.
  • mapmap_en.ts lacked the texts of Add Tools > Auto-Mapping, to see the scene from the projector #702, of the shaders and of the effects. Without an English form, a text with a number showed "5 face(s) found"; the English file now has the singular and plural forms, and the source of every other text.

Demo

  1. Start MapMap with --auto-mapping-simulation, open a project.
  2. Tools > Auto-Mapping…, Start. After the stripes, white numbered outlines lie on the table and on the blocks; the window says how many faces were found.
  3. Create Shapes: a coloured layer on each face, "Face 1", "Face 2"…, the table under the blocks.
  4. Close the window, give "Face 2" another source, open Tools > Auto-Mapping… again. Start, then Update Shapes: the box says how many layers will follow their face; "Face 2" keeps its source.
  5. Edit > Undo once: the layers are back as before the update; once more: the faces are gone.

Tests

  • tests/TestMappingManager.cpp: a layer taken away and put back has its place in the depths.
  • tests/TestAutoMap.cpp, 9 new tests: a perspective transform from 4 and from 20 points, refused with three points on a line; the outline along the edges of the cells; a quadrilateral moved inwards; the five faces of the simulated scene, with their corners within 1 pixel of the true ones (the slice asks for 2); the order of reading; the same faces twice; an L kept as an outline while a turned square next to it is found; faces matched after a move; colours far apart.
  • Every commit builds and passes all the tests on macOS 26 (Apple Silicon, Qt 6.11).
  • Tried by hand on macOS with --auto-mapping-simulation, on one screen: Create Shapes greyed before the scan; 5 numbered outlines after it; Create Shapes made "Face 1" to "Face 5", the table under the blocks, "Face 1" selected; "Face 2" given a white source over MCP; a second scan numbered its outlines as the layers; Update Shapes announced that the 5 layers of the previous scan would follow their face, and "Face 2" stayed white; one Undo took back the update only, the next one the faces. MapMap quit cleanly. Screenshots follow in a comment. This was before the rebase onto 94f9630, which moves and undoes layers through the project model; after the rebase, every commit still builds and passes all the tests, but the hand test was not made again.
  • Still to check:
    • "Update and Keep Them" and "Update and Remove Them", with a face gone from the scene (the simulated scene cannot lose one);
    • a dashed yellow outline, with a face that four corners do not fit (none in the simulated scene);
    • Tools > Show Auto-Mapping Image and Clear Auto-Mapping Image with the outlines;
    • the new texts in French (--lang fr);
    • a real camera and a real projector, on blocks on a table: corners within 3 pixels of the true edges.
  • Not tried on GNU/Linux or Windows: GitHub builds and tests them.
  • French translation of the new texts. Collecting them also brought into mapmap_fr.ts 76 texts of other features, left untranslated. The other languages show the English texts.
  • The documentation and CHANGELOG.md come with the third part of the slice.

@aalex aalex added this to the 1.0 milestone Dec 4, 2026
@aalex aalex self-assigned this Dec 4, 2026
@aalex
aalex requested a review from sofian December 4, 2026 17:33
aalex added 10 commits December 4, 2026 12:46
The camera, beside the projector, sees a little around a block standing
on the table. The simulated scene lit that part of the table with the
pixels of the output that land on the block, which no projector can do:
the points of the two faces then mixed along the edges of the block.
They are now in the shadow of the block, unread, as in a real room.
From what a scan read, PlaneSegmenter finds the flat faces of the scene:
four nearby points drawn at random give a perspective transform, the one
followed by the most points to a pixel and a half wins, it is fitted
again on its face without the edges, and the largest block that follows
it is a face. The draws have a fixed seed: a scan always gives the same
faces. The search stops when what is left is smaller than 0.5 % of the
output.

ContourSimplifier follows the outline of each face and reduces it to four
corners (Douglas-Peucker), then puts each corner where the lines of its
two sides cross. FaceFinder keeps the quadrilateral when its area is
within 10 % of that of the face, and gives the faces from left to right.

On the simulated scene of the tests, the five faces are found, with their
corners within one pixel of the true ones.
When the automatic mapping is made again, after a projector was knocked
or a block added, FaceMatcher tells which face found now is which face
found before: the two that share the most of the output they cover
together, from a quarter up. The layer of a face can then follow it with
its source and its effects. Faces not found again are listed.

FaceMatcher also gives each face its colour, turning the hue by the
golden angle from one face to the next, so that faces close in number
are never close in colour.
After a scan, the faces found are drawn over the output editor: plain,
white and numbered when a quadrilateral fits them, dashed and yellow when
they are to place by hand (the gable of a house, a block half hidden).
The window says how many: "5 faces found, 2 outlines to place by hand".
The outlines come and go with Tools > Show Auto-Mapping Image.

"Create Shapes" makes a quadrilateral layer of each face, named
"Face 1", "Face 2"..., each with a colour source of its own, a pixel
inside its face so as not to light the wall behind; the largest is under
the others, and the first is selected. It is all one step of Undo,
"Auto-Mapping".

Made again, the automatic mapping offers to "Update Shapes": the layers
of the previous scan follow their face, keeping their source and their
effects, only their corners move; new faces are added, and the layers of
faces not found again are removed or kept, as chosen. The layers of the
automatic mapping are only known while the project stays open.
A layer taken away by Undo (of "Add layer") or by "Delete layer" and
put back kept the depth it had before, while the others had been
renumbered: after Undo then Redo of several layers, four of five had the
depth 0, as the MCP server showed. The layers put back by the commands
now renumber all the depths, as removing one already did. Opening a
project still keeps the depths of the file.
The style sheet gave a disabled button the same look as the others: in
Tools > Auto-Mapping, Create Shapes looked ready before any scan. A
disabled button now has the grey text of a disabled list or menu item,
and no longer darkens under the mouse.
…apping

Without an English form, a text with a number showed its source as is:
"5 face(s) found, 0 outline(s) to place by hand", "5 layer(s) moved".
The texts with a number now have their singular and plural forms. The
other new texts, from the automatic mapping, the shaders and the
effects, get their source, as every English text does.
@aalex
aalex force-pushed the feat-camera-auto-mapping-faces branch from bfbeace to c1873b6 Compare December 4, 2026 17:56
@aalex
aalex merged commit e480284 into dev Dec 4, 2026
3 checks passed
@aalex
aalex deleted the feat-camera-auto-mapping-faces branch December 4, 2026 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants