Skip to content

Add Tools > Auto-Mapping, to see the scene from the projector - #702

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

aalex merged 6 commits into
devfrom
feat-camera-auto-mapping

Conversation

@aalex

@aalex aalex commented Dec 4, 2026

Copy link
Copy Markdown
Member

Summary

First part of the slice "Caler les formes tout seul grâce à une caméra" (automatic mapping with a camera): the scan, and the scene seen from the projector. Placing shapes on the flat faces found comes in a second pull request.

  • Tools > Auto-Mapping… (a new Tools menu, between View and Window) opens a window: choose the camera and the screen of the projector, see what the camera films, read the reminder (nobody in the picture, darken the room, then do not touch the zoom, the focus or the framing of the projector), and press Start.
  • During the scan, the output covers the screen of the projector, for this session only, and shows a countdown ("3, 2, 1, step out of the picture and do not move"), then white, black, and black and white stripes of a Gray code, each followed by its inverse: 46 images in 1920 × 1080, about 13 seconds. The output is shown as before afterwards.
  • The scene seen from the projector then shows under the shapes of the output editor, with in red what the camera did not see, to place the shapes on it by hand. Tools > Show Auto-Mapping Image hides it, Tools > Clear Auto-Mapping Image forgets it. It is never saved, and goes with the project.
  • Skip the finest stripes, in the window: 38 images instead of 46, for a camera that blurs the finest stripes. A point is then only known to a square of 4 × 4 pixels: 1.5 pixels of mean error instead of less than half a pixel.
  • --auto-mapping-simulation films a computed scene (a table, three blocks and a black object) instead of a camera, to try everything without a camera or a projector. --auto-mapping-save-images <folder> writes each image kept, and the scene seen from the projector; without it, no image of the camera is ever written to the disk.

How:

  • src/automap/, new: GrayCodePattern (the images), GrayCodeDecoder (reads them as they come: a point is lit when white is brighter than black by 20 levels; each bit compares the stripes with their inverse, so the light of the room cancels out; a point on the edge of a stripe is decided by the sign, and lands one pixel away at worst), Correspondence (camera point → output point, and the scene seen from the projector, with its small holes filled from their neighbours), AutoMapScan (the scan, with the event loop), AutoMapFrameSource (a real camera with Qt Multimedia, or a simulated one), SyntheticScene (the computed scene of the tests and of the simulation).
  • After each change of the projection, the first 4 images of the camera are thrown away, as a webcam often sends images filmed before; then the scan waits for two images in a row that hardly differ. It fails with a message when the camera sends nothing, nothing steady within 3 seconds, or does not see the projection at all.
  • No new dependency, no computer vision library.
  • Two fixes for the output covering a screen on macOS, found while trying it: the pointer stayed visible when the output came under a still mouse (it is now hidden over the images of the scan), and the shadow of the window drew a light outline around the whole screen, in every use of the output covering a screen (the output has no shadow while it covers a screen).

Demo

  1. Start MapMap with --auto-mapping-simulation, open a project.
  2. Tools > Auto-Mapping…: the simulated camera shows a table with three blocks. Press Start.
  3. The output covers the chosen screen: countdown, then the stripes, about 15 seconds.
  4. The output editor shows the table and the blocks, seen from the projector, under the shapes; in red, the black object and what the blocks hide from the camera. The window says how much of the output the camera saw.
  5. Tools > Show Auto-Mapping Image hides it and shows it again; Tools > Clear Auto-Mapping Image forgets it.

Tests

  • tests/TestAutoMap.cpp, 16 tests, on scenes computed by SyntheticScene with noise and the light of a room: Gray code; images and their order; more than 99 % of the lit points read, less than 0.5 pixel of mean error; with the two finest series skipped, less than 1.6 pixel; the black object not read; the same result twice; images out of order refused; the scene seen from the projector and its colours; the red of what was not read; a whole scan with a simulated camera three images late; failures without images and when the camera does not see the projection.
  • 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: the countdown, the stripes, the output shown as before, the scene under the shapes; no pointer over the images, no outline around the screen.
  • Not tried yet: a real camera and a real projector. To check then:
    • the scan with a webcam and a projector, on objects on a table: share of the output seen, red where expected;
    • once with Skip the finest stripes unchecked, once checked: which gives the better image;
    • a failure message, if any: an image that does not settle may come from the automatic exposure of the webcam;
    • --auto-mapping-save-images <folder>: the images and projector-view.png are written there;
    • the output shown as before after the scan, and after Cancel or Escape during the scan;
    • the output covering a screen without the scan: still no outline around the screen.
  • Not tried on GNU/Linux or Windows: GitHub builds and tests them.
  • French translation of the new texts.

@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 05:54
aalex added 6 commits December 4, 2026 01:09
The first part of the automatic mapping with a camera: the projector
shows white, black, then black and white stripes of a Gray code, each
followed by its inverse; a camera films them, and MapMap finds, for each
point of the camera, the point of the output that lights it. From it
comes the scene seen from the projector, with the points the camera did
not see left transparent.

The scan runs with the event loop. After each change of the projection,
the first images of the camera are thrown away, as a webcam often sends
images filmed before, then the scan waits for two images in a row that
hardly differ. It fails when the camera sends nothing steady, or does
not see the projection.

SyntheticScene computes what a camera would film of flat faces on a
table, with noise and the light of a room, so that the tests need no
camera and no projector: more than 99 % of the lit points are read,
less than half a pixel away.
…pes of the output editor

The output canvas shows an image over the whole output frame, in place
of the shapes and of the test signal, pixel for pixel and without
smoothing, so that the finest stripes stay sharp. The canvases of the
editors draw an image under the shapes, over their content rectangle.
The window chooses the camera and the screen of the projector, shows
what the camera films, and starts the scan. During the scan, the output
covers the screen of the projector, for this session only, and shows a
countdown, then the stripes; it is shown as before afterwards. The scene
seen from the projector then shows under the shapes of the output
editor, with in red what the camera did not see. Tools > Show
Auto-Mapping Image hides it, Tools > Clear Auto-Mapping Image forgets
it; it is never saved, and goes with the project.

--auto-mapping-simulation films a computed scene instead of a camera;
--auto-mapping-save-images <folder> writes the images of the camera,
which are otherwise never written to the disk.
On macOS, a blank cursor does not hide the pointer when the output
window comes under a still mouse, as it does when a scan starts: the
camera would film it. It is now hidden again at each image, as long as
it is over the output.
The shadow of a window draws a thin light outline around it, even
without a frame: around the whole screen when the output covers it.
The output has no shadow while it covers a screen, and gets it back as
an ordinary window.

@sofian sofian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This feature should be moved to an add-on when the plugins system is ready.

@aalex
aalex force-pushed the feat-camera-auto-mapping branch from 0004d77 to ef52fe2 Compare December 4, 2026 06:14
@aalex
aalex merged commit c45e88d into dev Dec 4, 2026
3 checks passed
@aalex
aalex deleted the feat-camera-auto-mapping branch December 4, 2026 06:20
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