Repository navigation
Add Create Shapes to Tools > Auto-Mapping, a layer on each flat face found - #708
Merged
Merged
Conversation
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
force-pushed
the
feat-camera-auto-mapping-faces
branch
from
December 4, 2026 17:56
bfbeace to
c1873b6
Compare
sofian
approved these changes
Dec 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.
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.FaceFinderkeeps 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.SetOutputVerticesCommandmoves 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.SyntheticScenenow 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.Found while trying it, in their own commits:
mapmap_en.tslacked 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
--auto-mapping-simulation, open a project.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.--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.--lang fr);mapmap_fr.ts76 texts of other features, left untranslated. The other languages show the English texts.CHANGELOG.mdcome with the third part of the slice.