From b7a5734d9d2649b7d1bceda73e508a01342a304e Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Fri, 4 Dec 2026 02:01:46 -0500 Subject: [PATCH 01/10] Shade what is behind a block in the simulated scene, as a projector does 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. --- src/automap/SyntheticScene.cpp | 4 ++++ src/automap/SyntheticScene.h | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/automap/SyntheticScene.cpp b/src/automap/SyntheticScene.cpp index 9fa65ceb..8136f34e 100644 --- a/src/automap/SyntheticScene.cpp +++ b/src/automap/SyntheticScene.cpp @@ -171,6 +171,10 @@ bool SyntheticScene::outputPointAt(const QPointF& cameraPoint, QPointF* outputPo const QPointF point = _cameraToOutput.at(face).map(cameraPoint); if (point.x() < 0 || point.y() < 0 || point.x() >= _outputSize.width() || point.y() >= _outputSize.height()) return false; + // The light of that point of the output stops on a face in front. + for (int i = face + 1; i < _faces.size(); i++) + if (_faces.at(i).outputQuad.containsPoint(point, Qt::OddEvenFill)) + return false; if (outputPoint) *outputPoint = point; return true; diff --git a/src/automap/SyntheticScene.h b/src/automap/SyntheticScene.h index 05a1087a..c4f942b6 100644 --- a/src/automap/SyntheticScene.h +++ b/src/automap/SyntheticScene.h @@ -100,7 +100,11 @@ class SyntheticScene * Gives the point of the output that lights point @a cameraPoint of the * camera, in pixels of the output. * - * @return false when no face is there, or when it is outside the output. + * The camera, beside the projector, sees a little around the faces in + * front: there, the faces behind are in the shadow of those in front, and + * no point of the output lights them. + * + * @return false when no face is there, when it is outside the output, or in the shadow of a face in front. */ bool outputPointAt(const QPointF& cameraPoint, QPointF* outputPoint) const; From 4d8b35cdd2ff12fceda529ff04b19a1573ef7c5c Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Fri, 4 Dec 2026 02:01:52 -0500 Subject: [PATCH 02/10] Find the flat faces of a scan and their four corners 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. --- src/automap/ContourSimplifier.cpp | 336 ++++++++++++++++++ src/automap/ContourSimplifier.h | 65 ++++ src/automap/FaceFinder.cpp | 100 ++++++ src/automap/FaceFinder.h | 72 ++++ src/automap/PlaneSegmenter.cpp | 547 ++++++++++++++++++++++++++++++ src/automap/PlaneSegmenter.h | 112 ++++++ src/automap/automap.pri | 6 + tests/TestAutoMap.cpp | 228 +++++++++++++ tests/TestAutoMap.h | 11 +- tests/tests.pro | 12 +- 10 files changed, 1482 insertions(+), 7 deletions(-) create mode 100644 src/automap/ContourSimplifier.cpp create mode 100644 src/automap/ContourSimplifier.h create mode 100644 src/automap/FaceFinder.cpp create mode 100644 src/automap/FaceFinder.h create mode 100644 src/automap/PlaneSegmenter.cpp create mode 100644 src/automap/PlaneSegmenter.h diff --git a/src/automap/ContourSimplifier.cpp b/src/automap/ContourSimplifier.cpp new file mode 100644 index 00000000..51a6ec96 --- /dev/null +++ b/src/automap/ContourSimplifier.cpp @@ -0,0 +1,336 @@ +/* + * ContourSimplifier.cpp + * + * (c) 2026 MapMap contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "ContourSimplifier.h" + +#include +#include + +#include +#include + +namespace mmp { + +namespace { + +const int CORNERS = 4; + +// The directions along the edges of the cells, turning right one after the other on the screen. +enum Direction { EAST = 0, SOUTH = 1, WEST = 2, NORTH = 3, DIRECTIONS = 4 }; +const int STEP_X[DIRECTIONS] = { 1, 0, -1, 0 }; +const int STEP_Y[DIRECTIONS] = { 0, 1, 0, -1 }; + +// Seen from a corner of the cells, going in a direction: the cell ahead on the left, then on the right. +const int LEFT_X[DIRECTIONS] = { 0, 0, -1, -1 }; +const int LEFT_Y[DIRECTIONS] = { -1, 0, 0, -1 }; +const int RIGHT_X[DIRECTIONS] = { 0, -1, -1, 0 }; +const int RIGHT_Y[DIRECTIONS] = { 0, 0, -1, -1 }; + +// The part of each side, at each end, left out when fitting its line: there, the outline turns. +const qreal SIDE_END_SHARE = 0.15; +// The step of the points taken along a side to fit its line, in pixels. +const qreal SIDE_SAMPLE_STEP = 0.5; +// A corner where the lines cross farther than this from the corner of the outline is not moved: +// at least this many pixels, or this share of its shortest side. +const qreal MINIMUM_CORNER_SHIFT = 4; +const qreal CORNER_SHIFT_SHARE = 0.25; +const qreal PARALLEL = 1e-9; + +qreal distanceToSegment(const QPointF& p, const QPointF& a, const QPointF& b) +{ + const QPointF ab = b - a; + const qreal length2 = ab.x() * ab.x() + ab.y() * ab.y(); + if (length2 <= 0) + return std::hypot(p.x() - a.x(), p.y() - a.y()); + const qreal t = qBound(0.0, ((p.x() - a.x()) * ab.x() + (p.y() - a.y()) * ab.y()) / length2, 1.0); + const QPointF closest = a + t * ab; + return std::hypot(p.x() - closest.x(), p.y() - closest.y()); +} + +/// A straight line: a point on it and its direction, of length 1. +struct Line { + QPointF point; + QPointF direction; +}; + +/// Crosses @a a and @a b; false when they are parallel. +bool cross(const Line& a, const Line& b, QPointF* point) +{ + const qreal det = a.direction.x() * b.direction.y() - a.direction.y() * b.direction.x(); + if (std::fabs(det) < PARALLEL) + return false; + const QPointF d = b.point - a.point; + const qreal t = (d.x() * b.direction.y() - d.y() * b.direction.x()) / det; + *point = a.point + t * a.direction; + return true; +} + +/// Fits a line on the points of @a outline from index @a from to index @a to, going forwards; false when too short. +bool fitSide(const QPolygonF& outline, int from, int to, Line* line) +{ + const int n = outline.size(); + QPolygonF side; + for (int i = from;; i = (i + 1) % n) + { + side.append(outline.at(i)); + if (i == to) + break; + } + qreal length = 0; + for (int i = 1; i < side.size(); i++) + length += QLineF(side.at(i - 1), side.at(i)).length(); + if (length <= 0) + return false; + + // Points every half pixel along the side, away from its ends. + QVector samples; + qreal travelled = 0; + for (int i = 1; i < side.size(); i++) + { + const QLineF segment(side.at(i - 1), side.at(i)); + const qreal segmentLength = segment.length(); + for (qreal s = 0; s < segmentLength; s += SIDE_SAMPLE_STEP) + { + const qreal along = travelled + s; + if (along >= SIDE_END_SHARE * length && along <= (1 - SIDE_END_SHARE) * length) + samples.append(segment.pointAt(s / segmentLength)); + } + travelled += segmentLength; + } + if (samples.size() < 2) + return false; + + // The line through their middle, along their main direction. + QPointF mean; + for (const QPointF& p : samples) + mean += p; + mean /= samples.size(); + qreal xx = 0, xy = 0, yy = 0; + for (const QPointF& p : samples) + { + const QPointF d = p - mean; + xx += d.x() * d.x(); + xy += d.x() * d.y(); + yy += d.y() * d.y(); + } + const qreal angle = 0.5 * std::atan2(2 * xy, xx - yy); + line->point = mean; + line->direction = QPointF(std::cos(angle), std::sin(angle)); + return true; +} + +} + +QPolygonF ContourSimplifier::outline(const PlaneRegion& region) +{ + QPolygonF result; + const int width = region.gridSize.width(); + int start = -1; + for (int i = 0; i < region.cells.size() && start < 0; i++) + if (region.cells.at(i)) + start = i; + if (start < 0) + return result; + + // Along the edges of the cells, with the face on the right, from the top left corner of its first cell. + const int startX = start % width; + const int startY = start / width; + const auto goes = [®ion](int x, int y, int direction) { + return !region.contains(x + LEFT_X[direction], y + LEFT_Y[direction]) && + region.contains(x + RIGHT_X[direction], y + RIGHT_Y[direction]); + }; + int x = startX; + int y = startY; + int direction = EAST; + result.append(QPointF(x, y) * region.cellSize); + const int maximumSteps = 4 * (region.cells.size() + 1); + for (int step = 0; step < maximumSteps; step++) + { + x += STEP_X[direction]; + y += STEP_Y[direction]; + // Turn right when possible, else go straight, else turn left. + int next = direction; + const int choices[3] = { (direction + 1) % DIRECTIONS, direction, (direction + DIRECTIONS - 1) % DIRECTIONS }; + for (int choice : choices) + { + if (goes(x, y, choice)) + { + next = choice; + break; + } + } + if (x == startX && y == startY && next == EAST) + break; + if (next != direction) + result.append(QPointF(x, y) * region.cellSize); + direction = next; + } + return result; +} + +QPolygonF ContourSimplifier::quad(const QPolygonF& outline) +{ + const int n = outline.size(); + if (n < CORNERS) + return QPolygonF(); + + // The two points farthest apart (nearly): the farthest from the middle, then the farthest from it. + QPointF middle; + for (const QPointF& p : outline) + middle += p; + middle /= n; + int first = 0; + for (int i = 1; i < n; i++) + if (QLineF(middle, outline.at(i)).length() > QLineF(middle, outline.at(first)).length()) + first = i; + int second = first; + for (int i = 0; i < n; i++) + if (QLineF(outline.at(first), outline.at(i)).length() > QLineF(outline.at(first), outline.at(second)).length()) + second = i; + if (second == first) + return QPolygonF(); + + // Then each time the point farthest from the outline kept so far. + QVector kept = { qMin(first, second), qMax(first, second) }; + while (kept.size() < CORNERS) + { + qreal farthest = -1; + int farthestIndex = -1; + int insertAt = -1; + for (int k = 0; k < kept.size(); k++) + { + const int from = kept.at(k); + const int to = kept.at((k + 1) % kept.size()); + for (int i = (from + 1) % n; i != to; i = (i + 1) % n) + { + const qreal distance = distanceToSegment(outline.at(i), outline.at(from), outline.at(to)); + if (distance > farthest) + { + farthest = distance; + farthestIndex = i; + insertAt = k + 1; + } + } + } + if (farthestIndex < 0) + return QPolygonF(); + kept.insert(insertAt, farthestIndex); + } + // Kept in the order of the outline, starting anywhere. + std::sort(kept.begin(), kept.end()); + + QPolygonF corners; + for (int index : kept) + corners.append(outline.at(index)); + + // Each corner where the lines of its two sides cross, when they do near it. + Line lines[CORNERS]; + bool fitted[CORNERS]; + for (int k = 0; k < CORNERS; k++) + fitted[k] = fitSide(outline, kept.at(k), kept.at((k + 1) % CORNERS), &lines[k]); + qreal shortestSide = QLineF(corners.at(0), corners.at(1)).length(); + for (int k = 1; k < CORNERS; k++) + shortestSide = qMin(shortestSide, QLineF(corners.at(k), corners.at((k + 1) % CORNERS)).length()); + const qreal maximumShift = qMax(MINIMUM_CORNER_SHIFT, CORNER_SHIFT_SHARE * shortestSide); + QPolygonF refined = corners; + for (int k = 0; k < CORNERS; k++) + { + const int before = (k + CORNERS - 1) % CORNERS; + QPointF crossing; + if (fitted[before] && fitted[k] && cross(lines[before], lines[k], &crossing) && + QLineF(crossing, corners.at(k)).length() <= maximumShift) + refined[k] = crossing; + } + + // Clockwise on the screen, from the corner nearest to the top left. + if (signedArea(refined) < 0) + std::reverse(refined.begin(), refined.end()); + int topLeft = 0; + for (int k = 1; k < CORNERS; k++) + if (refined.at(k).x() + refined.at(k).y() < refined.at(topLeft).x() + refined.at(topLeft).y()) + topLeft = k; + QPolygonF result; + for (int k = 0; k < CORNERS; k++) + result.append(refined.at((topLeft + k) % CORNERS)); + return result; +} + +bool ContourSimplifier::isConvex(const QPolygonF& quad) +{ + if (quad.size() != CORNERS) + return false; + int positive = 0; + int negative = 0; + for (int k = 0; k < CORNERS; k++) + { + const QPointF a = quad.at(k); + const QPointF b = quad.at((k + 1) % CORNERS); + const QPointF c = quad.at((k + 2) % CORNERS); + const qreal turn = (b.x() - a.x()) * (c.y() - b.y()) - (b.y() - a.y()) * (c.x() - b.x()); + if (turn > 0) + positive++; + else if (turn < 0) + negative++; + } + return positive == CORNERS || negative == CORNERS; +} + +qreal ContourSimplifier::signedArea(const QPolygonF& polygon) +{ + qreal sum = 0; + for (int i = 0; i < polygon.size(); i++) + { + const QPointF& a = polygon.at(i); + const QPointF& b = polygon.at((i + 1) % polygon.size()); + sum += a.x() * b.y() - b.x() * a.y(); + } + return sum / 2; +} + +QPolygonF ContourSimplifier::inset(const QPolygonF& quad, qreal distance) +{ + if (quad.size() != CORNERS || distance == 0) + return quad; + // Inwards is on the right of each side when the quadrilateral goes clockwise on the screen. + const qreal side = signedArea(quad) >= 0 ? 1 : -1; + Line lines[CORNERS]; + for (int k = 0; k < CORNERS; k++) + { + const QPointF a = quad.at(k); + const QPointF b = quad.at((k + 1) % CORNERS); + const qreal length = QLineF(a, b).length(); + if (length <= 0) + return quad; + const QPointF direction = (b - a) / length; + const QPointF inwards(-direction.y() * side, direction.x() * side); + lines[k].point = a + inwards * distance; + lines[k].direction = direction; + } + QPolygonF result; + for (int k = 0; k < CORNERS; k++) + { + QPointF corner; + if (!cross(lines[(k + CORNERS - 1) % CORNERS], lines[k], &corner)) + return quad; + result.append(corner); + } + return result; +} + +} diff --git a/src/automap/ContourSimplifier.h b/src/automap/ContourSimplifier.h new file mode 100644 index 00000000..539db72f --- /dev/null +++ b/src/automap/ContourSimplifier.h @@ -0,0 +1,65 @@ +/* + * ContourSimplifier.h + * + * (c) 2026 MapMap contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef CONTOUR_SIMPLIFIER_H_ +#define CONTOUR_SIMPLIFIER_H_ + +#include "PlaneSegmenter.h" + +#include + +namespace mmp { + +/** + * Turns a face found by PlaneSegmenter into a quadrilateral, when it is one. + * + * Its outer outline is followed along the edges of its cells, then reduced to + * four corners by the method of Douglas and Peucker: the two points farthest + * apart, then each time the point farthest from the outline kept so far. Each + * corner is then put where the straight lines fitted on its two sides cross, + * which is closer to the true corner than any point of the outline. + * + * Every polygon is in pixels of the output; a quadrilateral goes clockwise on + * the screen, from its corner nearest to the top left. + */ +class ContourSimplifier +{ +public: + /// Returns the outer outline of @a region, along the edges of its cells: its holes are ignored. + static QPolygonF outline(const PlaneRegion& region); + + /** + * Returns the four corners that best follow @a outline, or an empty polygon + * when it has fewer than four points. + */ + static QPolygonF quad(const QPolygonF& outline); + + /// Returns true when @a quad has four corners and turns the same way at each of them. + static bool isConvex(const QPolygonF& quad); + + /// Returns the area of @a polygon, positive when it goes clockwise on the screen. + static qreal signedArea(const QPolygonF& polygon); + + /// Returns @a quad with each of its sides moved inwards by @a distance pixels. + static QPolygonF inset(const QPolygonF& quad, qreal distance); +}; + +} + +#endif /* CONTOUR_SIMPLIFIER_H_ */ diff --git a/src/automap/FaceFinder.cpp b/src/automap/FaceFinder.cpp new file mode 100644 index 00000000..c726e707 --- /dev/null +++ b/src/automap/FaceFinder.cpp @@ -0,0 +1,100 @@ +/* + * FaceFinder.cpp + * + * (c) 2026 MapMap contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "FaceFinder.h" + +#include "ContourSimplifier.h" + +#include + +#include +#include + +namespace mmp { + +namespace { + +// Two faces whose middles are closer than this share of the width of the output are side by side: +// the higher one comes first. +const qreal COLUMN_SHARE = 0.02; + +QPolygonF clamped(const QPolygonF& polygon, const QSizeF& size) +{ + QPolygonF result; + for (const QPointF& p : polygon) + result.append(QPointF(qBound(0.0, p.x(), size.width()), qBound(0.0, p.y(), size.height()))); + return result; +} + +} + +QVector FaceFinder::find(const Correspondence& correspondence, const Options& options) +{ + QVector faces; + const QSizeF outputSize(correspondence.outputSize()); + const QVector regions = PlaneSegmenter::segment(correspondence, options.segmenter); + for (const PlaneRegion& region : regions) + { + Face face; + face.outline = clamped(ContourSimplifier::outline(region), outputSize); + face.area = std::fabs(ContourSimplifier::signedArea(face.outline)); + if (face.area <= 0) + continue; + const QPolygonF quad = clamped(ContourSimplifier::quad(face.outline), outputSize); + if (ContourSimplifier::isConvex(quad)) + { + const qreal quadArea = std::fabs(ContourSimplifier::signedArea(quad)); + if (std::fabs(quadArea - face.area) < options.maximumAreaDifference * face.area) + { + face.quad = quad; + face.fitsQuad = true; + } + } + faces.append(face); + } + + // From left to right, then from top to bottom. + const qreal column = qMax(1.0, COLUMN_SHARE * outputSize.width()); + std::stable_sort(faces.begin(), faces.end(), [column](const Face& a, const Face& b) { + const QPointF ma = a.outline.boundingRect().center(); + const QPointF mb = b.outline.boundingRect().center(); + const int ca = qFloor(ma.x() / column); + const int cb = qFloor(mb.x() / column); + if (ca != cb) + return ca < cb; + return ma.y() < mb.y(); + }); + return faces; +} + +QVector FaceFinder::find(const Correspondence& correspondence) +{ + return find(correspondence, Options()); +} + +int FaceFinder::quadCount(const QVector& faces) +{ + int count = 0; + for (const Face& face : faces) + if (face.fitsQuad) + count++; + return count; +} + +} diff --git a/src/automap/FaceFinder.h b/src/automap/FaceFinder.h new file mode 100644 index 00000000..c8729af9 --- /dev/null +++ b/src/automap/FaceFinder.h @@ -0,0 +1,72 @@ +/* + * FaceFinder.h + * + * (c) 2026 MapMap contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef FACE_FINDER_H_ +#define FACE_FINDER_H_ + +#include "Correspondence.h" +#include "PlaneSegmenter.h" + +#include +#include + +namespace mmp { + +/** + * Finds the flat faces of a scene from what a scan read, and those of them + * that a quadrilateral fits. + * + * The faces come from PlaneSegmenter and their corners from + * ContourSimplifier. A face is a quadrilateral when its four corners cover + * its outline to less than a tenth of its area, and its corners all turn the + * same way; the others, the gable of a house or a block half hidden behind + * another, are kept as outlines, to place by hand. + * + * The faces come in the order of reading: from left to right, then from top + * to bottom when they are side by side. + */ +class FaceFinder +{ +public: + /// A face found. + struct Face { + QPolygonF outline; ///< Its outer outline, in pixels of the output. + QPolygonF quad; ///< Its four corners, clockwise from the top left; empty when fitsQuad is false. + bool fitsQuad = false; ///< True when a quadrilateral fits it. + qreal area = 0; ///< The area inside its outline, in square pixels of the output. + }; + + struct Options { + PlaneSegmenter::Options segmenter; + qreal maximumAreaDifference = 0.10; ///< How much the area of the quadrilateral may differ from that of the face. + }; + + /// Returns the faces of @a correspondence, in the order of reading. + static QVector find(const Correspondence& correspondence, const Options& options); + + /// Returns the faces of @a correspondence, in the order of reading, with the options by default. + static QVector find(const Correspondence& correspondence); + + /// Returns how many of @a faces fit a quadrilateral. + static int quadCount(const QVector& faces); +}; + +} + +#endif /* FACE_FINDER_H_ */ diff --git a/src/automap/PlaneSegmenter.cpp b/src/automap/PlaneSegmenter.cpp new file mode 100644 index 00000000..a9386e66 --- /dev/null +++ b/src/automap/PlaneSegmenter.cpp @@ -0,0 +1,547 @@ +/* + * PlaneSegmenter.cpp + * + * (c) 2026 MapMap contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "PlaneSegmenter.h" + +#include + +#include +#include + +namespace mmp { + +namespace { + +const int UNKNOWNS = 8; +const double SINGULAR_PIVOT = 1e-12; +const double INFINITE_WEIGHT = 1e-12; + +// The largest side of a cell: beyond, the faces would lose too much of their edges. +const int MAXIMUM_CELL_SIZE = 4; + +// How many cells are drawn to score a transform: enough to compare two of them, cheap to count. +const int SCORED_CELLS = 4000; + +// The four points of a draw are taken in a square around the first one, of this share of the output. +const qreal DRAW_RADIUS_SHARE = 0.03; +const int MINIMUM_DRAW_RADIUS = 3; +// How many times a nearby cell is looked for, before the draw is given up. +const int NEARBY_TRIES = 40; +// Three points of a draw closer to a line than this, as a share of the square of the radius, are refused. +const qreal MINIMUM_TRIANGLE_SHARE = 0.02; + +// How many times a transform is fitted again on the face it found, before it is kept. +const int REFITS = 5; +// Fewer points than this left once the edges are left out: the whole face is used instead. +const int MINIMUM_FIT_CELLS = 16; + +enum CellState : char { EMPTY = 0, FREE = 1, TAKEN = 2 }; + +/// A small generator of pseudo-random numbers, the same on every system (xorshift64*). +class Random +{ +public: + explicit Random(quint64 seed) : _state(seed ? seed : 1) {} + + /// Returns a number from 0 to @a bound - 1. + int bounded(int bound) + { + _state ^= _state >> 12; + _state ^= _state << 25; + _state ^= _state >> 27; + return int((_state * 2685821657736338717ULL >> 33) % quint64(bound)); + } + +private: + quint64 _state; +}; + +/// Solves a x = b for a matrix of UNKNOWNS × UNKNOWNS, by elimination with partial pivoting. +bool solve(double a[UNKNOWNS][UNKNOWNS], double b[UNKNOWNS], double x[UNKNOWNS]) +{ + double scale = 0; + for (int i = 0; i < UNKNOWNS; i++) + for (int j = 0; j < UNKNOWNS; j++) + scale = qMax(scale, std::fabs(a[i][j])); + if (scale == 0) + return false; + + for (int column = 0; column < UNKNOWNS; column++) + { + int pivot = column; + for (int row = column + 1; row < UNKNOWNS; row++) + if (std::fabs(a[row][column]) > std::fabs(a[pivot][column])) + pivot = row; + if (std::fabs(a[pivot][column]) < SINGULAR_PIVOT * scale) + return false; + if (pivot != column) + { + for (int j = 0; j < UNKNOWNS; j++) + std::swap(a[pivot][j], a[column][j]); + std::swap(b[pivot], b[column]); + } + for (int row = column + 1; row < UNKNOWNS; row++) + { + const double factor = a[row][column] / a[column][column]; + for (int j = column; j < UNKNOWNS; j++) + a[row][j] -= factor * a[column][j]; + b[row] -= factor * b[column]; + } + } + for (int row = UNKNOWNS - 1; row >= 0; row--) + { + double sum = b[row]; + for (int j = row + 1; j < UNKNOWNS; j++) + sum -= a[row][j] * x[j]; + x[row] = sum / a[row][row]; + } + return true; +} + +/// The shift and the scale that bring points around 0, at a mean distance of about 1. +struct Normalization { + double x = 0, y = 0, scale = 1; + + explicit Normalization(const QVector& points) + { + for (const QPointF& p : points) + { + x += p.x(); + y += p.y(); + } + x /= points.size(); + y /= points.size(); + double distance = 0; + for (const QPointF& p : points) + distance += std::hypot(p.x() - x, p.y() - y); + distance /= points.size(); + scale = distance > 0 ? M_SQRT2 / distance : 1; + } +}; + +/// Labels the 4-connected blocks of the cells where @a mask is set; returns the size of each label (label 0 is unused). +QVector label(const QVector& mask, int width, int height, QVector* labels) +{ + labels->fill(0, mask.size()); + QVector sizes(1, 0); + QVector queue; + for (int start = 0; start < mask.size(); start++) + { + if (!mask.at(start) || labels->at(start)) + continue; + const int current = sizes.size(); + int size = 0; + queue.clear(); + queue.append(start); + (*labels)[start] = current; + for (int k = 0; k < queue.size(); k++) + { + const int index = queue.at(k); + size++; + const int x = index % width; + const int y = index / width; + const int neighbours[4] = { x > 0 ? index - 1 : -1, x < width - 1 ? index + 1 : -1, + y > 0 ? index - width : -1, y < height - 1 ? index + width : -1 }; + for (int n : neighbours) + { + if (n >= 0 && mask.at(n) && !labels->at(n)) + { + (*labels)[n] = current; + queue.append(n); + } + } + } + sizes.append(size); + } + return sizes; +} + +/// Removes from @a mask the cells that touch its outside, @a times times. +void erode(QVector* mask, int width, int height, int times) +{ + for (int t = 0; t < times; t++) + { + const QVector before = *mask; + for (int y = 0; y < height; y++) + { + for (int x = 0; x < width; x++) + { + const int index = y * width + x; + if (!before.at(index)) + continue; + if (x == 0 || y == 0 || x == width - 1 || y == height - 1 || !before.at(index - 1) || + !before.at(index + 1) || !before.at(index - width) || !before.at(index + width)) + (*mask)[index] = 0; + } + } + } +} + +/// What the segmenter knows of each cell of the grid. +struct Grid { + int cellSize = 1; + int width = 0; + int height = 0; + QVector camera; // The mean point of the camera of each cell. + QVector output; // The mean point of the output of each cell. + QVector state; + + bool follows(int index, const Homography& homography, qreal tolerance) const + { + QPointF mapped; + if (!homography.map(camera.at(index), &mapped)) + return false; + const QPointF error = mapped - output.at(index); + return error.x() * error.x() + error.y() * error.y() < tolerance * tolerance; + } + + /// Returns the free cells that follow @a homography. + QVector followers(const Homography& homography, qreal tolerance) const + { + QVector mask(state.size(), 0); + for (int i = 0; i < state.size(); i++) + mask[i] = (state.at(i) == FREE && follows(i, homography, tolerance)) ? 1 : 0; + return mask; + } + + /// Fits a transform on the cells of @a mask; false when they do not define one. + bool fit(const QVector& mask, Homography* result) const + { + QVector from; + QVector to; + for (int i = 0; i < mask.size(); i++) + { + if (mask.at(i)) + { + from.append(camera.at(i)); + to.append(output.at(i)); + } + } + return Homography::fit(from, to, result); + } +}; + +/// Returns the block of @a mask that shares the most cells with @a previous, or an empty mask. +QVector blockOver(const QVector& mask, const QVector& previous, int width, int height, int* count) +{ + QVector labels; + const QVector sizes = label(mask, width, height, &labels); + QVector overlap(sizes.size(), 0); + for (int i = 0; i < labels.size(); i++) + if (labels.at(i) && previous.at(i)) + overlap[labels.at(i)]++; + int best = 0; + for (int l = 1; l < sizes.size(); l++) + if (overlap.at(l) > overlap.at(best) || (overlap.at(l) == overlap.at(best) && best && sizes.at(l) > sizes.at(best))) + best = l; + QVector block(mask.size(), 0); + *count = 0; + if (best == 0) + return block; + for (int i = 0; i < labels.size(); i++) + { + if (labels.at(i) == best) + { + block[i] = 1; + (*count)++; + } + } + return block; +} + +/// Returns the largest block of @a mask. +QVector largestBlock(const QVector& mask, int width, int height, int* count) +{ + QVector labels; + const QVector sizes = label(mask, width, height, &labels); + int best = 0; + for (int l = 1; l < sizes.size(); l++) + if (best == 0 || sizes.at(l) > sizes.at(best)) + best = l; + QVector block(mask.size(), 0); + *count = best ? sizes.at(best) : 0; + for (int i = 0; best && i < labels.size(); i++) + block[i] = labels.at(i) == best ? 1 : 0; + return block; +} + +qreal triangleArea(const QPointF& a, const QPointF& b, const QPointF& c) +{ + return std::fabs((b.x() - a.x()) * (c.y() - a.y()) - (c.x() - a.x()) * (b.y() - a.y())) / 2; +} + +} + +Homography::Homography() + : m{ 1, 0, 0, 0, 1, 0, 0, 0, 1 } +{ +} + +bool Homography::map(const QPointF& point, QPointF* mapped) const +{ + const double w = m[6] * point.x() + m[7] * point.y() + m[8]; + if (std::fabs(w) < INFINITE_WEIGHT) + return false; + *mapped = QPointF((m[0] * point.x() + m[1] * point.y() + m[2]) / w, + (m[3] * point.x() + m[4] * point.y() + m[5]) / w); + return true; +} + +bool Homography::fit(const QVector& from, const QVector& to, Homography* result) +{ + if (from.size() < 4 || from.size() != to.size()) + return false; + + // Worked on points brought around 0, for precision. + const Normalization nFrom(from); + const Normalization nTo(to); + + double a[UNKNOWNS][UNKNOWNS] = {}; + double b[UNKNOWNS] = {}; + for (int i = 0; i < from.size(); i++) + { + const double x = (from.at(i).x() - nFrom.x) * nFrom.scale; + const double y = (from.at(i).y() - nFrom.y) * nFrom.scale; + const double u = (to.at(i).x() - nTo.x) * nTo.scale; + const double v = (to.at(i).y() - nTo.y) * nTo.scale; + // u (h6 x + h7 y + 1) = h0 x + h1 y + h2, and the same for v. + const double rowU[UNKNOWNS] = { x, y, 1, 0, 0, 0, -x * u, -y * u }; + const double rowV[UNKNOWNS] = { 0, 0, 0, x, y, 1, -x * v, -y * v }; + for (int r = 0; r < UNKNOWNS; r++) + { + for (int c = 0; c < UNKNOWNS; c++) + a[r][c] += rowU[r] * rowU[c] + rowV[r] * rowV[c]; + b[r] += rowU[r] * u + rowV[r] * v; + } + } + double h[UNKNOWNS]; + if (!solve(a, b, h)) + return false; + + // Back to pixels: H = inverse(T_to) × Hn × T_from. + const double n[9] = { h[0], h[1], h[2], h[3], h[4], h[5], h[6], h[7], 1 }; + const double tFrom[9] = { nFrom.scale, 0, -nFrom.scale * nFrom.x, 0, nFrom.scale, -nFrom.scale * nFrom.y, 0, 0, 1 }; + const double toInverse[9] = { 1 / nTo.scale, 0, nTo.x, 0, 1 / nTo.scale, nTo.y, 0, 0, 1 }; + double product[9] = {}; + for (int r = 0; r < 3; r++) + for (int c = 0; c < 3; c++) + for (int k = 0; k < 3; k++) + product[r * 3 + c] += n[r * 3 + k] * tFrom[k * 3 + c]; + Homography homography; + for (int r = 0; r < 3; r++) + { + for (int c = 0; c < 3; c++) + { + double sum = 0; + for (int k = 0; k < 3; k++) + sum += toInverse[r * 3 + k] * product[k * 3 + c]; + homography.m[r * 3 + c] = sum; + } + } + if (std::fabs(homography.m[8]) < INFINITE_WEIGHT) + return false; + const double last = homography.m[8]; + for (double& term : homography.m) + term /= last; + *result = homography; + return true; +} + +int PlaneSegmenter::cellSizeFor(const Correspondence& correspondence) +{ + const int read = correspondence.readCount(); + if (read <= 0) + return 1; + const qreal outputArea = qreal(correspondence.outputSize().width()) * correspondence.outputSize().height(); + return qBound(1, qCeil(std::sqrt(outputArea / read)), MAXIMUM_CELL_SIZE); +} + +QVector PlaneSegmenter::segment(const Correspondence& correspondence, const Options& options) +{ + QVector regions; + if (correspondence.isEmpty()) + return regions; + + // Every point read goes to the cell of the output it lands in; each cell keeps their mean. + Grid grid; + grid.cellSize = cellSizeFor(correspondence); + const QSize outputSize = correspondence.outputSize(); + grid.width = (outputSize.width() + grid.cellSize - 1) / grid.cellSize; + grid.height = (outputSize.height() + grid.cellSize - 1) / grid.cellSize; + const int cellCount = grid.width * grid.height; + grid.camera.fill(QPointF(), cellCount); + grid.output.fill(QPointF(), cellCount); + grid.state.fill(EMPTY, cellCount); + QVector pointsPerCell(cellCount, 0); + const QSize cameraSize = correspondence.cameraSize(); + for (int y = 0; y < cameraSize.height(); y++) + { + for (int x = 0; x < cameraSize.width(); x++) + { + if (!correspondence.isRead(x, y)) + continue; + const QPointF point = correspondence.outputPoint(x, y); + const int cx = qBound(0, qFloor(point.x() / grid.cellSize), grid.width - 1); + const int cy = qBound(0, qFloor(point.y() / grid.cellSize), grid.height - 1); + const int index = cy * grid.width + cx; + grid.camera[index] += QPointF(x, y); + grid.output[index] += point; + pointsPerCell[index]++; + } + } + int freeCount = 0; + for (int i = 0; i < cellCount; i++) + { + if (pointsPerCell.at(i) > 0) + { + grid.camera[i] /= pointsPerCell.at(i); + grid.output[i] /= pointsPerCell.at(i); + grid.state[i] = FREE; + freeCount++; + } + } + + const qreal cellArea = qreal(grid.cellSize) * grid.cellSize; + const int minimumCells = qMax(4, qCeil(options.minimumAreaShare * outputSize.width() * outputSize.height() / cellArea)); + const int radius = qMax(MINIMUM_DRAW_RADIUS, qRound(DRAW_RADIUS_SHARE * qMax(grid.width, grid.height))); + const qreal minimumTriangle = MINIMUM_TRIANGLE_SHARE * radius * radius * cellArea; + const int fitErosion = qCeil(options.fitMargin / grid.cellSize); + Random random(options.seed); + + while (freeCount >= minimumCells && regions.size() < options.maximumFaces) + { + QVector freeCells; + freeCells.reserve(freeCount); + for (int i = 0; i < cellCount; i++) + if (grid.state.at(i) == FREE) + freeCells.append(i); + + QVector scored; + const int scoredCount = qMin(SCORED_CELLS, freeCells.size()); + for (int i = 0; i < scoredCount; i++) + scored.append(freeCells.at(random.bounded(freeCells.size()))); + + // Draws of four nearby cells; the transform followed by the most scored cells wins. + Homography best; + int bestScore = -1; + for (int draw = 0; draw < options.draws; draw++) + { + const int first = freeCells.at(random.bounded(freeCells.size())); + int picked[4] = { first, -1, -1, -1 }; + int count = 1; + const int fx = first % grid.width; + const int fy = first / grid.width; + for (int t = 0; t < NEARBY_TRIES && count < 4; t++) + { + const int x = fx + random.bounded(2 * radius + 1) - radius; + const int y = fy + random.bounded(2 * radius + 1) - radius; + if (x < 0 || y < 0 || x >= grid.width || y >= grid.height) + continue; + const int index = y * grid.width + x; + if (grid.state.at(index) != FREE) + continue; + bool known = false; + for (int k = 0; k < count; k++) + known = known || picked[k] == index; + if (!known) + picked[count++] = index; + } + if (count < 4) + continue; + + QVector from; + QVector to; + for (int index : picked) + { + from.append(grid.camera.at(index)); + to.append(grid.output.at(index)); + } + bool flat = false; + for (int skip = 0; skip < 4 && !flat; skip++) + { + QVector three; + for (int k = 0; k < 4; k++) + if (k != skip) + three.append(to.at(k)); + flat = triangleArea(three.at(0), three.at(1), three.at(2)) < minimumTriangle; + } + Homography homography; + if (flat || !Homography::fit(from, to, &homography)) + continue; + + int score = 0; + for (int index : scored) + if (grid.follows(index, homography, options.tolerance)) + score++; + if (score > bestScore) + { + bestScore = score; + best = homography; + } + } + if (bestScore <= 0) + break; + + // The largest block that follows it, then fitted again on its inner part, until the block stops changing. + int blockCells = 0; + QVector block = largestBlock(grid.followers(best, options.tolerance), grid.width, grid.height, &blockCells); + for (int refit = 0; refit < REFITS && blockCells > 0; refit++) + { + QVector inner = block; + erode(&inner, grid.width, grid.height, fitErosion); + int innerCells = 0; + for (char c : inner) + innerCells += c; + Homography fitted; + if (!grid.fit(innerCells >= MINIMUM_FIT_CELLS ? inner : block, &fitted)) + break; + int newCells = 0; + const QVector newBlock = blockOver(grid.followers(fitted, options.tolerance), block, + grid.width, grid.height, &newCells); + const bool same = newBlock == block; + if (newCells == 0) + break; + block = newBlock; + blockCells = newCells; + if (same) + break; + } + if (blockCells < minimumCells) + break; + + PlaneRegion region; + region.cellSize = grid.cellSize; + region.gridSize = QSize(grid.width, grid.height); + region.cells.fill(false, cellCount); + for (int i = 0; i < cellCount; i++) + { + if (block.at(i)) + { + region.cells[i] = true; + grid.state[i] = TAKEN; + } + } + region.cellCount = blockCells; + freeCount -= blockCells; + regions.append(region); + } + return regions; +} + +} diff --git a/src/automap/PlaneSegmenter.h b/src/automap/PlaneSegmenter.h new file mode 100644 index 00000000..f853f62e --- /dev/null +++ b/src/automap/PlaneSegmenter.h @@ -0,0 +1,112 @@ +/* + * PlaneSegmenter.h + * + * (c) 2026 MapMap contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef PLANE_SEGMENTER_H_ +#define PLANE_SEGMENTER_H_ + +#include "Correspondence.h" + +#include +#include +#include + +namespace mmp { + +/** + * A perspective transform: the rule that takes the points of the camera that + * see a flat face to the points of the output that light it. + */ +class Homography +{ +public: + /// The identity. + Homography(); + + /// Maps @a point; returns false when it goes to infinity. + bool map(const QPointF& point, QPointF* mapped) const; + + /** + * Returns the transform that takes each of @a from to the point of @a to at + * the same index, in the sense of least squares when there are more than + * four points. Returns false when the points do not define one (fewer than + * four, or three of them on a line). + */ + static bool fit(const QVector& from, const QVector& to, Homography* result); + + /// Its nine terms, row by row; the last one is 1. + double m[9]; +}; + +/** + * A flat face found on the output: the cells of a grid laid over the output + * that belong to it. + */ +struct PlaneRegion { + int cellSize = 1; ///< The side of a cell, in pixels of the output. + QSize gridSize; ///< How many cells across and down. + QVector cells; ///< One per cell, row by row: true when the cell belongs to the face. + int cellCount = 0; ///< How many cells belong to it. + + /// Returns true when cell (x, y) belongs to the face; false outside the grid. + bool contains(int x, int y) const + { + return x >= 0 && y >= 0 && x < gridSize.width() && y < gridSize.height() && cells.at(y * gridSize.width() + x); + } + + /// Returns its area, in square pixels of the output. + qreal area() const { return qreal(cellCount) * cellSize * cellSize; } +}; + +/** + * Finds the flat faces of a scene from what a scan read (a Correspondence). + * + * Each point of a flat face goes from the camera to the output by the same + * perspective transform. The segmenter draws four nearby points at random, + * computes the transform they define, and counts the points that follow it to + * a pixel and a half; after a few hundred draws it keeps the best transform, + * fits it again on all of its points, and keeps the largest piece of the + * output that follows it in one block. That piece is a face: it is taken out, + * and the search starts again, until only pieces smaller than a share of the + * output are left. + * + * The draws come from a generator with a fixed seed: the same scan always + * gives the same faces. + */ +class PlaneSegmenter +{ +public: + struct Options { + qreal tolerance = 1.5; ///< How far from the transform a point may be, in pixels of the output. + qreal minimumAreaShare = 0.005; ///< The smallest face, as a share of the area of the output. + int draws = 400; ///< How many transforms are tried for each face. + quint32 seed = 1; ///< The seed of the draws. + qreal fitMargin = 2; ///< The band left out along the edges of a face when fitting its transform, in pixels. + int maximumFaces = 64; ///< The search stops after this many faces. + }; + + /// Returns the faces of @a correspondence, the largest first. + static QVector segment(const Correspondence& correspondence, const Options& options); + + /// Returns the side of the cells used for @a correspondence: about one point of the camera per cell. + static int cellSizeFor(const Correspondence& correspondence); +}; + +} + +#endif /* PLANE_SEGMENTER_H_ */ diff --git a/src/automap/automap.pri b/src/automap/automap.pri index ea6a4272..36196f2a 100644 --- a/src/automap/automap.pri +++ b/src/automap/automap.pri @@ -5,14 +5,20 @@ include(../src.pri) # on scenes computed by the tests. HEADERS += $$PWD/AutoMapFrameSource.h \ $$PWD/AutoMapScan.h \ + $$PWD/ContourSimplifier.h \ $$PWD/Correspondence.h \ + $$PWD/FaceFinder.h \ $$PWD/GrayCodeDecoder.h \ $$PWD/GrayCodePattern.h \ + $$PWD/PlaneSegmenter.h \ $$PWD/SyntheticScene.h SOURCES += $$PWD/AutoMapFrameSource.cpp \ $$PWD/AutoMapScan.cpp \ + $$PWD/ContourSimplifier.cpp \ $$PWD/Correspondence.cpp \ + $$PWD/FaceFinder.cpp \ $$PWD/GrayCodeDecoder.cpp \ $$PWD/GrayCodePattern.cpp \ + $$PWD/PlaneSegmenter.cpp \ $$PWD/SyntheticScene.cpp diff --git a/tests/TestAutoMap.cpp b/tests/TestAutoMap.cpp index 0fd29425..5452104d 100644 --- a/tests/TestAutoMap.cpp +++ b/tests/TestAutoMap.cpp @@ -13,9 +13,12 @@ #include "AutoMapFrameSource.h" #include "AutoMapScan.h" +#include "ContourSimplifier.h" #include "Correspondence.h" +#include "FaceFinder.h" #include "GrayCodeDecoder.h" #include "GrayCodePattern.h" +#include "PlaneSegmenter.h" #include "SyntheticScene.h" #include @@ -47,6 +50,9 @@ const qreal READABLE_REFLECTANCE = 0.5; // How far from the middle of a point of the camera its corners are checked. const qreal POINT_HALF_SIZE = 0.45; +// What the criteria of the slice ask: the corners of a face found within 2 pixels of the true ones. +const qreal MAXIMUM_CORNER_ERROR = 2; + // How long a scan with the event loop may take. const int SCAN_TIMEOUT_MS = 60000; @@ -116,6 +122,70 @@ Measure measure(const SyntheticScene& scene, const Correspondence& correspondenc return result; } +/// Returns the distance from @a point to the nearest corner of @a quad. +qreal distanceToNearestCorner(const QPointF& point, const QPolygonF& quad) +{ + qreal nearest = -1; + for (const QPointF& corner : quad) + { + const qreal distance = QLineF(point, corner).length(); + if (nearest < 0 || distance < nearest) + nearest = distance; + } + return nearest; +} + +/// Returns the farthest a corner of @a found is from the nearest corner of @a truth. +qreal cornerError(const QPolygonF& found, const QPolygonF& truth) +{ + qreal worst = 0; + for (const QPointF& corner : found) + worst = qMax(worst, distanceToNearestCorner(corner, truth)); + return worst; +} + +/// Returns the index of the face of @a scene whose output corners are nearest to @a quad. +int matchingFace(const SyntheticScene& scene, const QPolygonF& quad) +{ + int best = -1; + qreal bestError = 0; + for (int i = 0; i < scene.faces().size(); i++) + { + const qreal error = cornerError(quad, scene.faces().at(i).outputQuad); + if (best < 0 || error < bestError) + { + best = i; + bestError = error; + } + } + return best; +} + +/// The faces found in the large scene, found once for all the tests that read them. +const QVector& largeSceneFaces() +{ + static const QVector faces = FaceFinder::find(largeSceneDecoder().result()); + return faces; +} + +/// Adds to @a correspondence the points of the camera inside @a cameraArea, lit by @a cameraToOutput of them. +void addPlane(Correspondence* correspondence, const QPolygonF& cameraArea, const QTransform& cameraToOutput) +{ + const QRect bounds = cameraArea.boundingRect().toAlignedRect(); + for (int y = bounds.top(); y <= bounds.bottom(); y++) + { + for (int x = bounds.left(); x <= bounds.right(); x++) + { + const QPointF middle(x + 0.5, y + 0.5); + if (!cameraArea.containsPoint(middle, Qt::OddEvenFill)) + continue; + // As a decoder gives it: the middle of the pixel of the output. + const QPointF output = cameraToOutput.map(middle); + correspondence->set(x, y, QPointF(qFloor(output.x()) + 0.5, qFloor(output.y()) + 0.5)); + } + } +} + /// A camera that never sends an image. class SilentFrameSource : public AutoMapFrameSource { @@ -348,3 +418,161 @@ void TestAutoMap::failsWhenCameraDoesNotSeeProjection() QTRY_COMPARE_WITH_TIMEOUT(failed.count(), 1, SCAN_TIMEOUT_MS); QCOMPARE(finished.count(), 0); } + +void TestAutoMap::fitsHomography() +{ + // A perspective transform, as a tilted face gives. + QTransform truth; + QVERIFY(QTransform::quadToQuad(QPolygonF() << QPointF(10, 20) << QPointF(300, 40) << QPointF(280, 250) << QPointF(30, 200), + QPolygonF() << QPointF(0, 0) << QPointF(640, 0) << QPointF(640, 360) << QPointF(0, 360), + truth)); + // Four points far apart, then points between them. + QVector from = { QPointF(20, 30), QPointF(280, 50), QPointF(260, 230), QPointF(40, 190) }; + for (int i = 0; i < 16; i++) + from.append(QPointF(30 + 15 * i, 40 + 11 * ((i * 7) % 16))); + QVector to; + for (const QPointF& p : from) + to.append(truth.map(p)); + + // From four points, then from all of them. + for (int count : {4, 20}) + { + Homography homography; + QVERIFY(Homography::fit(from.mid(0, count), to.mid(0, count), &homography)); + for (int i = 0; i < from.size(); i++) + { + QPointF mapped; + QVERIFY(homography.map(from.at(i), &mapped)); + QVERIFY2(QLineF(mapped, to.at(i)).length() < 1e-6, qPrintable(QString::number(count))); + } + } + + // Three points on a line, or only three points, do not define one. + Homography homography; + QVERIFY(!Homography::fit({QPointF(0, 0), QPointF(1, 1), QPointF(2, 2), QPointF(5, 0)}, + {QPointF(0, 0), QPointF(1, 1), QPointF(2, 2), QPointF(5, 0)}, &homography)); + QVERIFY(!Homography::fit({QPointF(0, 0), QPointF(1, 1), QPointF(2, 0)}, + {QPointF(0, 0), QPointF(1, 1), QPointF(2, 0)}, &homography)); +} + +void TestAutoMap::followsOutlineOfCells() +{ + // An L of three cells of two pixels, and a cell that only touches it by a corner: only the L is followed. + PlaneRegion region; + region.cellSize = 2; + region.gridSize = QSize(4, 3); + region.cells = { true, true, false, false, + true, false, true, false, + false, false, false, false }; + region.cellCount = 4; + const QPolygonF outline = ContourSimplifier::outline(region); + const QPolygonF expected = QPolygonF() << QPointF(0, 0) << QPointF(4, 0) << QPointF(4, 2) << QPointF(2, 2) + << QPointF(2, 4) << QPointF(0, 4); + QCOMPARE(outline, expected); + QCOMPARE(ContourSimplifier::signedArea(outline), 12.0); + + // Once the cell between them is added, they make one face. + region.cells[5] = true; + region.cellCount = 5; + QCOMPARE(ContourSimplifier::outline(region), QPolygonF() << QPointF(0, 0) << QPointF(4, 0) << QPointF(4, 2) + << QPointF(6, 2) << QPointF(6, 4) << QPointF(0, 4)); +} + +void TestAutoMap::insetsQuad() +{ + const QPolygonF square = QPolygonF() << QPointF(0, 0) << QPointF(10, 0) << QPointF(10, 10) << QPointF(0, 10); + const QPolygonF expected = QPolygonF() << QPointF(1, 1) << QPointF(9, 1) << QPointF(9, 9) << QPointF(1, 9); + const QPolygonF inset = ContourSimplifier::inset(square, 1); + for (int k = 0; k < 4; k++) + QVERIFY(QLineF(inset.at(k), expected.at(k)).length() < 1e-9); + + // The same the other way round. + QPolygonF reversed = square; + std::reverse(reversed.begin(), reversed.end()); + for (const QPointF& corner : ContourSimplifier::inset(reversed, 1)) + QVERIFY(distanceToNearestCorner(corner, expected) < 1e-9); + + QVERIFY(ContourSimplifier::isConvex(square)); + QVERIFY(!ContourSimplifier::isConvex(QPolygonF() << QPointF(0, 0) << QPointF(10, 0) << QPointF(2, 2) + << QPointF(0, 10))); +} + +void TestAutoMap::findsFacesOfScene() +{ + const SyntheticScene& scene = largeScene(); + const QVector& faces = largeSceneFaces(); + + // The table and the four faces of the blocks; not the black object, that the camera cannot read. + QCOMPARE(faces.size(), 5); + QCOMPARE(FaceFinder::quadCount(faces), 5); + QSet matched; + for (const FaceFinder::Face& face : faces) + { + QVERIFY(face.fitsQuad); + const int index = matchingFace(scene, face.quad); + QVERIFY(scene.faces().at(index).reflectance > READABLE_REFLECTANCE); + matched.insert(index); + const qreal error = cornerError(face.quad, scene.faces().at(index).outputQuad); + QString corners; + for (const QPointF& corner : face.quad) + corners += QStringLiteral(" (%1, %2)").arg(corner.x(), 0, 'f', 1).arg(corner.y(), 0, 'f', 1); + QVERIFY2(error < MAXIMUM_CORNER_ERROR, + qPrintable(QStringLiteral("face %1: %2 pixels; corners%3").arg(index).arg(error).arg(corners))); + // Clockwise on the screen. + QVERIFY(ContourSimplifier::signedArea(face.quad) > 0); + } + QCOMPARE(matched.size(), 5); +} + +void TestAutoMap::ordersFacesFromLeftToRight() +{ + const SyntheticScene& scene = largeScene(); + QVector order; + for (const FaceFinder::Face& face : largeSceneFaces()) + order.append(matchingFace(scene, face.quad)); + // The top of block A, its front under it, the table, block C under the middle of the table, block B. + QCOMPARE(order, QVector({2, 1, 0, 4, 3})); +} + +void TestAutoMap::findsTheSameFacesTwice() +{ + const SyntheticScene scene = SyntheticScene::blocksOnTable(SMALL_CAMERA_SIZE, SMALL_OUTPUT_SIZE); + const Correspondence correspondence = decodeScene(scene, GrayCodePattern(SMALL_OUTPUT_SIZE)).result(); + const QVector first = FaceFinder::find(correspondence); + const QVector second = FaceFinder::find(correspondence); + QVERIFY(!first.isEmpty()); + QCOMPARE(first.size(), second.size()); + for (int i = 0; i < first.size(); i++) + { + QCOMPARE(first.at(i).quad, second.at(i).quad); + QCOMPARE(first.at(i).outline, second.at(i).outline); + } +} + +void TestAutoMap::keepsOutlineOfLShape() +{ + // An L, seen straight, and a square seen a little turned: two faces of different planes. + Correspondence correspondence(QSize(200, 200), QSize(200, 200)); + const QPolygonF lShape = QPolygonF() << QPointF(20, 20) << QPointF(100, 20) << QPointF(100, 60) << QPointF(60, 60) + << QPointF(60, 140) << QPointF(20, 140); + addPlane(&correspondence, lShape, QTransform()); + const QPolygonF squareOutput = QPolygonF() << QPointF(120, 120) << QPointF(180, 120) << QPointF(180, 180) + << QPointF(120, 180); + QTransform outputToCamera; + QVERIFY(QTransform::quadToQuad(squareOutput, + QPolygonF() << QPointF(125, 118) << QPointF(185, 126) << QPointF(178, 186) + << QPointF(118, 178), + outputToCamera)); + addPlane(&correspondence, outputToCamera.map(squareOutput), outputToCamera.inverted()); + + const QVector faces = FaceFinder::find(correspondence); + QCOMPARE(faces.size(), 2); + QCOMPARE(FaceFinder::quadCount(faces), 1); + // From left to right: the L, kept as an outline, then the square. + QVERIFY(!faces.at(0).fitsQuad); + QVERIFY(faces.at(0).quad.isEmpty()); + QVERIFY2(qAbs(faces.at(0).area - 6400) < 400, qPrintable(QString::number(faces.at(0).area))); + QVERIFY(faces.at(1).fitsQuad); + const qreal error = cornerError(faces.at(1).quad, squareOutput); + QVERIFY2(error < MAXIMUM_CORNER_ERROR, qPrintable(QString::number(error))); +} diff --git a/tests/TestAutoMap.h b/tests/TestAutoMap.h index 57792236..77f402e6 100644 --- a/tests/TestAutoMap.h +++ b/tests/TestAutoMap.h @@ -4,8 +4,8 @@ * Unit tests for the scan with structured light (src/automap): the stripes * projected, their decoding on scenes computed by SyntheticScene, with noise * and the light of a room, the image of the scene seen from the projector, and - * the whole scan with a simulated camera that sends its images late. No - * camera and no projector are needed. + * the whole scan with a simulated camera that sends its images late, and the + * flat faces found from what was read. No camera and no projector are needed. * * (c) 2026 MapMap contributors * @@ -39,6 +39,13 @@ private slots: void scansWithLateCamera(); void failsWithoutSteadyImage(); void failsWhenCameraDoesNotSeeProjection(); + void fitsHomography(); + void followsOutlineOfCells(); + void insetsQuad(); + void findsFacesOfScene(); + void ordersFacesFromLeftToRight(); + void findsTheSameFacesTwice(); + void keepsOutlineOfLShape(); }; #endif /* TEST_AUTO_MAP_H_ */ diff --git a/tests/tests.pro b/tests/tests.pro index e8cf50d9..42407a29 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -231,11 +231,13 @@ SOURCES += \ TestTranslations.cpp \ TestAutoMap.cpp -# The scan with structured light: everything but the dialog. -HEADERS += $$AUTOMAP/AutoMapFrameSource.h $$AUTOMAP/AutoMapScan.h $$AUTOMAP/Correspondence.h \ - $$AUTOMAP/GrayCodeDecoder.h $$AUTOMAP/GrayCodePattern.h $$AUTOMAP/SyntheticScene.h -SOURCES += $$AUTOMAP/AutoMapFrameSource.cpp $$AUTOMAP/AutoMapScan.cpp $$AUTOMAP/Correspondence.cpp \ - $$AUTOMAP/GrayCodeDecoder.cpp $$AUTOMAP/GrayCodePattern.cpp $$AUTOMAP/SyntheticScene.cpp +# The scan with structured light and the faces found from it: everything but the dialog. +HEADERS += $$AUTOMAP/AutoMapFrameSource.h $$AUTOMAP/AutoMapScan.h $$AUTOMAP/ContourSimplifier.h \ + $$AUTOMAP/Correspondence.h $$AUTOMAP/FaceFinder.h $$AUTOMAP/GrayCodeDecoder.h \ + $$AUTOMAP/GrayCodePattern.h $$AUTOMAP/PlaneSegmenter.h $$AUTOMAP/SyntheticScene.h +SOURCES += $$AUTOMAP/AutoMapFrameSource.cpp $$AUTOMAP/AutoMapScan.cpp $$AUTOMAP/ContourSimplifier.cpp \ + $$AUTOMAP/Correspondence.cpp $$AUTOMAP/FaceFinder.cpp $$AUTOMAP/GrayCodeDecoder.cpp \ + $$AUTOMAP/GrayCodePattern.cpp $$AUTOMAP/PlaneSegmenter.cpp $$AUTOMAP/SyntheticScene.cpp # The inspector. HEADERS += $$GUI/inspector/SettingFormat.h $$GUI/inspector/SettingControl.h $$GUI/inspector/ChoiceChips.h \ From bccb18389cd517d597fd3d0ab85e9c7fb7d052c1 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Fri, 4 Dec 2026 02:04:19 -0500 Subject: [PATCH 03/10] Match the faces of a new scan with those of the previous one 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. --- src/automap/FaceMatcher.cpp | 98 +++++++++++++++++++++++++++++++++++++ src/automap/FaceMatcher.h | 62 +++++++++++++++++++++++ src/automap/automap.pri | 2 + tests/TestAutoMap.cpp | 34 +++++++++++++ tests/TestAutoMap.h | 2 + tests/tests.pro | 4 +- 6 files changed, 200 insertions(+), 2 deletions(-) create mode 100644 src/automap/FaceMatcher.cpp create mode 100644 src/automap/FaceMatcher.h diff --git a/src/automap/FaceMatcher.cpp b/src/automap/FaceMatcher.cpp new file mode 100644 index 00000000..ba43dd75 --- /dev/null +++ b/src/automap/FaceMatcher.cpp @@ -0,0 +1,98 @@ +/* + * FaceMatcher.cpp + * + * (c) 2026 MapMap contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "FaceMatcher.h" + +#include "ContourSimplifier.h" + +#include +#include + +namespace mmp { + +namespace { + +// The hue turns by the golden angle from one face to the next: two faces close in number are never +// close in colour, however many there are. +const qreal GOLDEN_ANGLE_DEGREES = 137.508; +const qreal FULL_TURN_DEGREES = 360; +const qreal FACE_SATURATION = 0.7; +const qreal FACE_LIGHTNESS = 0.55; + +/// A pair of faces that overlap, to be matched from the one that overlaps the most. +struct Pair { + qreal overlap; + int previous; + int found; +}; + +qreal area(const QPolygonF& polygon) +{ + return std::fabs(ContourSimplifier::signedArea(polygon)); +} + +} + +qreal FaceMatcher::overlap(const QPolygonF& a, const QPolygonF& b) +{ + if (!a.boundingRect().intersects(b.boundingRect())) + return 0; + const qreal shared = area(a.intersected(b)); + const qreal together = area(a) + area(b) - shared; + return together > 0 ? shared / together : 0; +} + +FaceMatcher::Match FaceMatcher::match(const QVector& previous, const QVector& found, + qreal minimumOverlap) +{ + QVector pairs; + for (int p = 0; p < previous.size(); p++) + { + for (int f = 0; f < found.size(); f++) + { + const qreal shared = overlap(previous.at(p), found.at(f)); + if (shared >= minimumOverlap) + pairs.append({ shared, p, f }); + } + } + std::stable_sort(pairs.begin(), pairs.end(), [](const Pair& a, const Pair& b) { return a.overlap > b.overlap; }); + + Match result; + result.previousOfFound.fill(-1, found.size()); + QVector taken(previous.size(), false); + for (const Pair& pair : pairs) + { + if (taken.at(pair.previous) || result.previousOfFound.at(pair.found) >= 0) + continue; + taken[pair.previous] = true; + result.previousOfFound[pair.found] = pair.previous; + } + for (int p = 0; p < previous.size(); p++) + if (!taken.at(p)) + result.lost.append(p); + return result; +} + +QColor FaceMatcher::colorOf(int number) +{ + const qreal hue = std::fmod(number * GOLDEN_ANGLE_DEGREES, FULL_TURN_DEGREES) / FULL_TURN_DEGREES; + return QColor::fromHslF(float(hue), float(FACE_SATURATION), float(FACE_LIGHTNESS)); +} + +} diff --git a/src/automap/FaceMatcher.h b/src/automap/FaceMatcher.h new file mode 100644 index 00000000..71512f7d --- /dev/null +++ b/src/automap/FaceMatcher.h @@ -0,0 +1,62 @@ +/* + * FaceMatcher.h + * + * (c) 2026 MapMap contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef FACE_MATCHER_H_ +#define FACE_MATCHER_H_ + +#include +#include +#include + +namespace mmp { + +/** + * Finds, when an automatic mapping is made again, which face found now is + * which face of the previous one, so that its layer follows it with its + * source and its effects; and gives each face its colour. + * + * Two faces are the same when they cover mostly the same part of the output: + * after a projector was knocked, its faces have moved a little. + */ +class FaceMatcher +{ +public: + /// What became of the previous faces. + struct Match { + QVector previousOfFound; ///< For each face found, the index of the same previous face, or -1 when it is new. + QVector lost; ///< The previous faces that were not found again. + }; + + /// Two faces are the same when they share at least this share of the area they cover together. + static constexpr qreal MINIMUM_OVERLAP = 0.25; + + /// Matches each of @a found with one of @a previous, the faces that overlap the most first. + static Match match(const QVector& previous, const QVector& found, + qreal minimumOverlap = MINIMUM_OVERLAP); + + /// Returns the area that @a a and @a b share, divided by the area they cover together, from 0 to 1. + static qreal overlap(const QPolygonF& a, const QPolygonF& b); + + /// Returns the colour of face @a number: each one far from the previous ones, even with many faces. + static QColor colorOf(int number); +}; + +} + +#endif /* FACE_MATCHER_H_ */ diff --git a/src/automap/automap.pri b/src/automap/automap.pri index 36196f2a..89a5dc42 100644 --- a/src/automap/automap.pri +++ b/src/automap/automap.pri @@ -8,6 +8,7 @@ HEADERS += $$PWD/AutoMapFrameSource.h \ $$PWD/ContourSimplifier.h \ $$PWD/Correspondence.h \ $$PWD/FaceFinder.h \ + $$PWD/FaceMatcher.h \ $$PWD/GrayCodeDecoder.h \ $$PWD/GrayCodePattern.h \ $$PWD/PlaneSegmenter.h \ @@ -18,6 +19,7 @@ SOURCES += $$PWD/AutoMapFrameSource.cpp \ $$PWD/ContourSimplifier.cpp \ $$PWD/Correspondence.cpp \ $$PWD/FaceFinder.cpp \ + $$PWD/FaceMatcher.cpp \ $$PWD/GrayCodeDecoder.cpp \ $$PWD/GrayCodePattern.cpp \ $$PWD/PlaneSegmenter.cpp \ diff --git a/tests/TestAutoMap.cpp b/tests/TestAutoMap.cpp index 5452104d..49e8a200 100644 --- a/tests/TestAutoMap.cpp +++ b/tests/TestAutoMap.cpp @@ -16,6 +16,7 @@ #include "ContourSimplifier.h" #include "Correspondence.h" #include "FaceFinder.h" +#include "FaceMatcher.h" #include "GrayCodeDecoder.h" #include "GrayCodePattern.h" #include "PlaneSegmenter.h" @@ -576,3 +577,36 @@ void TestAutoMap::keepsOutlineOfLShape() const qreal error = cornerError(faces.at(1).quad, squareOutput); QVERIFY2(error < MAXIMUM_CORNER_ERROR, qPrintable(QString::number(error))); } + +void TestAutoMap::matchesFacesThatMoved() +{ + const auto square = [](qreal x, qreal y, qreal side) { + return QPolygonF() << QPointF(x, y) << QPointF(x + side, y) << QPointF(x + side, y + side) << QPointF(x, y + side); + }; + QCOMPARE(FaceMatcher::overlap(square(0, 0, 10), square(0, 0, 10)), 1.0); + QCOMPARE(FaceMatcher::overlap(square(0, 0, 10), square(20, 0, 10)), 0.0); + QVERIFY(qAbs(FaceMatcher::overlap(square(0, 0, 10), square(5, 0, 10)) - 1.0 / 3) < 1e-9); + + // The projector was knocked: every face moved by a few pixels. A block was taken away, another added. + const QVector previous = { square(0, 0, 100), square(200, 0, 50), square(400, 0, 50) }; + const QVector found = { square(300, 300, 50), square(214, 8, 50), square(14, 8, 100) }; + const FaceMatcher::Match match = FaceMatcher::match(previous, found); + QCOMPARE(match.previousOfFound, QVector({-1, 1, 0})); + QCOMPARE(match.lost, QVector({2})); +} + +void TestAutoMap::givesFacesDistinctColors() +{ + // However many faces there are, two faces close in number have hues far apart. + const int faces = 12; + for (int i = 1; i <= faces; i++) + { + const QColor color = FaceMatcher::colorOf(i); + QVERIFY(color.isValid()); + for (int j = i + 1; j <= qMin(faces, i + 3); j++) + { + const int distance = qAbs(color.hslHue() - FaceMatcher::colorOf(j).hslHue()); + QVERIFY2(qMin(distance, 360 - distance) > 40, qPrintable(QStringLiteral("%1 and %2").arg(i).arg(j))); + } + } +} diff --git a/tests/TestAutoMap.h b/tests/TestAutoMap.h index 77f402e6..f5b6cb0c 100644 --- a/tests/TestAutoMap.h +++ b/tests/TestAutoMap.h @@ -46,6 +46,8 @@ private slots: void ordersFacesFromLeftToRight(); void findsTheSameFacesTwice(); void keepsOutlineOfLShape(); + void matchesFacesThatMoved(); + void givesFacesDistinctColors(); }; #endif /* TEST_AUTO_MAP_H_ */ diff --git a/tests/tests.pro b/tests/tests.pro index 42407a29..14d7328a 100644 --- a/tests/tests.pro +++ b/tests/tests.pro @@ -233,10 +233,10 @@ SOURCES += \ # The scan with structured light and the faces found from it: everything but the dialog. HEADERS += $$AUTOMAP/AutoMapFrameSource.h $$AUTOMAP/AutoMapScan.h $$AUTOMAP/ContourSimplifier.h \ - $$AUTOMAP/Correspondence.h $$AUTOMAP/FaceFinder.h $$AUTOMAP/GrayCodeDecoder.h \ + $$AUTOMAP/Correspondence.h $$AUTOMAP/FaceFinder.h $$AUTOMAP/FaceMatcher.h $$AUTOMAP/GrayCodeDecoder.h \ $$AUTOMAP/GrayCodePattern.h $$AUTOMAP/PlaneSegmenter.h $$AUTOMAP/SyntheticScene.h SOURCES += $$AUTOMAP/AutoMapFrameSource.cpp $$AUTOMAP/AutoMapScan.cpp $$AUTOMAP/ContourSimplifier.cpp \ - $$AUTOMAP/Correspondence.cpp $$AUTOMAP/FaceFinder.cpp $$AUTOMAP/GrayCodeDecoder.cpp \ + $$AUTOMAP/Correspondence.cpp $$AUTOMAP/FaceFinder.cpp $$AUTOMAP/FaceMatcher.cpp $$AUTOMAP/GrayCodeDecoder.cpp \ $$AUTOMAP/GrayCodePattern.cpp $$AUTOMAP/PlaneSegmenter.cpp $$AUTOMAP/SyntheticScene.cpp # The inspector. From cce1b6379b16f677a4a927ceefe6ce1d515fa571 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Fri, 4 Dec 2026 02:10:27 -0500 Subject: [PATCH 04/10] Create a layer of each flat face found by the automatic mapping 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. --- src/core/Commands.cpp | 24 +++++ src/core/Commands.h | 23 +++++ src/core/MM.cpp | 3 + src/core/MM.h | 4 + src/gui/AutoMappingDialog.cpp | 176 +++++++++++++++++++++++++++++++++- src/gui/AutoMappingDialog.h | 26 ++++- src/gui/MainWindow.cpp | 163 +++++++++++++++++++++++++++++-- src/gui/MainWindow.h | 52 +++++++++- src/gui/MapperGLCanvas.cpp | 57 +++++++++++ src/gui/MapperGLCanvas.h | 25 +++++ 10 files changed, 538 insertions(+), 15 deletions(-) diff --git a/src/core/Commands.cpp b/src/core/Commands.cpp index 72c2215f..80cf1501 100644 --- a/src/core/Commands.cpp +++ b/src/core/Commands.cpp @@ -466,6 +466,30 @@ void EffectPlacementCommand::_take() _mainWindow->updateCanvases(); } +SetOutputVerticesCommand::SetOutputVerticesCommand(MainWindow *mainWindow, uid layerId, + const QVector& vertices, QUndoCommand *parent) : + QUndoCommand(parent), + _mainWindow(mainWindow), + _layerId(layerId), + _after(vertices) +{ + setText(QObject::tr("Move layer")); + Layer::ptr layer = _mainWindow->getMappingManager().getLayerById(_layerId); + if (layer && layer->getShape()) + _before = layer->getShape()->getVertices(); +} + +void SetOutputVerticesCommand::_apply(const QVector& vertices) +{ + Layer::ptr layer = _mainWindow->getMappingManager().getLayerById(_layerId); + if (!layer || !layer->getShape() || layer->getShape()->nVertices() != vertices.size()) + return; + MShape::ptr shape = layer->getShape(); + for (int i = 0; i < vertices.size(); i++) + shape->setVertex(i, vertices.at(i)); + _mainWindow->updateCanvases(); +} + AddEffectCommand::AddEffectCommand(MainWindow *mainWindow, LinkTarget::ElementKind element, uid elementId, const Effect::ptr& effect, QUndoCommand *parent) : EffectPlacementCommand(mainWindow, element, elementId, effect, INT_MAX, parent) diff --git a/src/core/Commands.h b/src/core/Commands.h index 9b52e2f0..5fb31bff 100644 --- a/src/core/Commands.h +++ b/src/core/Commands.h @@ -322,6 +322,29 @@ class EffectPlacementCommand : public QUndoCommand QList _links; }; +/** + * Moves every vertex of the output shape of a layer at once: the automatic + * mapping, made again, puts the layer of a face back on it. + */ +class SetOutputVerticesCommand : public QUndoCommand +{ +public: + /// @a vertices has one point per vertex of the output shape of the layer, in the same order. + SetOutputVerticesCommand(MainWindow *mainWindow, uid layerId, const QVector& vertices, + QUndoCommand *parent = 0); + + void undo() Q_DECL_OVERRIDE { _apply(_before); } + void redo() Q_DECL_OVERRIDE { _apply(_after); } + +private: + void _apply(const QVector& vertices); + + MainWindow *_mainWindow; + uid _layerId; + QVector _before; + QVector _after; +}; + /// Adds an effect at the end of the list of a source or a layer. class AddEffectCommand : public EffectPlacementCommand { diff --git a/src/core/MM.cpp b/src/core/MM.cpp index be9cb615..3d39836c 100644 --- a/src/core/MM.cpp +++ b/src/core/MM.cpp @@ -67,6 +67,9 @@ const QColor MM::CONTROL_COLOR(WHITE); const QColor MM::CONTROL_COLOR_NON_SELECTED(QColor(CONTROL_COLOR.red(), CONTROL_COLOR.green(), CONTROL_COLOR.blue(), 63)); const QColor MM::CONTENT_OUTLINE_COLOR(MID_GRAY); const QColor MM::CONTENT_LABEL_COLOR(QColor(WHITE.red(), WHITE.green(), WHITE.blue(), 160)); +const QColor MM::FOUND_OUTLINE_COLOR(WHITE); +const QColor MM::GUIDE_OUTLINE_COLOR("#FFD84D"); +const QColor MM::OUTLINE_SHADOW_COLOR(QColor(0, 2, 14, 200)); const QColor MM::CONTROL_LOCKED_COLOR(LIGHT_RED); //const QBrush MM::VERTEX_LOCKED_BACKGROUND(QColor(CONTROL_LOCKED_COLOR.red(), CONTROL_LOCKED_COLOR.green(), CONTROL_LOCKED_COLOR.blue(), 63)); const QBrush MM::VERTEX_BACKGROUND(QColor(CROSSHAIR_STROKE.red(), CROSSHAIR_STROKE.green(), CROSSHAIR_STROKE.blue(), 63)); diff --git a/src/core/MM.h b/src/core/MM.h index e9c75b8d..b89edd2b 100644 --- a/src/core/MM.h +++ b/src/core/MM.h @@ -131,6 +131,10 @@ class MM /// Editors: outline of the source image or the output frame, and its caption. static const QColor CONTENT_OUTLINE_COLOR; static const QColor CONTENT_LABEL_COLOR; + /// Output editor, after an automatic mapping: a face found, a face to place by hand, and the line under them. + static const QColor FOUND_OUTLINE_COLOR; + static const QColor GUIDE_OUTLINE_COLOR; + static const QColor OUTLINE_SHADOW_COLOR; static const QColor CONTROL_LOCKED_COLOR; static const QBrush VERTEX_BACKGROUND; static const QBrush VERTEX_SELECTED_BACKGROUND; diff --git a/src/gui/AutoMappingDialog.cpp b/src/gui/AutoMappingDialog.cpp index 5d393983..85a2d95e 100644 --- a/src/gui/AutoMappingDialog.cpp +++ b/src/gui/AutoMappingDialog.cpp @@ -21,10 +21,13 @@ #include "AutoMapFrameSource.h" #include "AutoMapScan.h" +#include "ContourSimplifier.h" #include "Correspondence.h" +#include "FaceMatcher.h" #include "MainWindow.h" #include "SyntheticScene.h" +#include #include #include #include @@ -33,8 +36,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -119,6 +124,9 @@ AutoMappingDialog::AutoMappingDialog(MainWindow* mainWindow) QDialogButtonBox* buttons = new QDialogButtonBox(this); _startButton = buttons->addButton(tr("Start"), QDialogButtonBox::AcceptRole); + _createButton = buttons->addButton(tr("Create Shapes"), QDialogButtonBox::ActionRole); + _createButton->setToolTip(tr("Make a layer of each face found, with a colour of its own")); + _createButton->setEnabled(false); _closeButton = buttons->addButton(QDialogButtonBox::Close); _startButton->setDefault(true); @@ -139,6 +147,7 @@ AutoMappingDialog::AutoMappingDialog(MainWindow* mainWindow) connect(_cameraBox, &QComboBox::currentIndexChanged, this, &AutoMappingDialog::_openCamera); connect(_skipFineStripes, &QCheckBox::toggled, this, &AutoMappingDialog::_updateEstimate); connect(_startButton, &QPushButton::clicked, this, &AutoMappingDialog::_start); + connect(_createButton, &QPushButton::clicked, this, &AutoMappingDialog::_createShapes); connect(_closeButton, &QPushButton::clicked, this, &AutoMappingDialog::reject); _updateEstimate(); @@ -304,16 +313,174 @@ void AutoMappingDialog::_onProgress(int done, int total) void AutoMappingDialog::_onFinished() { const QImage view = _scan->projectorView(); + const Correspondence correspondence = _scan->correspondence(); _scan->deleteLater(); _scan = nullptr; _mainWindow->endAutoMappingOutput(); _setRunning(false); _mainWindow->setAutoMappingImage(Correspondence::withCoverage(view, UNREAD_COLOR)); + + // A second or so, once the output is back. + { + QApplication::setOverrideCursor(Qt::WaitCursor); + const auto restore = qScopeGuard([] { QApplication::restoreOverrideCursor(); }); + _faces = FaceFinder::find(correspondence); + } + _showFaces(true); + + const int quads = FaceFinder::quadCount(_faces); const int readPercent = qRound(Correspondence::readShare(view) * PERCENT); - _status->setText(tr("Done: the camera saw %1 % of the output. The scene seen from the projector is under the shapes " - "of the output editor; in red, what the camera did not see. Tools > Show Auto-Mapping Image " - "hides it, Tools > Clear Auto-Mapping Image forgets it.").arg(readPercent)); + _status->setText(tr("Done: %1, %2. The camera saw %3 % of the output: the scene seen from the projector is under " + "the shapes of the output editor; in red, what the camera did not see. " + "Tools > Show Auto-Mapping Image hides it with the outlines.") + .arg(tr("%n face(s) found", nullptr, quads)) + .arg(tr("%n outline(s) to place by hand", nullptr, int(_faces.size()) - quads)) + .arg(readPercent)); + + const bool update = !_mainWindow->autoMappingLayers().isEmpty(); + _createButton->setText(update ? tr("Update Shapes") : tr("Create Shapes")); + _createButton->setToolTip(update ? tr("Move the layers of the previous scan onto their faces, " + "and make a layer of each new face") + : tr("Make a layer of each face found, with a colour of its own")); + _createButton->setEnabled(quads > 0 || update); + if (_createButton->isEnabled()) + _createButton->setDefault(true); +} + +AutoMappingDialog::Plan AutoMappingDialog::_plan() const +{ + Plan plan; + QVector found; + QVector faceOfFound; + for (int i = 0; i < _faces.size(); i++) + { + if (!_faces.at(i).fitsQuad) + continue; + found.append(ContourSimplifier::inset(_faces.at(i).quad, FACE_INSET)); + faceOfFound.append(i); + } + + const QVector previousLayers = _mainWindow->autoMappingLayers(); + QVector previous; + for (uid id : previousLayers) + previous.append(_mainWindow->outputCorners(id)); + const FaceMatcher::Match match = FaceMatcher::match(previous, found); + + // A face found again keeps the number of its layer, if it is named after one; the new ones come after. + plan.numbers.fill(0, _faces.size()); + int next = _mainWindow->highestFaceNumber() + 1; + for (int f = 0; f < found.size(); f++) + { + const int p = match.previousOfFound.at(f); + if (p >= 0) + { + const uid id = previousLayers.at(p); + plan.change.moved.append(qMakePair(id, found.at(f))); + Layer::ptr layer = _mainWindow->getMappingManager().getLayerById(id); + plan.numbers[faceOfFound.at(f)] = layer ? MainWindow::faceNumber(layer->getName()) : 0; + } + else + { + plan.change.added.append(qMakePair(next, found.at(f))); + plan.numbers[faceOfFound.at(f)] = next; + next++; + } + } + for (int p : match.lost) + plan.change.removed.append(previousLayers.at(p)); + return plan; +} + +void AutoMappingDialog::_showFaces(bool withQuads) +{ + const Plan plan = _plan(); + QVector outlines; + for (int i = 0; i < _faces.size(); i++) + { + const FaceFinder::Face& face = _faces.at(i); + MapperGLCanvas::Outline outline; + if (face.fitsQuad) + { + if (!withQuads) + continue; + outline.polygon = face.quad; + if (plan.numbers.at(i) > 0) + outline.label = QString::number(plan.numbers.at(i)); + } + else + { + outline.polygon = face.outline; + outline.dashed = true; + } + outlines.append(outline); + } + _mainWindow->setAutoMappingOutlines(outlines); +} + +void AutoMappingDialog::_createShapes() +{ + Plan plan = _plan(); + const int moved = plan.change.moved.size(); + const int added = plan.change.added.size(); + const int lost = plan.change.removed.size(); + + // Faces of an earlier scan: say what will happen to them, with the numbers, before. + if (moved > 0 || lost > 0) + { + QStringList lines; + if (moved > 0) + lines << tr("%n layer(s) of the previous scan will follow their face: they keep their source and their effects, " + "only their corners move.", nullptr, moved); + if (added > 0) + lines << tr("%n new face(s) will be added.", nullptr, added); + QPushButton* removeButton = nullptr; + QPushButton* keepButton = nullptr; + QMessageBox box(QMessageBox::Question, tr("Update Shapes"), QString(), QMessageBox::NoButton, this); + if (lost > 0) + { + QStringList names; + for (uid id : plan.change.removed) + { + Layer::ptr layer = _mainWindow->getMappingManager().getLayerById(id); + if (layer) + names << layer->getName(); + } + lines << tr("%n layer(s) of the previous scan were not found again: %1.", nullptr, lost) + .arg(names.join(QStringLiteral(", "))); + removeButton = box.addButton(tr("Update and Remove Them"), QMessageBox::AcceptRole); + keepButton = box.addButton(tr("Update and Keep Them"), QMessageBox::AcceptRole); + } + else + removeButton = box.addButton(tr("Update"), QMessageBox::AcceptRole); + box.addButton(QMessageBox::Cancel); + box.setDefaultButton(removeButton); + box.setText(lines.join(QStringLiteral("\n\n"))); + box.exec(); + if (box.clickedButton() != removeButton && box.clickedButton() != keepButton) + return; + if (box.clickedButton() == keepButton) + plan.change.removed.clear(); + } + + _mainWindow->applyAutoMapping(plan.change); + + // The quadrilaterals are layers now: only the outlines to place by hand are left. + _showFaces(false); + _createButton->setEnabled(false); + _closeButton->setDefault(true); + + QStringList done; + if (moved > 0) + done << tr("%n layer(s) moved", nullptr, moved); + if (added > 0) + done << tr("%n shape(s) created", nullptr, added); + if (!plan.change.removed.isEmpty()) + done << tr("%n layer(s) removed", nullptr, int(plan.change.removed.size())); + const int guides = int(_faces.size()) - FaceFinder::quadCount(_faces); + if (guides > 0) + done << tr("%n outline(s) to place by hand", nullptr, guides); + _status->setText(tr("%1. Edit > Undo takes it all back at once.").arg(done.join(QStringLiteral(", ")))); } void AutoMappingDialog::_onFailed(const QString& message) @@ -337,6 +504,9 @@ void AutoMappingDialog::_setRunning(bool running) _screenBox->setEnabled(!running); _skipFineStripes->setEnabled(!running); _startButton->setEnabled(!running && _source); + // A new scan finds new faces. + if (running) + _createButton->setEnabled(false); _closeButton->setText(running ? tr("Cancel") : tr("Close")); } diff --git a/src/gui/AutoMappingDialog.h b/src/gui/AutoMappingDialog.h index 5feeed3c..bbd64b34 100644 --- a/src/gui/AutoMappingDialog.h +++ b/src/gui/AutoMappingDialog.h @@ -20,6 +20,9 @@ #ifndef AUTO_MAPPING_DIALOG_H_ #define AUTO_MAPPING_DIALOG_H_ +#include "FaceFinder.h" +#include "MainWindow.h" + #include #include #include @@ -43,7 +46,11 @@ class MainWindow; * camera films, and starts the scan. During the scan, the output covers the * screen of the projector and shows a countdown, then the stripes; afterwards * it is shown as before. The scene seen from the projector then appears under - * the shapes of the output editor. + * the shapes of the output editor, with the flat faces found in it: plain and + * numbered for those a quadrilateral fits, dashed for those to place by hand. + * "Create Shapes" makes a layer of each quadrilateral; when the automatic + * mapping was made before, "Update Shapes" moves the layers of the faces found + * again, with their sources and effects, instead. */ class AutoMappingDialog : public QDialog { @@ -68,6 +75,9 @@ class AutoMappingDialog : public QDialog /// How many of the finest series of stripes are skipped when asked to. static const int SKIPPED_FINE_BITS = 2; + /// How far inside its face a shape is put, in pixels of the output: a pixel too many lights the wall behind. + static constexpr qreal FACE_INSET = 1; + public slots: /// Stops a scan that runs, then closes. void reject() override; @@ -85,6 +95,20 @@ public slots: void _updateEstimate(); QSize _outputSize() const; + /// What creating the shapes would change, given the layers of the previous mappings still in the project. + struct Plan { + MainWindow::AutoMappingChange change; ///< With every lost layer in change.removed. + QVector numbers; ///< For each face of _faces, the number shown on it; 0 for none. + }; + Plan _plan() const; + /// Draws the faces over the output editor; the quadrilaterals only while they are still to create. + void _showFaces(bool withQuads); + void _createShapes(); + + // The faces found by the last scan, in the order of reading. + QVector _faces; + QPushButton* _createButton; + MainWindow* _mainWindow; QComboBox* _cameraBox; QComboBox* _screenBox; diff --git a/src/gui/MainWindow.cpp b/src/gui/MainWindow.cpp index 0a630440..6901d963 100644 --- a/src/gui/MainWindow.cpp +++ b/src/gui/MainWindow.cpp @@ -22,8 +22,10 @@ #include "MainWindow.h" #include "AutoMappingDialog.h" #include "BottomPanel.h" +#include "ContourSimplifier.h" #include "CuePanel.h" #include "EffectTypes.h" +#include "FaceMatcher.h" #include "MediaCues.h" #include "SettingFormat.h" #include "AddSourceActions.h" @@ -2017,8 +2019,9 @@ bool MainWindow::clearProject() mappingManager->clearAll(); setOutputResolution(defaultOutputResolution()); - // The scene seen from the projector belongs to the room of this project. + // The scene seen from the projector, and the faces found in it, belong to the room of this project. clearAutoMappingImage(); + _autoMappingLayers.clear(); // Refresh GL canvases to clear them out. sourceCanvas->repaint(); @@ -4655,29 +4658,171 @@ void MainWindow::showAutoMappingPattern(const QImage& image) void MainWindow::setAutoMappingImage(const QImage& image) { _autoMappingImage = image; - // A project may be cleared before the actions are made. - if (showAutoMappingImageAction) + _updateAutoMappingActions(); + if (destinationCanvas) { - const bool hasImage = !image.isNull(); - showAutoMappingImageAction->setEnabled(hasImage); - clearAutoMappingImageAction->setEnabled(hasImage); - QSignalBlocker blocker(showAutoMappingImageAction); - showAutoMappingImageAction->setChecked(true); + destinationCanvas->setBackgroundImage(image); + destinationCanvas->setOutlines(_autoMappingOutlines); } +} + +void MainWindow::setAutoMappingOutlines(const QVector& outlines) +{ + _autoMappingOutlines = outlines; + _updateAutoMappingActions(); if (destinationCanvas) - destinationCanvas->setBackgroundImage(image); + { + destinationCanvas->setBackgroundImage(_autoMappingImage); + destinationCanvas->setOutlines(outlines); + } +} + +void MainWindow::_updateAutoMappingActions() +{ + // A project may be cleared before the actions are made. + if (!showAutoMappingImageAction) + return; + const bool hasSomething = !_autoMappingImage.isNull() || !_autoMappingOutlines.isEmpty(); + showAutoMappingImageAction->setEnabled(hasSomething); + clearAutoMappingImageAction->setEnabled(hasSomething); + // What was just set is shown. + QSignalBlocker blocker(showAutoMappingImageAction); + showAutoMappingImageAction->setChecked(true); } void MainWindow::setAutoMappingImageShown(bool shown) { destinationCanvas->setBackgroundImage(shown ? _autoMappingImage : QImage()); + destinationCanvas->setOutlines(shown ? _autoMappingOutlines : QVector()); } void MainWindow::clearAutoMappingImage() { + _autoMappingOutlines.clear(); setAutoMappingImage(QImage()); } +QVector MainWindow::autoMappingLayers() const +{ + QVector layers; + for (uid id : _autoMappingLayers) + if (mappingManager->getLayerById(id)) + layers.append(id); + return layers; +} + +QPolygonF MainWindow::outputCorners(uid layerId) const +{ + Layer::ptr layer = mappingManager->getLayerById(layerId); + if (!layer) + return QPolygonF(); + QSharedPointer mesh = qSharedPointerDynamicCast(layer->getShape()); + if (mesh.isNull() || mesh->nColumns() < 2 || mesh->nRows() < 2) + return QPolygonF(); + const int lastColumn = mesh->nColumns() - 1; + const int lastRow = mesh->nRows() - 1; + return QPolygonF() << mesh->getVertex2d(0, 0) << mesh->getVertex2d(lastColumn, 0) + << mesh->getVertex2d(lastColumn, lastRow) << mesh->getVertex2d(0, lastRow); +} + +int MainWindow::faceNumber(const QString& layerName) +{ + // The name is translated: what comes before and after the number in "Face %1". + const QStringList parts = tr("Face %1").split(QStringLiteral("%1")); + if (parts.size() != 2) + return 0; + const QRegularExpression pattern(QStringLiteral("^%1(\\d+)%2$").arg(QRegularExpression::escape(parts.at(0)), + QRegularExpression::escape(parts.at(1)))); + const QRegularExpressionMatch match = pattern.match(layerName); + return match.hasMatch() ? match.captured(1).toInt() : 0; +} + +int MainWindow::highestFaceNumber() const +{ + int highest = 0; + for (int i = 0; i < mappingManager->nLayers(); i++) + highest = qMax(highest, faceNumber(mappingManager->getLayer(i)->getName())); + return highest; +} + +void MainWindow::applyAutoMapping(const AutoMappingChange& change) +{ + if (change.moved.isEmpty() && change.added.isEmpty() && change.removed.isEmpty()) + return; + + undoStack->beginMacro(tr("Auto-Mapping")); + + for (uid id : change.removed) + if (mappingManager->getLayerById(id)) + undoStack->push(new DeleteLayerCommand(this, id)); + + // Each vertex of a moved layer goes where the perspective from its old corners to the new ones takes it: + // the inner vertices of a mesh keep their place on the face. + QVector layers; + uid selected = NULL_UID; + for (const QPair& move : change.moved) + { + Layer::ptr layer = mappingManager->getLayerById(move.first); + const QPolygonF before = outputCorners(move.first); + QTransform transform; + if (!layer || before.size() != 4 || move.second.size() != 4 || + !QTransform::quadToQuad(before, move.second, transform)) + continue; + QVector vertices; + for (const QPointF& vertex : layer->getShape()->getVertices()) + vertices.append(transform.map(vertex)); + undoStack->push(new SetOutputVerticesCommand(this, move.first, vertices)); + layers.append(move.first); + if (selected == NULL_UID) + selected = move.first; + } + + // The largest face first, under the others: the table under the blocks. + QVector> added = change.added; + const auto area = [](const QPolygonF& quad) { return qAbs(ContourSimplifier::signedArea(quad)); }; + std::stable_sort(added.begin(), added.end(), [&area](const QPair& a, const QPair& b) { + return area(a.second) > area(b.second); + }); + int selectedNumber = INT_MAX; + for (const QPair& face : added) + { + if (face.second.size() != 4) + continue; + const QColor color = FaceMatcher::colorOf(face.first); + ColorGenerator* generator = new ColorGenerator(color); + generator->setName(strippedName(color.name())); + Source::ptr source(generator); + const uid sourceId = mappingManager->addSource(source); + undoStack->push(new AddSourceCommand(this, sourceId, source->getIcon(), source->getName())); + + const QPolygonF& quad = face.second; + MShape::ptr outputShape(new Mesh(quad.at(0), quad.at(1), quad.at(2), quad.at(3))); + MShape::ptr inputShape(Util::createMeshForRect(generator->getRect())); + Layer::ptr layer(new TextureLayer(source, outputShape, inputShape)); + layer->setName(tr("Face %1").arg(face.first)); + const uid layerId = mappingManager->addLayer(layer); + undoStack->push(new AddLayerCommand(this, layerId)); + layers.append(layerId); + if (face.first < selectedNumber) + { + selectedNumber = face.first; + selected = layerId; + } + } + + undoStack->endMacro(); + + // The layers of earlier mappings that were kept, then those of this one. + QVector remembered; + for (uid id : autoMappingLayers()) + if (!change.removed.contains(id) && !layers.contains(id)) + remembered.append(id); + _autoMappingLayers = remembered + layers; + + if (selected != NULL_UID && mappingManager->getLayerById(selected)) + setCurrentLayer(selected); +} + void MainWindow::openAutoMapping() { AutoMappingDialog dialog(this); diff --git a/src/gui/MainWindow.h b/src/gui/MainWindow.h index 38ee8df1..d153b6f7 100644 --- a/src/gui/MainWindow.h +++ b/src/gui/MainWindow.h @@ -564,8 +564,13 @@ public slots: QAction* autoMappingAction = nullptr; QAction* showAutoMappingImageAction = nullptr; QAction* clearAutoMappingImageAction = nullptr; - // The scene seen from the projector, from the last automatic mapping; never saved. + // The scene seen from the projector, from the last automatic mapping, and its faces; never saved. QImage _autoMappingImage; + QVector _autoMappingOutlines; + // The layers made by the automatic mapping since the project was opened (see autoMappingLayers()). + QVector _autoMappingLayers; + // Enables the actions on the scene seen from the projector when there is one, or outlines. + void _updateAutoMappingActions(); // How the output was shown before an automatic mapping took it (see beginAutoMappingOutput()). bool _autoMappingOutputActive = false; OutputMode _outputModeBeforeAutoMapping = OutputMode::Hidden; @@ -1055,9 +1060,52 @@ public slots: /// Shows or hides the scene seen from the projector, under the shapes of the output editor. void setAutoMappingImageShown(bool shown); - /// Forgets the scene seen from the projector. + /// Forgets the scene seen from the projector, and the outlines of its faces. void clearAutoMappingImage(); + /** + * Draws the faces found by an automatic mapping over the output editor: + * plain and numbered for those a quadrilateral fits, dashed for those to + * place by hand. They come and go with the scene seen from the projector + * (Tools > Show Auto-Mapping Image), and are never saved. + */ + void setAutoMappingOutlines(const QVector& outlines); + + /// What an automatic mapping changes in the layers, in one step of Undo (see applyAutoMapping()). + struct AutoMappingChange { + QVector> moved; ///< Layers of a previous mapping, and the new corners of their face. + QVector> added; ///< Faces to add: their number, and their corners. + QVector removed; ///< Layers of a previous mapping to remove. + }; + + /** + * Returns the layers made by the automatic mapping since the project was + * opened, that are still in it. They are not saved: once the project is + * opened again, the automatic mapping adds new layers. + */ + QVector autoMappingLayers() const; + + /** + * Returns the four corners of the output shape of layer @a layerId, + * clockwise from the top left, or an empty polygon when its shape is not a + * quadrilateral or a mesh. + */ + QPolygonF outputCorners(uid layerId) const; + + /// Returns the number of a layer named "Face " by the automatic mapping, or 0 for another name. + static int faceNumber(const QString& layerName); + + /// Returns the highest number of the layers named "Face ", or 0. + int highestFaceNumber() const; + + /** + * Makes @a change as one step of Undo, "Auto-Mapping": removes, moves the + * corners of, and adds layers. Each face added gets a colour of its own, + * and is named after its number; the largest is put under the others. The + * first face added, or moved, is selected. + */ + void applyAutoMapping(const AutoMappingChange& change); + /// Opens the window of the automatic mapping. void openAutoMapping(); diff --git a/src/gui/MapperGLCanvas.cpp b/src/gui/MapperGLCanvas.cpp index db3a92e5..b098e595 100644 --- a/src/gui/MapperGLCanvas.cpp +++ b/src/gui/MapperGLCanvas.cpp @@ -176,6 +176,9 @@ void MapperGLCanvas::paintEvent(QPaintEvent* event) void MapperGLCanvas::drawForeground(QPainter *painter , const QRectF &rect) { Q_UNUSED(rect); + // Under the controls of the shapes, so that they can still be grabbed. + _drawOutlines(painter); + if (MainWindow::window()->displayControls()) { uid mid = MainWindow::window()->getCurrentLayerId(); @@ -341,6 +344,60 @@ void MapperGLCanvas::setBackgroundImage(const QImage& image) viewport()->update(); } +void MapperGLCanvas::setOutlines(const QVector& outlines) +{ + _outlines = outlines; + viewport()->update(); +} + +void MapperGLCanvas::_drawOutlines(QPainter* painter) +{ + if (_outlines.isEmpty()) + return; + + // Drawn in screen pixels, so that they look the same at any zoom. + const QTransform toScreen = viewportTransform(); + painter->save(); + painter->resetTransform(); + painter->setRenderHint(QPainter::Antialiasing); + painter->setBrush(Qt::NoBrush); + + for (const Outline& outline : _outlines) + { + const QPolygonF polygon = toScreen.map(outline.polygon); + QPen shadow(MM::OUTLINE_SHADOW_COLOR, OUTLINE_SHADOW_WIDTH); + shadow.setJoinStyle(Qt::RoundJoin); + painter->setPen(shadow); + painter->drawPolygon(polygon); + + QPen line(outline.dashed ? MM::GUIDE_OUTLINE_COLOR : MM::FOUND_OUTLINE_COLOR, OUTLINE_WIDTH); + line.setJoinStyle(Qt::RoundJoin); + if (outline.dashed) + line.setDashPattern({ OUTLINE_DASH, OUTLINE_DASH / 2 }); + painter->setPen(line); + painter->drawPolygon(polygon); + } + + // The numbers over all the outlines. + QFont font = painter->font(); + font.setPixelSize(OUTLINE_LABEL_FONT_SIZE); + painter->setFont(font); + for (const Outline& outline : _outlines) + { + if (outline.label.isEmpty()) + continue; + const QPointF middle = toScreen.map(outline.polygon.boundingRect().center()); + const QRectF disc(middle - QPointF(OUTLINE_LABEL_RADIUS, OUTLINE_LABEL_RADIUS), + QSizeF(2 * OUTLINE_LABEL_RADIUS, 2 * OUTLINE_LABEL_RADIUS)); + painter->setPen(Qt::NoPen); + painter->setBrush(MM::OUTLINE_SHADOW_COLOR); + painter->drawEllipse(disc); + painter->setPen(MM::FOUND_OUTLINE_COLOR); + painter->drawText(disc, Qt::AlignCenter, outline.label); + } + painter->restore(); +} + void MapperGLCanvas::setContentLabel(const QString& label) { _contentLabel = label; diff --git a/src/gui/MapperGLCanvas.h b/src/gui/MapperGLCanvas.h index 31becea9..9cf52ade 100644 --- a/src/gui/MapperGLCanvas.h +++ b/src/gui/MapperGLCanvas.h @@ -127,6 +127,19 @@ class MapperGLCanvas: public QGraphicsView /// Returns the image drawn under the shapes, or a null image. QImage backgroundImage() const { return _backgroundImage; } + /// An outline drawn over the shapes, to guide: a face found by the automatic mapping. + struct Outline { + QPolygonF polygon; ///< In the coordinates of the scene: pixels of the output, in the output editor. + QString label; ///< Written in its middle, in a small disc; none when empty. + bool dashed = false; ///< Dashed and yellow, for a face to place by hand; else plain and white. + }; + + /// Sets the outlines drawn over the shapes; none removes them. + void setOutlines(const QVector& outlines); + + /// Returns the outlines drawn over the shapes. + QVector outlines() const { return _outlines; } + // Apply zoom to view void applyZoomToView(); @@ -220,6 +233,10 @@ class MapperGLCanvas: public QGraphicsView // Drawn under the shapes, over the content rectangle (see setBackgroundImage()). QImage _backgroundImage; + // Drawn over the shapes (see setOutlines()). + QVector _outlines; + void _drawOutlines(QPainter* painter); + // Drag in progress on a scale or rotation handle of the current shape. std::optional _handleDrag; // The mode when the handle drag started, which names the undo step. @@ -295,6 +312,14 @@ public slots: static constexpr int CONTENT_LABEL_FONT_SIZE = 11; static constexpr qreal CONTENT_LABEL_SPACING = 3; + // Outlines over the shapes (see setOutlines()), in screen pixels: a dark line under a light one, + // so that they show on any image. + static constexpr qreal OUTLINE_WIDTH = 1.5; + static constexpr qreal OUTLINE_SHADOW_WIDTH = 3.5; + static constexpr qreal OUTLINE_DASH = 4; + static constexpr qreal OUTLINE_LABEL_RADIUS = 9; + static constexpr int OUTLINE_LABEL_FONT_SIZE = 11; + // Space left at 100% zoom between the view and the handle of a shape that // covers all the content, in screen pixels. static constexpr qreal FIT_MARGIN_SPACING = 4; From 247f87171e2b9d5afdc0b8fc0a566f38e2f2386b Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Fri, 4 Dec 2026 02:10:58 -0500 Subject: [PATCH 05/10] Collect the new texts for the French translation --- translations/mapmap_fr.ts | 948 ++++++++++++++++++++++---------------- 1 file changed, 550 insertions(+), 398 deletions(-) diff --git a/translations/mapmap_fr.ts b/translations/mapmap_fr.ts index 3c42232a..f555e6f6 100644 --- a/translations/mapmap_fr.ts +++ b/translations/mapmap_fr.ts @@ -157,148 +157,163 @@ IsfShader - + The file %1 cannot be read. Le fichier %1 ne peut pas être lu. - + %1 does not start with an ISF header. %1 ne commence pas par un en-tête ISF. - + The ISF header of %1 is not closed. L'en-tête ISF de %1 n'est pas fermé. - + The ISF header of %1 is not a JSON object: %2. L'en-tête ISF de %1 n'est pas un objet JSON : %2. - + %1: the key %2 is ignored. %1 : la clé %2 est ignorée. - + %1 has %2 passes: MapMap reads shaders of one pass only. %1 a %2 passes : MapMap ne lit que les shaders à une seule passe. - + %1 draws its pass into an image: MapMap does not read such passes yet. %1 dessine sa passe dans une image : MapMap ne lit pas encore de telles passes. - + %1 keeps images from one frame to the next: MapMap does not read such shaders yet. %1 garde des images d'un rendu au suivant : MapMap ne lit pas encore de tels shaders. - + %1 imports images: MapMap does not read such shaders yet. %1 importe des images : MapMap ne lit pas encore de tels shaders. - + + %1: GROUPS is not a list: it is ignored. + + + + + %1: the key %2 of group %3 is ignored. + + + + + %1: group %2 of GROUPS names no group of the inputs: it is ignored. + + + + %1: input %2 has no valid NAME. %1 : l'entrée %2 n'a pas de NAME valide. - + %1: the image input %2 is refused: MapMap gives an effect one image, named %3. %1 : l'entrée d'image %2 est refusée : MapMap donne une seule image à un effet, nommée %3. - - + + %1: two inputs are named %2. %1 : deux entrées se nomment %2. - + %1: the name %2 is reserved. %1 : le nom %2 est réservé. - + %1: the key %2 of the input %3 is ignored. %1 : la clé %2 de l'entrée %3 est ignorée. - + %1: inputs of type %2 are not read by MapMap. %1 : MapMap ne lit pas les entrées de type %2. - + (none) (aucun) - + %1: the unit %2 of the input %3 is ignored. %1 : l'unité %2 de l'entrée %3 est ignorée. - + %1: generator %2 has no valid NAME. %1 : le générateur %2 n'a pas de NAME valide. - + %1: the generator %2 has the name of an input. %1 : le générateur %2 porte le nom d'une entrée. - + %1: generators of type %2 are not read: %3 stays at 0. %1 : les générateurs de type %2 ne sont pas lus : %3 reste à 0. - + %1: the generator %2 names an input that does not exist: %3. %1 : le générateur %2 nomme une entrée qui n'existe pas : %3. - + %1: the generator %2 gives its speed twice: %3 is ignored. %1 : le générateur %2 donne sa vitesse deux fois : %3 est ignoré. - + %1: the animator %2 has a shape MapMap does not draw, %3: it stays at 0. %1 : l'animateur %2 a une forme que MapMap ne dessine pas, %3 : il reste à 0. - + %1: the parameter %2 of the generator %3 is ignored. %1 : le paramètre %2 du générateur %3 est ignoré. - + %1: its #version line is ignored: MapMap compiles shaders in GLSL 1.20. %1 : sa ligne #version est ignorée : MapMap compile les shaders en GLSL 1.20. - + %1 is an effect that reads the time: MapMap does not animate effects yet. %1 est un effet qui lit le temps : MapMap n'anime pas encore les effets. - + %1 is an effect with GENERATORS: MapMap does not animate effects yet. %1 est un effet avec GENERATORS : MapMap n'anime pas encore les effets. - + %1 is an effect with the event input %2: MapMap does not animate effects yet. %1 est un effet avec l'entrée d'événement %2 : MapMap n'anime pas encore les effets. - + %1: the name %2 is reserved: names starting with %3 are MapMap's. %1 : le nom %2 est réservé : les noms qui commencent par %3 appartiennent à MapMap. @@ -370,87 +385,92 @@ Retirer le média - + Raise layer Monter le calque - + Lower layer Descendre le calque - + Raise layer to top Monter le calque tout en haut - + Lower layer to bottom Descendre le calque tout en bas - + Flip Horizontally Retourner horizontalement - + Flip Image Horizontally Retourner l’image horizontalement - + Flip Vertically Retourner verticalement - + Flip Image Vertically Retourner l’image verticalement - + Rotate 90° CW Pivoter de 90° dans le sens horaire - + Rotate Image 90° CW Pivoter l’image de 90° dans le sens horaire - + Rotate 90° CCW Pivoter de 90° dans le sens antihoraire - + Rotate Image 90° CCW Pivoter l’image de 90° dans le sens antihoraire - + Rotate 180° Pivoter de 180° - + Rotate Image 180° Pivoter l’image de 180° - + Change output resolution Changer la résolution de sortie - + + Move layer + + + + Add effect %1 Ajouter l'effet %1 - + Remove effect %1 Retirer l'effet %1 @@ -678,7 +698,7 @@ ShaderLibrary - + Shader refused: %1 Shader refusé : %1 @@ -1218,7 +1238,7 @@ 0 blends the colours smoothly; 100 % gives bands of plain colour with sharp edges. - 0 fond les couleurs en douceur; 100 % donne des bandes de couleur unie aux bords nets. + 0 fond les couleurs en douceur; 100 % donne des bandes de couleur unie aux bords nets. @@ -1278,7 +1298,7 @@ How one colour turns into the next: RGB in a straight line; Hue through the hues, the shorter way round the colour wheel; Rainbow the longer way round, all the hues when both colours have the same. A grey takes the hue of the other colour. - Comment une couleur devient la suivante : RVB en ligne droite; Teinte en passant par les teintes, par le plus court chemin sur la roue chromatique; Arc-en-ciel par le plus long, toutes les teintes quand les deux couleurs ont la même. Un gris prend la teinte de l'autre couleur. + Comment une couleur devient la suivante : RVB en ligne droite; Teinte en passant par les teintes, par le plus court chemin sur la roue chromatique; Arc-en-ciel par le plus long, toutes les teintes quand les deux couleurs ont la même. Un gris prend la teinte de l'autre couleur. @@ -1293,12 +1313,12 @@ How many repeats go by in a minute: at 6, the gradient moves by one repeat every 10 seconds; 0 keeps it still. - Le nombre de répétitions qui défilent en une minute : à 6, le dégradé avance d'une répétition toutes les 10 secondes; 0 le garde immobile. + Le nombre de répétitions qui défilent en une minute : à 6, le dégradé avance d'une répétition toutes les 10 secondes; 0 le garde immobile. The gradient moves the other way: towards the centre, or anticlockwise. - Le dégradé défile dans l'autre sens : vers le centre, ou dans le sens inverse des aiguilles d'une montre. + Le dégradé défile dans l'autre sens : vers le centre, ou dans le sens inverse des aiguilles d'une montre. @@ -1458,7 +1478,7 @@ Noise that moves slowly: smooth clouds, cells or a plasma, between two colours. - Un bruit qui bouge lentement : des nuages doux, des cellules ou un plasma, entre deux couleurs. + Un bruit qui bouge lentement : des nuages doux, des cellules ou un plasma, entre deux couleurs. @@ -1513,7 +1533,7 @@ Changes the pattern: each number gives another one, always the same. - Change le motif : chaque nombre en donne un autre, toujours le même. + Change le motif : chaque nombre en donne un autre, toujours le même. @@ -1528,7 +1548,7 @@ How many times a minute the noise goes through its motion and comes back to where it started: at 6, every 10 seconds; 0 keeps it still. - Le nombre de fois par minute que le bruit fait son mouvement et revient à son point de départ : à 6, toutes les 10 secondes; 0 le garde immobile. + Le nombre de fois par minute que le bruit fait son mouvement et revient à son point de départ : à 6, toutes les 10 secondes; 0 le garde immobile. @@ -1598,7 +1618,7 @@ The direction across the stripes, clockwise from left to right: at 0°, the stripes stand upright. - La direction en travers des rayures, dans le sens des aiguilles d'une montre depuis la gauche vers la droite : à 0°, les rayures sont verticales. + La direction en travers des rayures, dans le sens des aiguilles d'une montre depuis la gauche vers la droite : à 0°, les rayures sont verticales. @@ -1613,7 +1633,7 @@ How wide the blend between two stripes is, in pixels of the image: 0 gives sharp edges. - La largeur du fondu entre deux rayures, en pixels de l'image : 0 donne des bords nets. + La largeur du fondu entre deux rayures, en pixels de l'image : 0 donne des bords nets. @@ -1628,7 +1648,7 @@ How many pairs of stripes go by in a minute: at 6, the stripes move by one pair every 10 seconds; 0 keeps them still. - Le nombre de paires de rayures qui défilent en une minute : à 6, les rayures avancent d'une paire toutes les 10 secondes; 0 les garde immobiles. + Le nombre de paires de rayures qui défilent en une minute : à 6, les rayures avancent d'une paire toutes les 10 secondes; 0 les garde immobiles. @@ -1738,7 +1758,7 @@ 0 gives soft waves, a sine; 100 % gives bands of plain colour with sharp edges. - 0 donne des ondes douces, une sinusoïde; 100 % donne des bandes de couleur unie aux bords nets. + 0 donne des ondes douces, une sinusoïde; 100 % donne des bandes de couleur unie aux bords nets. @@ -1753,12 +1773,12 @@ How many waves go by in a minute: at 6, the waves move by one wave every 10 seconds; 0 keeps them still. - Le nombre d'ondes qui passent en une minute : à 6, les ondes avancent d'une onde toutes les 10 secondes; 0 les garde immobiles. + Le nombre d'ondes qui passent en une minute : à 6, les ondes avancent d'une onde toutes les 10 secondes; 0 les garde immobiles. The waves go the other way: rings come towards the centre. - Les ondes vont dans l'autre sens : les anneaux viennent vers le centre. + Les ondes vont dans l'autre sens : les anneaux viennent vers le centre. @@ -1883,84 +1903,196 @@ mmp::AutoMappingDialog - + Auto-Mapping Calage automatique - + Simulated scene (--auto-mapping-simulation) Scène simulée (--auto-mapping-simulation) - + %1 - %2 × %3 %1 - %2 × %3 - + Place the camera next to the projector, so that it sees everything the projector lights. Nobody in the picture, and darken the room. After the scan, do not touch the zoom, the focus or the framing of the projector: the image would no longer match. Placez la caméra à côté du projecteur, pour qu'elle voie tout ce qu'il éclaire. Personne dans le champ, et la salle assombrie. Après le relevé, ne touchez plus au zoom, à la mise au point ni au cadrage du projecteur : l'image ne correspondrait plus. - + Skip the finest stripes (faster, for a blurry camera, but less precise) Sauter les rayures les plus fines (plus rapide, pour une caméra floue, mais moins précis) - + Start Lancer - + + + Create Shapes + + + + + + Make a layer of each face found, with a colour of its own + + + + Camera: Caméra : - + Projector screen: Écran du projecteur : - + No camera is connected. Aucune caméra n'est branchée. - + %1 images, about %2 seconds. %1 images, environ %2 secondes. - + The scan needs the output over the whole screen of the projector. Le relevé a besoin de la sortie sur tout l'écran du projecteur. - + Scanning: do not move. Relevé en cours : ne bougez pas. - + Scan cancelled. Relevé annulé. - + + Done: %1, %2. The camera saw %3 % of the output: the scene seen from the projector is under the shapes of the output editor; in red, what the camera did not see. Tools > Show Auto-Mapping Image hides it with the outlines. + + + + + %n face(s) found + + + + + + + + + %n outline(s) to place by hand + + + + + + + + + Update Shapes + + + + + Move the layers of the previous scan onto their faces, and make a layer of each new face + + + + + %n layer(s) of the previous scan will follow their face: they keep their source and their effects, only their corners move. + + + + + + + + %n new face(s) will be added. + + + + + + + + %n layer(s) of the previous scan were not found again: %1. + + + + + + + + Update and Remove Them + + + + + Update and Keep Them + + + + + Update + + + + + %n layer(s) moved + + + + + + + + %n shape(s) created + + + + + + + + %n layer(s) removed + + + + + + + + %1. Edit > Undo takes it all back at once. + + + Done: the camera saw %1 % of the output. The scene seen from the projector is under the shapes of the output editor; in red, what the camera did not see. Tools > Show Auto-Mapping Image hides it, Tools > Clear Auto-Mapping Image forgets it. - Terminé : la caméra a vu %1 % de la sortie. La scène vue depuis le projecteur est sous les formes de l'éditeur de sortie ; en rouge, ce que la caméra n'a pas vu. Outils > Montrer l'image du calage la masque, Outils > Effacer l'image du calage l'oublie. + Terminé : la caméra a vu %1 % de la sortie. La scène vue depuis le projecteur est sous les formes de l'éditeur de sortie ; en rouge, ce que la caméra n'a pas vu. Outils > Montrer l'image du calage la masque, Outils > Effacer l'image du calage l'oublie. - + Cancel Annuler - + Close Fermer @@ -2249,15 +2381,25 @@ Après le relevé, ne touchez plus au zoom, à la mise au point ni au cadrage du mmp::Effect - + Enabled Activé - + Whether this effect changes the image; off, the image passes unchanged. Quand il est activé, cet effet modifie l'image; désactivé, il laisse passer l'image inchangée. + + + Mix + + + + + How much of the effect shows: at 0 % the image is unchanged, at 100 % only the effect shows. + + mmp::EffectInspector @@ -2361,27 +2503,27 @@ Après le relevé, ne touchez plus au zoom, à la mise au point ni au cadrage du mmp::Image - + Image file Fichier image - + Image files (%1);;All files (*) Fichiers image (%1);;Tous les fichiers (*) - + The image file shown by this source. Le fichier image affiché par cette source. - + Speed Vitesse - + How fast an animated image plays; a negative speed plays it backwards. La vitesse de lecture d'une image animée; une vitesse négative la lit à l'envers. @@ -2389,9 +2531,8 @@ Après le relevé, ne touchez plus au zoom, à la mise au point ni au cadrage du mmp::Inspector - Type in project files: %1 - Type dans les fichiers de projet : %1 + Type dans les fichiers de projet : %1 @@ -2546,7 +2687,7 @@ Après le relevé, ne touchez plus au zoom, à la mise au point ni au cadrage du Quadrilatère - + Used by %1 layers: changing it changes them all. Utilisée par %1 calques : la modifier les modifie tous. @@ -2698,1193 +2839,1204 @@ Après le relevé, ne touchez plus au zoom, à la mise au point ni au cadrage du mmp::MainWindow - - + + Open project Ouvrir un projet - - - - + + + + MapMap files (*.%1) Fichiers MapMap (*.%1) - - + + Save project Sauvegarder le projet - - + + Import media source file Importer un média - - + + Media files (%1 %2);;All files (*) Fichiers média (%1-%2);;Tous les fichiers (*) - + Select camera Selectionner une caméra - - + + No camera available Aucune caméra disponible - - + + You can not use this feature! No camera available in your system Vous ne pouvez pas utiliser cette fonctionnalité. Aucune caméra n'est disponible sur ce système. - - - + + + MapMap MapMap - + Cues Repères - + &New &Nouveau - + Create a new project Créer un nouveau projet - + &Open… &Ouvrir… - + Open an existing project Ouvrir un projet existant - + &Save &Sauvegarder - + Save the project Sauvegarder le projet - + Save &As… S&auvegarder sous… - + Save the project as… Sauvegarder le projet sous… - + No Recents Videos Pas de vidéos récentes - + &Import Media File… &Importer un fichier média … - + Import a video or image file… Importer un fichier vidéo ou image … - + Open &Camera Device… Ajouter une source &caméra… - + Choose your camera device… Choisir la caméra… - + E&xit &Quitter - + Exit the application Quitter l'application - + &Undo Ann&uler - + &Redo &Retablir - + &About MapMap &A propos de MapMap - + Show the application's About box Afficher le dialogue "À propos de l'application" - + &Preferences… &Préférences… - + Configure preferences… Configurer les préférences… - - + + Play Lecture - - + + Pause Pause - + &Display Controls &Afficher les points de contrôle - + Display canvas controls Afficher les points de contrôle du canevas - + &Sticky Vertices &Sommets collants - + Enable sticky vertices Activer les sommets collants - + Show &Test Signal Afficher le signal de &Test - + Show Test signal Afficher le signal de Test - + Display &Undo History &Afficher l'historique des opérations - + Open Conso&le Ouvrir la conso&le - + &Auto-Mapping… &Calage automatique… - + Film stripes projected on the scene, to see it from the projector Filmer des rayures projetées sur la scène, pour la voir depuis le projecteur - + &Show Auto-Mapping Image &Montrer l'image du calage - + Show the scene seen from the projector under the shapes of the output Montrer la scène vue depuis le projecteur sous les formes de la sortie - + &Clear Auto-Mapping Image &Effacer l'image du calage - + Forget the scene seen from the projector Oublier la scène vue depuis le projecteur - + Display &Zoom Toolbar Afficher la barre de contrôle du &Zoom - + &Menu Bar Barre de &Menu - + Main Layout Vue normale - + Switch to the Main layout. Passer à la vue normale. - + Editor Éditeur - + Show the editor and hide the bottom section Montrer l'éditeur et cacher la section du bas - + Bottom Section Section du bas - + Show the bottom section, such as the cues, and hide the editor Montrer la section du bas, comme les repères, et cacher l'éditeur - + Editor and Bottom Section Éditeur et section du bas - + Show the editor, and the bottom section under it Montrer l'éditeur, et la section du bas en dessous - + Documentation Documentation - + &File &Fichier - + Open Recents Projects Ouvrir les projets récents - + Open Recents Videos Ouvrir les vidéo récentes - + &Edit &Édition - + &Tools &Outils - + &Window &Fenêtre - + &Help &Aide - + &Toolbar &Barre de menu - + The document has been modified. Do you want to save your changes? Ce document a été modifié. Voulez-vous sauvegarder vos changements? - - + + Error reading mapping project file Erreur de lecture du projet - - + + Cannot read file %1: %2. Impossible de lire le fichier %1: %2. - + File loaded Fichier chargé - - + + Error saving mapping project Erreur en sauvegardant le fichier du projet - + Cannot write file %1: %2. Impossible d'écrire le fichier %1 : %2. - + Cannot rename temporary file to %1. Impossible de renommer le fichier temporaire en %1. - + File saved Fichier sauvegardé - + Untitled Sans titre - + %1[*] - %2 %1[*] - %2 - - + + MapMap Project Projet MapMap - - - + + + &%1 %2 &%1 %2 - + Clear List Vider la liste - + No Recents Projects Aucun projet récent - + + + Face %1 + + + + + Auto-Mapping + Calage automatique + + + %1 - %2x%3 %1 - %2x%3 - + File imported Fichier importé - + Warning Avertissement - + The following file is not supported: %1 Le fichier suivant n'est pas supporté: %1 - + Cannot load movie Impossible de charger le film - - + + %1 files (%2) Fichiers %1 (%2) - + Undo history Historique - + Camera device Dispositif caméra - + Report an issue Rapporter un problème - + Submit feedback via email Soumettre une remarque par courriel - + &View &Apparence - + Unable to use file %1. The original file is not found. Please locate. Impossible d'utiliser le fichier %1. Le fichier original est introuvable. Prière de le localiser. - - + + Locate file %1 Localiser le fichier %1 - + - Primary - Principal - + Used by %1 layers: changing it changes them all. Utilisé par %1 calques : le modifier les modifie tous. - + Replace effect Remplacer l'effet - - + + Replace Effect Remplacer l'effet - - - + + + Add Effect Ajouter un effet - + Save over a project of a later version? Écraser un projet d'une version plus récente? - + %1 was saved by a later version of MapMap, in the format %2. This version keeps what it does not know, but the later version may not open the project as it was. Save over it anyway? %1 a été sauvegardé par une version plus récente de MapMap, au format %2. Cette version garde ce qu'elle ne connaît pas, mais la version plus récente pourrait ne pas ouvrir le projet tel qu'il était. L'écraser quand même? - + Learning MIDI for %1: press a pad for "%2", or turn a knob to move it both ways. Escape stops, Delete removes the MIDI controls of the point. Apprentissage MIDI pour %1 : appuyez sur un pad pour « %2 », ou tournez un bouton pour le déplacer dans les deux sens. Échap arrête, Suppr retire les contrôles MIDI du point. - + Learning keys for %1: press a key for "%2". Escape stops, Delete removes the keys of the point. Apprentissage des touches pour %1 : appuyez sur une touche pour « %2 ». Échap arrête, Suppr retire les touches du point. - + Learning MIDI: move a control or press a pad for %1. Delete removes its MIDI control. Apprentissage MIDI : bougez un contrôle ou appuyez sur un pad pour %1. Suppr retire son contrôle MIDI. - + Learning MIDI: click a control outlined in blue, then move a control of the MIDI device. The MIDI controls already learned act. Apprentissage MIDI : cliquez sur un contrôle entouré de bleu, puis bougez un contrôle de l'appareil MIDI. Les contrôles MIDI déjà appris agissent. - + Learning keys: press a key for %1. Delete removes its key. Apprentissage des touches : appuyez sur une touche pour %1. Suppr retire sa touche. - + Learning keys: click a control outlined in blue, then press a key. Learned keys do not act until learning stops (Escape). Apprentissage des touches : cliquez sur un contrôle entouré de bleu, puis appuyez sur une touche. Les touches apprises n'agissent qu'à la fin de l'apprentissage (Échap). - - + + %1: %2 %1 : %2 - + Move a MIDI control for %1. Delete removes its MIDI control, Escape stops learning. Bougez un contrôle MIDI pour %1. Suppr retire son contrôle MIDI, Échap arrête l'apprentissage. - + MIDI learn: click a control outlined in blue, then move a control of the MIDI device. Escape stops learning. Apprentissage MIDI : cliquez sur un contrôle entouré de bleu, puis bougez un contrôle de l'appareil MIDI. Échap arrête l'apprentissage. - + Press a key for %1. Delete removes its key, Escape stops learning. Appuyez sur une touche pour %1. Suppr retire sa touche, Échap arrête l'apprentissage. - + Keyboard learn: click a control outlined in blue, then press a key. Escape stops learning. Apprentissage clavier : cliquez sur un contrôle entouré de bleu, puis appuyez sur une touche. Échap arrête l'apprentissage. - + Learning MIDI: move a control of the MIDI device, not a key. Edit > Keyboard Learn learns keys. Apprentissage MIDI : bougez un contrôle de l'appareil MIDI, pas une touche. Édition > Apprentissage clavier apprend les touches. - + %1 drives %2. Press Escape to stop learning: %1 then acts. %1 commande %2. Appuyez sur Échap pour arrêter l'apprentissage : %1 agira alors. - + Click a control outlined in blue first, then press %1. Cliquez d'abord sur un contrôle entouré de bleu, puis appuyez sur %1. - + %1 is already the shortcut of %2: choose another key. %1 sert déjà (%2) : choisissez une autre touche. - - + + %1 → %2 %1 → %2 - + %1 → %2: %3 %1 → %2 : %3 - + MIDI control removed from %1 Contrôle MIDI retiré de %1 - + Key removed from %1 Touche retirée de %1 - + Click a control outlined in blue first, then move %1. Cliquez d'abord sur un contrôle entouré de bleu, puis bougez %1. - + Input Editor: %1% Éditeur d'entrée : %1 % - + Output Editor: %1% Éditeur de sortie : %1 % - + Stop Learning Arrêter l'apprentissage - + Stop learning (Escape) Arrêter l'apprentissage (Échap) - - + + Add &Generator Ajouter un &générateur - + Add a generator Ajouter un générateur - + Remove Effect Retirer l'effet - + Remove the selected effect Retirer l'effet sélectionné - + Solo layer item Calque en solo - + Rotate 90° CW Pivoter de 90° dans le sens horaire - + Rotate 90° clockwise. In the input view, rotates the image inside the layer. Pivoter de 90° dans le sens horaire. Dans la vue d’entrée, fait pivoter l’image à l’intérieur du calque. - + Rotate 90° CCW Pivoter de 90° dans le sens antihoraire - + Rotate 90° counterclockwise. In the input view, rotates the image inside the layer. Pivoter de 90° dans le sens antihoraire. Dans la vue d’entrée, fait pivoter l’image à l’intérieur du calque. - + Rotate 180° Pivoter de 180° - + Rotate 180°. In the input view, rotates the image inside the layer. Pivoter de 180°. Dans la vue d’entrée, fait pivoter l’image à l’intérieur du calque. - + Flip horizontally. In the input view, flips the image inside the layer. Retourner horizontalement. Dans la vue d’entrée, retourne l’image à l’intérieur du calque. - + Flip vertically. In the input view, flips the image inside the layer. Retourner verticalement. Dans la vue d’entrée, retourne l’image à l’intérieur du calque. - - + + Raise Monter - - + + Lower Descendre - + Raise to Top Monter tout en haut - + Raise to top Monter tout en haut - + Lower to Bottom Descendre tout en bas - + Lower to bottom Descendre tout en bas - + &Keyboard Learn Apprentissage &clavier - + Link keys of the keyboard to settings: click a control, then press a key Lier des touches du clavier à des réglages : cliquez sur un contrôle, puis appuyez sur une touche - + &MIDI Learn Apprentissage &MIDI - + Link controls and notes of a MIDI device to settings: click a control, then move a MIDI control Lier des contrôles et des notes d'un appareil MIDI à des réglages : cliquez sur un contrôle, puis bougez un contrôle MIDI - + Learned K&eys Active &Touches apprises actives - + Turn the learned keys off while typing for something else, and on again Désactiver les touches apprises le temps de taper autre chose, puis les réactiver - + &Publish Syphon Output &Publier la sortie Syphon - + Publish the output composition as a Syphon server other apps can receive Publier la composition de sortie comme un serveur Syphon que d'autres applications peuvent recevoir - + &Links Lie&ns - + List the keys linked to settings Lister les touches liées aux réglages - - + + Zoom In Agrandir - - + + Zoom Out Réduire - + Remove this source and all its associated layers? Supprimer cette source et tous les calques associés ? - + Syphon source added Source Syphon ajoutée - + Input Editor Éditeur d'entrée - + Output Editor Éditeur de sortie - + Library Bibliothèque - + Layers Calques - + Add &Syphon Source… Ajouter une source &Syphon… - + Receive live video from another application via Syphon… Recevoir de la vidéo en direct d'une autre application via Syphon… - + Duplicate Layer Dupliquer le calque - + Duplicate layer item Dupliquer un élément du calque - + Delete Layer Supprimer le calque - + Delete layer item Supprimer un élément du calque - + Rename Layer Renommer le calque - + Rename layer item Renommer un élément du calque - + Lock Layer Vérouiller le calque - + Lock layer item Vérouiller un élément du calque - + Hide Layer Cacher le calque - + Hide layer item Cacher un élément du calque - + Solo Layer Calque solo - + Delete Source Supprimer la source - + Delete source item Supprimer un élément de la source - + Rename Source Renommer la source - + Rename source item Renommer un élément de la source - + Add &Mesh Layer Ajouter un calque &maillage - + Add mesh layer Ajouter un calque de maillage - + Add &Triangle Layer Ajouter un calque &triangle - + Add triangle layer Ajouter un calque triangulaire - + Add &Ellipse Layer Ajouter un calque &ellipse - + Add ellipse layer Ajouter un calque elliptique - + &Display Controls of Layers of a Source Commandes d'&affichage des calques d'une source - + Display all canvas controls related to current source Afficher tous les contrôles de la toile liés à la source actuelle - + Input editor Layout Vue de l'éditeur d'entrée - + Switch to the Input editor Layout. Passer à la vue de l'éditeur d'entrée. - + Output Editor Layout Vue de l'éditeur de sortie - + Switch to the Output Editors Layout. Passer à la vue de l'éditeur de sortie. - + Import New Media Importer un nouveau média - + Import new media file if not exists on the list Importer un nouveau média si le fichier n'existe pas sur la liste - - + + Restart Redémarrer - + Actual Pixels (1:1) Taille réelle (1:1) - + Show one image pixel per screen pixel Afficher un pixel de l'image par pixel de l'écran - + Fit To View (100%) Ajuster à la vue (100 %) - + Show the whole image or output frame Afficher toute l'image ou tout le cadre de sortie - + Output &Resolution... &Résolution de sortie... - + Choose the size of the output frame Choisir la taille du cadre de sortie - + Professional services && custom development… Services professionnels && développement sur mesure… - + Hire Art Plus Code for video mapping installations, custom features, integration and training Engagez Art Plus Code pour des installations de mapping vidéo, des fonctionnalités sur mesure, de l'intégration et de la formation - + Support the project (donate)… Soutenir le projet (faire un don)… - + Help fund MapMap's ongoing development Aidez à financer le développement continu de MapMap - + &Keyboard shortcuts &Raccourcis clavier - + Welcome to %1… Bienvenue dans %1… - + Change Layer Source Changer la source du calque - + Flip Horizontally Retourner horizontalement - + Flip Vertically Retourner verticalement - + The output screen %1 is disconnected: the output is hidden until it comes back. L'écran de sortie %1 est débranché : la sortie est cachée jusqu'à son retour. - + The output screen %1 is back. L'écran de sortie %1 est revenu. - + &Hide Output &Cacher la sortie - + Output in a &Window Sortie dans une &fenêtre - + Output &Fills a Screen La sortie &couvre un écran - + Output Sortie - + Output Fills a Screen (%1). The arrow chooses how and where the output is shown. La sortie couvre un écran (%1). La flèche choisit comment et où montrer la sortie. - + The learned keys act again. Les touches apprises agissent de nouveau. - + The learned keys are off: they do nothing until turned on again. Les touches apprises sont désactivées : elles ne font rien jusqu'à ce qu'on les réactive. - + Learned keys: on Touches apprises : actives - + Learned keys: off Touches apprises : inactives - + Edit > Learned Keys Active (%1) turns them on and off. Édition > Touches apprises actives (%1) les active et les désactive. - + Cannot read %1: %2 Impossible de lire %1 : %2 - + Project of a later version Projet d'une version plus récente - + This project was saved by a later version of MapMap, in the format %1; this version writes %2. What this version does not know is kept, but may not work as the later version intended. Ce projet a été sauvegardé par une version plus récente de MapMap, au format %1; cette version écrit %2. Ce que cette version ne connaît pas est conservé, mais pourrait ne pas fonctionner comme la version plus récente le prévoyait. - + Project opened with missing entries Projet ouvert avec des entrées manquantes - + MapMap skipped these project entries: %1 MapMap a ignoré ces entrées du projet : %1 - + Sources this version cannot open Sources que cette version ne peut pas ouvrir - + This project has sources of types this version of MapMap cannot open: %1. They are kept with their layers, which show a "missing" image, and saved as they are. Ce projet a des sources de types que cette version de MapMap ne peut pas ouvrir : %1. Elles sont conservées avec leurs calques, qui affichent une image « manquante », et sauvegardées telles quelles. - - + + File loaded: %n link(s) active Fichier chargé : %n lien actif @@ -3892,7 +4044,7 @@ Elles sont conservées avec leurs calques, qui affichent une image « manqu - + , %n kept but not usable here , %n conservé mais inutilisable ici @@ -3900,82 +4052,82 @@ Elles sont conservées avec leurs calques, qui affichent une image « manqu - + %1 added Source ajoutée : %1 - + Output %1 × %2 Sortie %1 × %2 - + Output Editor (%1 × %2) Éditeur de sortie (%1 × %2) - + Output Resolution Résolution de sortie - + Size of the output frame, usually the resolution of the projector. The output window scales it to fill the output screen. Taille du cadre de sortie, en général la résolution du projecteur. La fenêtre de sortie le met à l'échelle pour remplir l'écran de sortie. - + Scale the shapes to keep them in place in the frame Mettre les formes à l'échelle pour les garder en place dans le cadre - + %1 %2 × %3 %1 %2 × %3 - + %1 - disconnected %1 - débranché - + Output Fills a Screen La sortie couvre un écran - + The output will cover this screen. Press Esc to bring MapMap back. La sortie va couvrir cet écran. Appuyez sur Échap pour faire revenir MapMap. - + Cover the Screen Couvrir l'écran - + Don't ask again Ne plus demander - + &Output &Sortie - + Cue %1 Repère %1 - + Cue %1 — %2 Repère %1 — %2 - + %1 set at %2 %1 posé à %2 @@ -4586,22 +4738,22 @@ Elles sont conservées avec leurs calques, qui affichent une image « manqu mmp::Texture - + X X - + The horizontal position of the top-left corner of the texture. La position horizontale du coin supérieur gauche de la texture. - + Y Y - + The vertical position of the top-left corner of the texture. La position verticale du coin supérieur gauche de la texture. @@ -4609,142 +4761,142 @@ Elles sont conservées avec leurs calques, qui affichent une image « manqu mmp::Video - + Source Source - + Video files (%1);;All files (*) Fichiers vidéo (%1);;Tous les fichiers (*) - + The video file, or the camera, shown by this source. Le fichier vidéo, ou la caméra, affiché par cette source. - + Speed Vitesse - + How fast the video plays; at zero the image stops. A negative speed stops it too for now: the video cannot play backwards yet. La vitesse de lecture de la vidéo; à zéro, l'image s'arrête. Une vitesse négative l'arrête aussi pour l'instant : la vidéo ne peut pas encore être lue à l'envers. - + Volume Volume - + How loud the sound of the video plays. Le volume du son de la vidéo. - + Mute Sourdine - + Silences the sound of the video; its volume comes back when the sound does. Coupe le son de la vidéo; son volume revient quand le son revient. - + Play Lecture - + Plays this video, or pauses it alone while the others play. Lit cette vidéo, ou la met en pause seule pendant que les autres jouent. - + Position Position - + The moment of the video being played; writing it moves there. Le moment de la vidéo en cours de lecture; le modifier y déplace la lecture. - + Duration Durée - + How long the video lasts. La durée de la vidéo. - + Cue %1 Repère %1 - + Colour Couleur - + The colour of the cue. La couleur du repère. - + Name Nom - + The name of the cue, shown when it is reached. Le nom du repère, affiché quand on y saute. - + Time Moment - + The moment of the video where the cue is; empty while it is not placed. Le moment de la vidéo où se trouve le repère ; vide tant qu'il n'est pas posé. - + Go Aller - + Jumps to the cue and plays from there; places it where the video plays when it is empty. Saute au repère et lance la lecture depuis là ; s'il est vide, le pose à l'endroit en cours de lecture. - + Set Poser - + Places or moves the cue where the video plays. Pose ou déplace le repère à l'endroit en cours de lecture. - + Clear Effacer - + Removes the cue. Efface le repère. From e12dfeee39f7c5210b44a06570fbfdf56d1ab602 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Fri, 4 Dec 2026 02:11:48 -0500 Subject: [PATCH 06/10] Translate the faces of the automatic mapping into French --- translations/mapmap_fr.ts | 72 +++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/translations/mapmap_fr.ts b/translations/mapmap_fr.ts index f555e6f6..567739c4 100644 --- a/translations/mapmap_fr.ts +++ b/translations/mapmap_fr.ts @@ -462,7 +462,7 @@ Move layer - + Déplacer le calque @@ -1938,13 +1938,13 @@ Après le relevé, ne touchez plus au zoom, à la mise au point ni au cadrage du Create Shapes - + Créer les formes Make a layer of each face found, with a colour of its own - + Faire un calque de chaque face trouvée, chacun de sa couleur @@ -1984,103 +1984,103 @@ Après le relevé, ne touchez plus au zoom, à la mise au point ni au cadrage du Done: %1, %2. The camera saw %3 % of the output: the scene seen from the projector is under the shapes of the output editor; in red, what the camera did not see. Tools > Show Auto-Mapping Image hides it with the outlines. - + Terminé : %1, %2. La caméra a vu %3 % de la sortie : la scène vue depuis le projecteur est sous les formes de l'éditeur de sortie ; en rouge, ce que la caméra n'a pas vu. Outils > Montrer l'image du calage la masque, avec les contours. %n face(s) found - - - + + %n face trouvée + %n faces trouvées %n outline(s) to place by hand - - - + + %n contour à caler à la main + %n contours à caler à la main Update Shapes - + Mettre à jour les formes Move the layers of the previous scan onto their faces, and make a layer of each new face - + Replacer les calques du relevé précédent sur leurs faces, et faire un calque de chaque nouvelle face %n layer(s) of the previous scan will follow their face: they keep their source and their effects, only their corners move. - - - + + %n calque du relevé précédent suivra sa face : il garde sa source et ses effets, seuls ses coins bougent. + %n calques du relevé précédent suivront leur face : ils gardent leur source et leurs effets, seuls leurs coins bougent. %n new face(s) will be added. - - - + + %n nouvelle face sera ajoutée. + %n nouvelles faces seront ajoutées. %n layer(s) of the previous scan were not found again: %1. - - - + + %n calque du relevé précédent n'a pas été retrouvé : %1. + %n calques du relevé précédent n'ont pas été retrouvés : %1. Update and Remove Them - + Mettre à jour et les supprimer Update and Keep Them - + Mettre à jour et les garder Update - + Mettre à jour %n layer(s) moved - - - + + %n calque déplacé + %n calques déplacés %n shape(s) created - - - + + %n forme créée + %n formes créées %n layer(s) removed - - - + + %n calque supprimé + %n calques supprimés %1. Edit > Undo takes it all back at once. - + %1. Édition > Annuler défait tout d'un coup. Done: the camera saw %1 % of the output. The scene seen from the projector is under the shapes of the output editor; in red, what the camera did not see. Tools > Show Auto-Mapping Image hides it, Tools > Clear Auto-Mapping Image forgets it. @@ -3269,12 +3269,12 @@ Voulez-vous sauvegarder vos changements? Face %1 - + Face %1 Auto-Mapping - Calage automatique + Calage automatique From 05ab513993e5282756dadddef50b6269f9d6b6f6 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Fri, 4 Dec 2026 11:56:03 -0500 Subject: [PATCH 07/10] Give a layer put back by Undo or Redo its place in the depths 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. --- src/core/Commands.cpp | 6 +++--- src/core/MappingManager.cpp | 8 ++++++++ src/core/MappingManager.h | 3 +++ tests/TestMappingManager.cpp | 20 ++++++++++++++++++++ tests/TestMappingManager.h | 1 + 5 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/core/Commands.cpp b/src/core/Commands.cpp index 80cf1501..548bb1df 100644 --- a/src/core/Commands.cpp +++ b/src/core/Commands.cpp @@ -75,7 +75,7 @@ void AddLayerCommand::redo() { if (!_layer.isNull()) { - uid storedId = _mainWindow->getMappingManager().addLayer(_layer); + uid storedId = _mainWindow->getMappingManager().putLayerBack(_layer); _mainWindow->addLayerItem(storedId); } else @@ -282,7 +282,7 @@ void RemoveSourceCommand::undo() QMap sourceLayers = manager.getSourceLayers(_source); for (QMap::const_iterator it = _sourceLayers.constBegin(); it != _sourceLayers.constEnd(); ++it) { - uid mid = manager.addLayer( it.value() ); + uid mid = manager.putLayerBack( it.value() ); Q_ASSERT( mid == it.key() ); _mainWindow->addLayerItem(mid); } @@ -312,7 +312,7 @@ void DeleteLayerCommand::undo() { if (!_layer.isNull()) { - uid storedId = _mainWindow->getMappingManager().addLayer(_layer); + uid storedId = _mainWindow->getMappingManager().putLayerBack(_layer); _mainWindow->addLayerItem(storedId); } } diff --git a/src/core/MappingManager.cpp b/src/core/MappingManager.cpp index d501bd39..aa09b448 100644 --- a/src/core/MappingManager.cpp +++ b/src/core/MappingManager.cpp @@ -185,6 +185,14 @@ uid MappingManager::addLayer(Layer::ptr layer) return layer->getId(); } +uid MappingManager::putLayerBack(Layer::ptr layer) +{ + const uid id = addLayer(layer); + // The depths changed when it was taken away: its own is out of date. + updateLayerDepths(); + return id; +} + bool MappingManager::removeLayer(uid mappingId) { // Make sure the source to which this mapping refers to exists in the manager. diff --git a/src/core/MappingManager.h b/src/core/MappingManager.h index 24bc01d4..71d94b24 100644 --- a/src/core/MappingManager.h +++ b/src/core/MappingManager.h @@ -194,6 +194,9 @@ class MappingManager : public QObject /// Adds a mapping and returns its uid. uid addLayer(Layer::ptr mapping); + /// Adds again a layer taken away (by Undo or Redo), with the depths of all layers updated, and returns its uid. + uid putLayerBack(Layer::ptr layer); + /// Removes a mapping of given uid. bool removeLayer(uid mappingId); diff --git a/tests/TestMappingManager.cpp b/tests/TestMappingManager.cpp index 83e9e55a..3a217e73 100644 --- a/tests/TestMappingManager.cpp +++ b/tests/TestMappingManager.cpp @@ -177,6 +177,26 @@ void TestMappingManager::removeLayer() QVERIFY(!manager.removeLayer(layer->getId())); } +void TestMappingManager::layerPutBackHasItsDepth() +{ + MappingManager manager; + Source::ptr red = makeColor("red"); + manager.addSource(red); + Layer::ptr wall = makeColorLayer(red, "wall"); + Layer::ptr floor = makeColorLayer(red, "floor"); + Layer::ptr ceiling = makeColorLayer(red, "ceiling"); + manager.addLayer(wall); + manager.addLayer(floor); + manager.addLayer(ceiling); + + // As Undo then Redo of "Add layer" do. + manager.removeLayer(floor->getId()); + manager.putLayerBack(floor); + + for (int i = 0; i < manager.nLayers(); i++) + QCOMPARE(manager.getLayer(i)->getDepth(), i); +} + void TestMappingManager::removeSourceRemovesItsLayers() { MappingManager manager; diff --git a/tests/TestMappingManager.h b/tests/TestMappingManager.h index 0b91d01b..88588616 100644 --- a/tests/TestMappingManager.h +++ b/tests/TestMappingManager.h @@ -28,6 +28,7 @@ private slots: void reorderIsAtomic(); void findByNamePattern(); void removeLayer(); + void layerPutBackHasItsDepth(); void removeSourceRemovesItsLayers(); void unknownIdsReturnNull(); void clearAll(); From 115d7a4e5f4984b4db39e468aac17fb8e6b1ea83 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Fri, 4 Dec 2026 12:12:18 -0500 Subject: [PATCH 08/10] Grey the text of a button that does nothing 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. --- resources/qss/mapmap.qss | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/resources/qss/mapmap.qss b/resources/qss/mapmap.qss index 2ada41c6..4e540b4f 100644 --- a/resources/qss/mapmap.qss +++ b/resources/qss/mapmap.qss @@ -40,6 +40,12 @@ QPushButton::checked { background-color: #272a36; } +/* After the hover: a button that does nothing does not react to the mouse either. */ +QPushButton:disabled { + color: #4C4F5B; + background-color: #323541; +} + QToolTip { padding: 1px 2px; border-radius: 2px; From 1b6a6b519210c6aee759bb784239b4ac283e6bf7 Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Fri, 4 Dec 2026 12:19:45 -0500 Subject: [PATCH 09/10] Collect the new texts for the English translation --- translations/mapmap_en.ts | 1023 ++++++++++++++++++++++++------------- 1 file changed, 663 insertions(+), 360 deletions(-) diff --git a/translations/mapmap_en.ts b/translations/mapmap_en.ts index bcdcd690..705cef97 100644 --- a/translations/mapmap_en.ts +++ b/translations/mapmap_en.ts @@ -157,148 +157,163 @@ IsfShader - + The file %1 cannot be read. The file %1 cannot be read. - + %1 does not start with an ISF header. %1 does not start with an ISF header. - + The ISF header of %1 is not closed. The ISF header of %1 is not closed. - + The ISF header of %1 is not a JSON object: %2. The ISF header of %1 is not a JSON object: %2. - + %1: the key %2 is ignored. %1: the key %2 is ignored. - + %1 has %2 passes: MapMap reads shaders of one pass only. %1 has %2 passes: MapMap reads shaders of one pass only. - + %1 draws its pass into an image: MapMap does not read such passes yet. %1 draws its pass into an image: MapMap does not read such passes yet. - + %1 keeps images from one frame to the next: MapMap does not read such shaders yet. %1 keeps images from one frame to the next: MapMap does not read such shaders yet. - + %1 imports images: MapMap does not read such shaders yet. %1 imports images: MapMap does not read such shaders yet. - + + %1: GROUPS is not a list: it is ignored. + + + + + %1: the key %2 of group %3 is ignored. + + + + + %1: group %2 of GROUPS names no group of the inputs: it is ignored. + + + + %1: input %2 has no valid NAME. %1: input %2 has no valid NAME. - + %1: the image input %2 is refused: MapMap gives an effect one image, named %3. %1: the image input %2 is refused: MapMap gives an effect one image, named %3. - - + + %1: two inputs are named %2. %1: two inputs are named %2. - + %1: the name %2 is reserved. %1: the name %2 is reserved. - + %1: the key %2 of the input %3 is ignored. %1: the key %2 of the input %3 is ignored. - + %1: inputs of type %2 are not read by MapMap. %1: inputs of type %2 are not read by MapMap. - + (none) (none) - + %1: the unit %2 of the input %3 is ignored. %1: the unit %2 of the input %3 is ignored. - + %1: generator %2 has no valid NAME. %1: generator %2 has no valid NAME. - + %1: the generator %2 has the name of an input. %1: the generator %2 has the name of an input. - + %1: generators of type %2 are not read: %3 stays at 0. %1: generators of type %2 are not read: %3 stays at 0. - + %1: the generator %2 names an input that does not exist: %3. %1: the generator %2 names an input that does not exist: %3. - + %1: the generator %2 gives its speed twice: %3 is ignored. %1: the generator %2 gives its speed twice: %3 is ignored. - + %1: the animator %2 has a shape MapMap does not draw, %3: it stays at 0. %1: the animator %2 has a shape MapMap does not draw, %3: it stays at 0. - + %1: the parameter %2 of the generator %3 is ignored. %1: the parameter %2 of the generator %3 is ignored. - + %1: its #version line is ignored: MapMap compiles shaders in GLSL 1.20. %1: its #version line is ignored: MapMap compiles shaders in GLSL 1.20. - + %1 is an effect that reads the time: MapMap does not animate effects yet. %1 is an effect that reads the time: MapMap does not animate effects yet. - + %1 is an effect with GENERATORS: MapMap does not animate effects yet. %1 is an effect with GENERATORS: MapMap does not animate effects yet. - + %1 is an effect with the event input %2: MapMap does not animate effects yet. %1 is an effect with the event input %2: MapMap does not animate effects yet. - + %1: the name %2 is reserved: names starting with %3 are MapMap's. %1: the name %2 is reserved: names starting with %3 are MapMap's. @@ -306,7 +321,7 @@ QGuiApplication - + QT_LAYOUT_DIRECTION Translate this string to the string 'LTR' in left-to-right languages or to 'RTL' in right-to-left languages (such as Hebrew and Arabic) to get proper widget layout. LTR @@ -365,87 +380,92 @@ Delete layer - + Raise layer Raise layer - + Lower layer Lower layer - + Raise layer to top Raise layer to top - + Lower layer to bottom Lower layer to bottom - + Flip Horizontally Flip Horizontally - + Flip Image Horizontally Flip Image Horizontally - + Flip Vertically Flip Vertically - + Flip Image Vertically Flip Image Vertically - + Rotate 90° CW Rotate 90° CW - + Rotate Image 90° CW Rotate Image 90° CW - + Rotate 90° CCW Rotate 90° CCW - + Rotate Image 90° CCW Rotate Image 90° CCW - + Rotate 180° Rotate 180° - + Rotate Image 180° Rotate Image 180° - + Change output resolution Change output resolution - + + Move layer + + + + Add effect %1 Add effect %1 - + Remove effect %1 Remove effect %1 @@ -490,12 +510,12 @@ The project field '%1' must be an array. - + Initiating program... Initiating program... - + Done. Done. @@ -678,7 +698,7 @@ ShaderLibrary - + Shader refused: %1 Shader refused: %1 @@ -1764,7 +1784,7 @@ Source - + Syphon Syphon @@ -1852,6 +1872,226 @@ License + + mmp::AutoMapScan + + + Step out of the picture and do not move + + + + + The camera changed the size of its images during the scan. + + + + + The camera does not see the projection. Point it at what the projector lights, and darken the room. + + + + + The camera sends no images. + + + + + The image of the camera did not settle within %1 seconds: something moves in the picture. + + + + + mmp::AutoMappingDialog + + + Auto-Mapping + + + + + Simulated scene (--auto-mapping-simulation) + + + + + %1 - %2 × %3 + + + + + Place the camera next to the projector, so that it sees everything the projector lights. Nobody in the picture, and darken the room. +After the scan, do not touch the zoom, the focus or the framing of the projector: the image would no longer match. + + + + + Skip the finest stripes (faster, for a blurry camera, but less precise) + + + + + Start + Start + + + + + Create Shapes + + + + + + Make a layer of each face found, with a colour of its own + + + + + Camera: + + + + + Projector screen: + + + + + No camera is connected. + + + + + %1 images, about %2 seconds. + + + + + The scan needs the output over the whole screen of the projector. + + + + + Scanning: do not move. + + + + + Scan cancelled. + + + + + Done: %1, %2. The camera saw %3 % of the output: the scene seen from the projector is under the shapes of the output editor; in red, what the camera did not see. Tools > Show Auto-Mapping Image hides it with the outlines. + + + + + %n face(s) found + + + + + + + + + %n outline(s) to place by hand + + + + + + + + + Update Shapes + + + + + Move the layers of the previous scan onto their faces, and make a layer of each new face + + + + + %n layer(s) of the previous scan will follow their face: they keep their source and their effects, only their corners move. + + + + + + + + %n new face(s) will be added. + + + + + + + + %n layer(s) of the previous scan were not found again: %1. + + + + + + + + Update and Remove Them + + + + + Update and Keep Them + + + + + Update + + + + + %n layer(s) moved + + + + + + + + %n shape(s) created + + + + + + + + %n layer(s) removed + + + + + + + + %1. Edit > Undo takes it all back at once. + + + + + Cancel + + + + + Close + + + mmp::BottomPanel @@ -1871,6 +2111,14 @@ Show the editor above + + mmp::CameraFrameSource + + + No camera is connected. + + + mmp::ChoiceControl @@ -2128,15 +2376,25 @@ mmp::Effect - + Enabled Enabled - + Whether this effect changes the image; off, the image passes unchanged. Whether this effect changes the image; off, the image passes unchanged. + + + Mix + + + + + How much of the effect shows: at 0 % the image is unchanged, at 100 % only the effect shows. + + mmp::EffectInspector @@ -2240,27 +2498,27 @@ mmp::Image - + Image file Image file - + Image files (%1);;All files (*) Image files (%1);;All files (*) - + The image file shown by this source. The image file shown by this source. - + Speed Speed - + How fast an animated image plays; a negative speed plays it backwards. How fast an animated image plays; a negative speed plays it backwards. @@ -2268,9 +2526,8 @@ mmp::Inspector - Type in project files: %1 - Type in project files: %1 + Type in project files: %1 @@ -2425,7 +2682,7 @@ Quad - + Used by %1 layers: changing it changes them all. Used by %1 layers: changing it changes them all. @@ -2577,1101 +2834,1147 @@ mmp::MainWindow - - + + Open project Open project - - - - + + + + MapMap files (*.%1) MapMap files (*.%1) - - + + Save project Save project - + Import media source file Import media source file - + Media files (%1 %2);;All files (*) Media files (%1 %2);;All files (*) - + Camera device Camera device - + Select camera Select camera - - + + No camera available No camera available - - + + You can not use this feature! No camera available in your system You can not use this feature! No camera available in your system - + Syphon source added Syphon source added - - - + + + MapMap MapMap - + &New &New - + Create a new project Create a new project - + &Open… &Open… - + Open an existing project Open an existing project - + &Save &Save - + Save the project Save the project - + Save &As… Save &As… - + Save the project as… Save the project as… - + No Recents Videos No Recents Videos - + &Import Media File… &Import Media File… - + Import a video or image file… Import a video or image file… - + Open &Camera Device… Open &Camera Device… - + Choose your camera device… Choose your camera device… - + E&xit E&xit - + Exit the application Exit the application - + &Undo &Undo - + &Redo &Redo - + &About MapMap &About MapMap - + Show the application's About box Show the application's About box - + &Preferences… &Preferences… - + Configure preferences… Configure preferences… - + Play Play - + Pause Pause - + &Display Controls &Display Controls - + Display canvas controls Display canvas controls - + &Sticky Vertices &Sticky Vertices - + Enable sticky vertices Enable sticky vertices - + Show &Test Signal Show &Test Signal - + Show Test signal Show Test signal - + Display &Undo History Display &Undo History - + Open Conso&le Open Conso&le - + Display &Zoom Toolbar Display &Zoom Toolbar - + &Menu Bar &Menu Bar - + Main Layout Main Layout - + Switch to the Main layout. Switch to the Main layout. - - + + Zoom In Zoom In - - + + Zoom Out Zoom Out - + Report an issue Report an issue - + Submit feedback via email Submit feedback via email - + &View &View - + - Primary - Primary - + Unable to use file %1. The original file is not found. Please locate. Unable to use file %1. The original file is not found. Please locate. - - + + Locate file %1 Locate file %1 - + Documentation Documentation - + &File &File - + Open Recents Projects Open Recents Projects - + Open Recents Videos Open Recents Videos - + &Edit &Edit - + &Output &Output - + &Window &Window - + Remove this source and all its associated layers? Remove this source and all its associated layers? - + Input Editor Input Editor - + Output Editor Output Editor - + Library Library - + Layers Layers - + Cue %1 Cue %1 - + Cue %1 — %2 Cue %1 — %2 - + %1 set at %2 %1 set at %2 - + Used by %1 layers: changing it changes them all. Used by %1 layers: changing it changes them all. - + Replace effect Replace effect - - + + Replace Effect Replace Effect - - - + + + Add Effect Add Effect - + Save over a project of a later version? Save over a project of a later version? - + %1 was saved by a later version of MapMap, in the format %2. This version keeps what it does not know, but the later version may not open the project as it was. Save over it anyway? %1 was saved by a later version of MapMap, in the format %2. This version keeps what it does not know, but the later version may not open the project as it was. Save over it anyway? - + Learning MIDI for %1: press a pad for "%2", or turn a knob to move it both ways. Escape stops, Delete removes the MIDI controls of the point. Learning MIDI for %1: press a pad for "%2", or turn a knob to move it both ways. Escape stops, Delete removes the MIDI controls of the point. - + Learning keys for %1: press a key for "%2". Escape stops, Delete removes the keys of the point. Learning keys for %1: press a key for "%2". Escape stops, Delete removes the keys of the point. - + Learning MIDI: move a control or press a pad for %1. Delete removes its MIDI control. Learning MIDI: move a control or press a pad for %1. Delete removes its MIDI control. - + Learning MIDI: click a control outlined in blue, then move a control of the MIDI device. The MIDI controls already learned act. Learning MIDI: click a control outlined in blue, then move a control of the MIDI device. The MIDI controls already learned act. - + Learning keys: press a key for %1. Delete removes its key. Learning keys: press a key for %1. Delete removes its key. - + Learning keys: click a control outlined in blue, then press a key. Learned keys do not act until learning stops (Escape). Learning keys: click a control outlined in blue, then press a key. Learned keys do not act until learning stops (Escape). - - + + %1: %2 %1: %2 - + Move a MIDI control for %1. Delete removes its MIDI control, Escape stops learning. Move a MIDI control for %1. Delete removes its MIDI control, Escape stops learning. - + MIDI learn: click a control outlined in blue, then move a control of the MIDI device. Escape stops learning. MIDI learn: click a control outlined in blue, then move a control of the MIDI device. Escape stops learning. - + Press a key for %1. Delete removes its key, Escape stops learning. Press a key for %1. Delete removes its key, Escape stops learning. - + Keyboard learn: click a control outlined in blue, then press a key. Escape stops learning. Keyboard learn: click a control outlined in blue, then press a key. Escape stops learning. - + Learning MIDI: move a control of the MIDI device, not a key. Edit > Keyboard Learn learns keys. Learning MIDI: move a control of the MIDI device, not a key. Edit > Keyboard Learn learns keys. - + %1 drives %2. Press Escape to stop learning: %1 then acts. %1 drives %2. Press Escape to stop learning: %1 then acts. - + Click a control outlined in blue first, then press %1. Click a control outlined in blue first, then press %1. - + %1 is already the shortcut of %2: choose another key. %1 is already the shortcut of %2: choose another key. - - + + %1 → %2 %1 → %2 - + %1 → %2: %3 %1 → %2: %3 - + MIDI control removed from %1 MIDI control removed from %1 - + Key removed from %1 Key removed from %1 - + Click a control outlined in blue first, then move %1. Click a control outlined in blue first, then move %1. - + Input Editor: %1% Input Editor: %1% - + Output Editor: %1% Output Editor: %1% - + Cues Cues - + Stop Learning Stop Learning - + Stop learning (Escape) Stop learning (Escape) - - + + Add &Generator Add &Generator - + Add a generator Add a generator - + Add &Syphon Source… Add &Syphon Source… - + Receive live video from another application via Syphon… Receive live video from another application via Syphon… - + Duplicate Layer Duplicate Layer - + Duplicate layer item Duplicate layer item - + Delete Layer Delete Layer - + Delete layer item Delete layer item - + Remove Effect Remove Effect - + Remove the selected effect Remove the selected effect - + Rename Layer Rename Layer - + Rename layer item Rename layer item - + Lock Layer Lock Layer - + Lock layer item Lock layer item - + Hide Layer Hide Layer - + Hide layer item Hide layer item - + Solo Layer Solo Layer - + Solo layer item Solo layer item - + Rotate 90° CW Rotate 90° CW - + Rotate 90° clockwise. In the input view, rotates the image inside the layer. Rotate 90° clockwise. In the input view, rotates the image inside the layer. - + Rotate 90° CCW Rotate 90° CCW - + Rotate 90° counterclockwise. In the input view, rotates the image inside the layer. Rotate 90° counterclockwise. In the input view, rotates the image inside the layer. - + Rotate 180° Rotate 180° - + Rotate 180°. In the input view, rotates the image inside the layer. Rotate 180°. In the input view, rotates the image inside the layer. - + Flip Horizontally Flip Horizontally - + Flip horizontally. In the input view, flips the image inside the layer. Flip horizontally. In the input view, flips the image inside the layer. - + Flip Vertically Flip Vertically - + Flip vertically. In the input view, flips the image inside the layer. Flip vertically. In the input view, flips the image inside the layer. - - + + Raise Raise - - + + Lower Lower - + Raise to Top Raise to Top - + Raise to top Raise to top - + Lower to Bottom Lower to Bottom - + Lower to bottom Lower to bottom - + Delete Source Delete Source - + Delete source item Delete source item - + Rename Source Rename Source - + Rename source item Rename source item - + Import New Media Import New Media - + Import new media file if not exists on the list Import new media file if not exists on the list - + Add &Mesh Layer Add &Mesh Layer - + Add mesh layer Add mesh layer - + Add &Triangle Layer Add &Triangle Layer - + Add triangle layer Add triangle layer - + Add &Ellipse Layer Add &Ellipse Layer - + Add ellipse layer Add ellipse layer - + Restart Restart - + &Hide Output &Hide Output - + Output in a &Window Output in a &Window - + Output &Fills a Screen Output &Fills a Screen - + Output Output - + Output Fills a Screen (%1). The arrow chooses how and where the output is shown. Output Fills a Screen (%1). The arrow chooses how and where the output is shown. - + &Display Controls of Layers of a Source &Display Controls of Layers of a Source - + Display all canvas controls related to current source Display all canvas controls related to current source - + &Keyboard Learn &Keyboard Learn - + Link keys of the keyboard to settings: click a control, then press a key Link keys of the keyboard to settings: click a control, then press a key - + &MIDI Learn &MIDI Learn - + Link controls and notes of a MIDI device to settings: click a control, then move a MIDI control Link controls and notes of a MIDI device to settings: click a control, then move a MIDI control - + Learned K&eys Active Learned K&eys Active - + Turn the learned keys off while typing for something else, and on again Turn the learned keys off while typing for something else, and on again - + &Publish Syphon Output &Publish Syphon Output - + Publish the output composition as a Syphon server other apps can receive Publish the output composition as a Syphon server other apps can receive - + &Links &Links - + List the keys linked to settings List the keys linked to settings - + + &Auto-Mapping… + + + + + Film stripes projected on the scene, to see it from the projector + + + + + &Show Auto-Mapping Image + + + + + Show the scene seen from the projector under the shapes of the output + + + + + &Clear Auto-Mapping Image + + + + + Forget the scene seen from the projector + + + + Input editor Layout Input editor Layout - + Switch to the Input editor Layout. Switch to the Input editor Layout. - + Output Editor Layout Output Editor Layout - + Switch to the Output Editors Layout. Switch to the Output Editors Layout. - + Editor Editor - + Show the editor and hide the bottom section Show the editor and hide the bottom section - + Bottom Section Bottom Section - + Show the bottom section, such as the cues, and hide the editor Show the bottom section, such as the cues, and hide the editor - + Editor and Bottom Section Editor and Bottom Section - + Show the editor, and the bottom section under it Show the editor, and the bottom section under it - + Actual Pixels (1:1) Actual Pixels (1:1) - + Show one image pixel per screen pixel Show one image pixel per screen pixel - + Fit To View (100%) Fit To View (100%) - + Show the whole image or output frame Show the whole image or output frame - + Output &Resolution... Output &Resolution... - + Choose the size of the output frame Choose the size of the output frame - + Professional services && custom development… Professional services && custom development… - + Hire Art Plus Code for video mapping installations, custom features, integration and training Hire Art Plus Code for video mapping installations, custom features, integration and training - + Support the project (donate)… Support the project (donate)… - + Help fund MapMap's ongoing development Help fund MapMap's ongoing development - + &Keyboard shortcuts &Keyboard shortcuts - + Welcome to %1… Welcome to %1… - + + &Tools + + + + &Help &Help - + Change Layer Source Change Layer Source - + &Toolbar &Toolbar - + The learned keys act again. The learned keys act again. - + The learned keys are off: they do nothing until turned on again. The learned keys are off: they do nothing until turned on again. - + Learned keys: on Learned keys: on - + Learned keys: off Learned keys: off - + Edit > Learned Keys Active (%1) turns them on and off. Edit > Learned Keys Active (%1) turns them on and off. - + The document has been modified. Do you want to save your changes? The document has been modified. Do you want to save your changes? - - + + Error reading mapping project file Error reading mapping project file - - + + Cannot read file %1: %2. Cannot read file %1: %2. - + Cannot read %1: %2 Cannot read %1: %2 - + Project of a later version Project of a later version - + This project was saved by a later version of MapMap, in the format %1; this version writes %2. What this version does not know is kept, but may not work as the later version intended. This project was saved by a later version of MapMap, in the format %1; this version writes %2. What this version does not know is kept, but may not work as the later version intended. - + Project opened with missing entries Project opened with missing entries - + MapMap skipped these project entries: %1 MapMap skipped these project entries: %1 - + Sources this version cannot open Sources this version cannot open - + This project has sources of types this version of MapMap cannot open: %1. They are kept with their layers, which show a "missing" image, and saved as they are. This project has sources of types this version of MapMap cannot open: %1. They are kept with their layers, which show a "missing" image, and saved as they are. - + + + Face %1 + + + + + Auto-Mapping + + + + %1 - disconnected %1 - disconnected - + Output Fills a Screen Output Fills a Screen - + The output will cover this screen. Press Esc to bring MapMap back. The output will cover this screen. Press Esc to bring MapMap back. - + Cover the Screen Cover the Screen - + Don't ask again Don't ask again - + File loaded File loaded - - + + File loaded: %n link(s) active File loaded: %n link active @@ -3679,7 +3982,7 @@ They are kept with their layers, which show a "missing" image, and sav - + , %n kept but not usable here , %n kept but not usable here @@ -3687,139 +3990,139 @@ They are kept with their layers, which show a "missing" image, and sav - - + + Error saving mapping project Error saving mapping project - + Cannot write file %1: %2. Cannot write file %1: %2. - + Cannot rename temporary file to %1. Cannot rename temporary file to %1. - + File saved File saved - + Untitled Untitled - + %1[*] - %2 %1[*] - %2 - - + + MapMap Project MapMap Project - - - + + + &%1 %2 &%1 %2 - + Clear List Clear List - + No Recents Projects No Recents Projects - + %1 added %1 added - + Output %1 × %2 Output %1 × %2 - + Output Editor (%1 × %2) Output Editor (%1 × %2) - + Output Resolution Output Resolution - + Size of the output frame, usually the resolution of the projector. The output window scales it to fill the output screen. Size of the output frame, usually the resolution of the projector. The output window scales it to fill the output screen. - + Scale the shapes to keep them in place in the frame Scale the shapes to keep them in place in the frame - + %1 %2 × %3 %1 %2 × %3 - + The output screen %1 is disconnected: the output is hidden until it comes back. The output screen %1 is disconnected: the output is hidden until it comes back. - + The output screen %1 is back. The output screen %1 is back. - + %1 - %2x%3 %1 - %2x%3 - + File imported File imported - + Warning Warning - + The following file is not supported: %1 The following file is not supported: %1 - + Cannot load movie Cannot load movie - - + + %1 files (%2) %1 files (%2) - + Undo history Undo history @@ -4430,22 +4733,22 @@ They are kept with their layers, which show a "missing" image, and sav mmp::Texture - + X X - + The horizontal position of the top-left corner of the texture. The horizontal position of the top-left corner of the texture. - + Y Y - + The vertical position of the top-left corner of the texture. The vertical position of the top-left corner of the texture. @@ -4453,142 +4756,142 @@ They are kept with their layers, which show a "missing" image, and sav mmp::Video - + Source Source - + Video files (%1);;All files (*) Video files (%1);;All files (*) - + The video file, or the camera, shown by this source. The video file, or the camera, shown by this source. - + Speed Speed - + How fast the video plays; at zero the image stops. A negative speed stops it too for now: the video cannot play backwards yet. How fast the video plays; at zero the image stops. A negative speed stops it too for now: the video cannot play backwards yet. - + Volume Volume - + How loud the sound of the video plays. How loud the sound of the video plays. - + Mute Mute - + Silences the sound of the video; its volume comes back when the sound does. Silences the sound of the video; its volume comes back when the sound does. - + Play Play - + Plays this video, or pauses it alone while the others play. Plays this video, or pauses it alone while the others play. - + Position Position - + The moment of the video being played; writing it moves there. The moment of the video being played; writing it moves there. - + Duration Duration - + How long the video lasts. How long the video lasts. - + Cue %1 Cue %1 - + Colour Colour - + The colour of the cue. The colour of the cue. - + Name Name - + The name of the cue, shown when it is reached. The name of the cue, shown when it is reached. - + Time Time - + The moment of the video where the cue is; empty while it is not placed. The moment of the video where the cue is; empty while it is not placed. - + Go Go - + Jumps to the cue and plays from there; places it where the video plays when it is empty. Jumps to the cue and plays from there; places it where the video plays when it is empty. - + Set Set - + Places or moves the cue where the video plays. Places or moves the cue where the video plays. - + Clear Clear - + Removes the cue. Removes the cue. From c1873b6c155db16ae058f04b181a1a1aa2ec487a Mon Sep 17 00:00:00 2001 From: Alexandre Quessy Date: Fri, 4 Dec 2026 12:20:28 -0500 Subject: [PATCH 10/10] Complete the English translation, with the plurals of the automatic mapping 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. --- translations/mapmap_en.ts | 431 +++++++++++++++++++------------------- 1 file changed, 216 insertions(+), 215 deletions(-) diff --git a/translations/mapmap_en.ts b/translations/mapmap_en.ts index 705cef97..f08cf760 100644 --- a/translations/mapmap_en.ts +++ b/translations/mapmap_en.ts @@ -204,17 +204,17 @@ %1: GROUPS is not a list: it is ignored. - + %1: GROUPS is not a list: it is ignored. %1: the key %2 of group %3 is ignored. - + %1: the key %2 of group %3 is ignored. %1: group %2 of GROUPS names no group of the inputs: it is ignored. - + %1: group %2 of GROUPS names no group of the inputs: it is ignored. @@ -457,7 +457,7 @@ Move layer - + Move layer @@ -853,97 +853,97 @@ Changes the brightness, the contrast, the saturation and the hue of the image, its levels and the gain of each colour. - + Changes the brightness, the contrast, the saturation and the hue of the image, its levels and the gain of each colour. Levels - + Levels Black Point - + Black Point Colours this dark or darker become black. - + Colours this dark or darker become black. White Point - + White Point Colours this light or lighter become white. - + Colours this light or lighter become white. Gamma - + Gamma Above 1 the middle tones are lighter, below 1 darker; black and white stay. - + Above 1 the middle tones are lighter, below 1 darker; black and white stay. Output Black - + Output Black What black becomes: above 0 % it is lifted to a grey. - + What black becomes: above 0 % it is lifted to a grey. Output White - + Output White What white becomes: below 100 % it is dimmed to a grey. - + What white becomes: below 100 % it is dimmed to a grey. Channels - + Channels Red - + Red Multiplies the red of each pixel: 0 % removes it, 100 % keeps it. - + Multiplies the red of each pixel: 0 % removes it, 100 % keeps it. Green - + Green Multiplies the green of each pixel: 0 % removes it, 100 % keeps it. - + Multiplies the green of each pixel: 0 % removes it, 100 % keeps it. Blue - + Blue Multiplies the blue of each pixel: 0 % removes it, 100 % keeps it. - + Multiplies the blue of each pixel: 0 % removes it, 100 % keeps it. @@ -1093,232 +1093,232 @@ Colorize - + Colorize Colours the image with two colours: one for the dark, one for the light, and the shades between. - + Colours the image with two colours: one for the dark, one for the light, and the shades between. Dark Color - + Dark Color The colour that black becomes. - + The colour that black becomes. Light Color - + Light Color The colour that white becomes. - + The colour that white becomes. Options - + Options Tone From - + Tone From How light a pixel is: as the eye sees it, by its strongest channel, or by the mean of its channels. - + How light a pixel is: as the eye sees it, by its strongest channel, or by the mean of its channels. Luminance - + Luminance Maximum - + Maximum Average - + Average Gradient - + Gradient A gradient of two or three colours, linear, radial, conic or in a diamond, repeated, mirrored and moving along its shape. - + A gradient of two or three colours, linear, radial, conic or in a diamond, repeated, mirrored and moving along its shape. Shape - + Shape Linear goes across the image; radial goes out from the centre in circles; conic goes around the centre; diamond goes out from the centre in squares on their corners. - + Linear goes across the image; radial goes out from the centre in circles; conic goes around the centre; diamond goes out from the centre in squares on their corners. Linear - + Linear Radial - + Radial Conic - + Conic Diamond - + Diamond Angle - + Angle The direction of a linear gradient, clockwise from left to right; where a conic gradient starts; how a diamond is turned. A radial gradient does not use it. - + The direction of a linear gradient, clockwise from left to right; where a conic gradient starts; how a diamond is turned. A radial gradient does not use it. Center - + Center The centre of a radial, conic or diamond gradient, from the top left corner (0, 0) to the bottom right corner (1, 1). A linear gradient does not use it. - + The centre of a radial, conic or diamond gradient, from the top left corner (0, 0) to the bottom right corner (1, 1). A linear gradient does not use it. Repeats - + Repeats How many times the gradient repeats across the image, from the centre to the edge, or around the centre, where it is rounded to a whole number. - + How many times the gradient repeats across the image, from the centre to the edge, or around the centre, where it is rounded to a whole number. Mirror - + Mirror Each repeat goes from the first colour to the last and back, with no edge between repeats. - + Each repeat goes from the first colour to the last and back, with no edge between repeats. Hardness - + Hardness 0 blends the colours smoothly; 100 % gives bands of plain colour with sharp edges. - + 0 blends the colours smoothly; 100 % gives bands of plain colour with sharp edges. Color A - + Color A The first colour. - + The first colour. Color B - + Color B The second colour, the last one with two colours. - + The second colour, the last one with two colours. Color C - + Color C The third colour, used with Three Colors. - + The third colour, used with Three Colors. Three Colors - + Three Colors Goes from Color A to Color B, then to Color C. - + Goes from Color A to Color B, then to Color C. Swap Colors - + Swap Colors Swaps the first and the last colour. - + Swaps the first and the last colour. Blend - + Blend How one colour turns into the next: RGB in a straight line; Hue through the hues, the shorter way round the colour wheel; Rainbow the longer way round, all the hues when both colours have the same. A grey takes the hue of the other colour. - + How one colour turns into the next: RGB in a straight line; Hue through the hues, the shorter way round the colour wheel; Rainbow the longer way round, all the hues when both colours have the same. A grey takes the hue of the other colour. RGB - + RGB Rainbow - + Rainbow How many repeats go by in a minute: at 6, the gradient moves by one repeat every 10 seconds; 0 keeps it still. - + How many repeats go by in a minute: at 6, the gradient moves by one repeat every 10 seconds; 0 keeps it still. The gradient moves the other way: towards the centre, or anticlockwise. - + The gradient moves the other way: towards the centre, or anticlockwise. @@ -1378,407 +1378,407 @@ Invert - + Invert Inverts the colours of the image, as a photographic negative. - + Inverts the colours of the image, as a photographic negative. Keep Colors - + Keep Colors Inverts the light and the dark but keeps the colours: red stays red, lighter or darker. - + Inverts the light and the dark but keeps the colours: red stays red, lighter or darker. Threshold - + Threshold Only what is at least this light is inverted, as a solarized photograph. - + Only what is at least this light is inverted, as a solarized photograph. Inverts the red, unless the colours are kept. - + Inverts the red, unless the colours are kept. Inverts the green, unless the colours are kept. - + Inverts the green, unless the colours are kept. Inverts the blue, unless the colours are kept. - + Inverts the blue, unless the colours are kept. Luma Key - + Luma Key Makes the dark parts of the image transparent, or the light ones, to show what is behind. - + Makes the dark parts of the image transparent, or the light ones, to show what is behind. Keying - + Keying Low Threshold - + Low Threshold Darker than this, a pixel is transparent; lighter when inverted, it is opaque. - + Darker than this, a pixel is transparent; lighter when inverted, it is opaque. High Threshold - + High Threshold Lighter than this, a pixel is opaque; transparent when inverted. Between the two, it fades. - + Lighter than this, a pixel is opaque; transparent when inverted. Between the two, it fades. Removes the light parts instead of the dark ones. - + Removes the light parts instead of the dark ones. Channel - + Channel What is compared with the thresholds: the brightness seen by the eye, one channel, or the strongest of the three. - + What is compared with the thresholds: the brightness seen by the eye, one channel, or the strongest of the three. Noise - + Noise Noise that moves slowly: smooth clouds, cells or a plasma, between two colours. - + Noise that moves slowly: smooth clouds, cells or a plasma, between two colours. Kind - + Kind Smooth gives soft clouds; Cells, cells around points that wander; Plasma, waves that cross each other. - + Smooth gives soft clouds; Cells, cells around points that wander; Plasma, waves that cross each other. Smooth - + Smooth Cells - + Cells Plasma - + Plasma Scale - + Scale How many clouds, cells or waves cross the image. - + How many clouds, cells or waves cross the image. Detail - + Detail How many layers of finer and finer noise, or of waves for the plasma, are added together. Each layer costs time to draw; cells have a single layer. - + How many layers of finer and finer noise, or of waves for the plasma, are added together. Each layer costs time to draw; cells have a single layer. Seed - + Seed Changes the pattern: each number gives another one, always the same. - + Changes the pattern: each number gives another one, always the same. The colour of the low values. - + The colour of the low values. The colour of the high values. - + The colour of the high values. How many times a minute the noise goes through its motion and comes back to where it started: at 6, every 10 seconds; 0 keeps it still. - + How many times a minute the noise goes through its motion and comes back to where it started: at 6, every 10 seconds; 0 keeps it still. The noise goes through its motion the other way. - + The noise goes through its motion the other way. Posterize - + Posterize Reduces the image to a few levels of each colour, in flat bands, as a poster. - + Reduces the image to a few levels of each colour, in flat bands, as a poster. The number of levels of each colour, black and full included. - + The number of levels of each colour, black and full included. Softness - + Softness Shades between the bands: 0 % gives sharp edges, 100 % no bands. - + Shades between the bands: 0 % gives sharp edges, 100 % no bands. Dithering - + Dithering Mixes the pixels of two neighbouring levels in a fine pattern, to suggest the shades between. - + Mixes the pixels of two neighbouring levels in a fine pattern, to suggest the shades between. Brightness Only - + Brightness Only Keeps the colours and reduces only their brightness to levels. - + Keeps the colours and reduces only their brightness to levels. Stripes - + Stripes Stripes of two colours, at any angle and width, going by. - + Stripes of two colours, at any angle and width, going by. How many pairs of stripes, one of each colour, cross the image. - + How many pairs of stripes, one of each colour, cross the image. The direction across the stripes, clockwise from left to right: at 0°, the stripes stand upright. - + The direction across the stripes, clockwise from left to right: at 0°, the stripes stand upright. Width - + Width The share of each pair taken by the stripe of Color A. - + The share of each pair taken by the stripe of Color A. How wide the blend between two stripes is, in pixels of the image: 0 gives sharp edges. - + How wide the blend between two stripes is, in pixels of the image: 0 gives sharp edges. The colour of every other stripe. - + The colour of every other stripe. The colour of the stripes between. - + The colour of the stripes between. How many pairs of stripes go by in a minute: at 6, the stripes move by one pair every 10 seconds; 0 keeps them still. - + How many pairs of stripes go by in a minute: at 6, the stripes move by one pair every 10 seconds; 0 keeps them still. The stripes go by the other way. - + The stripes go by the other way. Turns the image into two colours: what is darker than the threshold, and what is lighter. - + Turns the image into two colours: what is darker than the threshold, and what is lighter. Below it a pixel takes the dark colour, above it the light colour. - + Below it a pixel takes the dark colour, above it the light colour. The width of the shades between the two colours, around the threshold: 0 % gives a sharp edge. - + The width of the shades between the two colours, around the threshold: 0 % gives a sharp edge. What is compared with the threshold: the brightness seen by the eye, one channel, or the strongest of the three. - + What is compared with the threshold: the brightness seen by the eye, one channel, or the strongest of the three. Colors - + Colors The colour of what is below the threshold. - + The colour of what is below the threshold. The colour of what is above the threshold. - + The colour of what is above the threshold. Transparent - + Transparent Which side lets what is behind show through instead of its colour. - + Which side lets what is behind show through instead of its colour. None - + None Dark - + Dark Light - + Light Waves - + Waves Waves of two colours, in straight lines or in rings around a centre, from soft to sharp, going forward. - + Waves of two colours, in straight lines or in rings around a centre, from soft to sharp, going forward. Lines are straight waves across the image; rings go out from the centre. - + Lines are straight waves across the image; rings go out from the centre. Lines - + Lines The direction in which straight waves go, clockwise from left to right. Rings do not use it. - + The direction in which straight waves go, clockwise from left to right. Rings do not use it. The centre of the rings, from the top left corner (0, 0) to the bottom right corner (1, 1). Straight waves do not use it. - + The centre of the rings, from the top left corner (0, 0) to the bottom right corner (1, 1). Straight waves do not use it. How many waves cross the image, or go from the centre to the edge. - + How many waves cross the image, or go from the centre to the edge. Sharpness - + Sharpness 0 gives soft waves, a sine; 100 % gives bands of plain colour with sharp edges. - + 0 gives soft waves, a sine; 100 % gives bands of plain colour with sharp edges. The colour of the troughs. - + The colour of the troughs. The colour of the crests. - + The colour of the crests. How many waves go by in a minute: at 6, the waves move by one wave every 10 seconds; 0 keeps them still. - + How many waves go by in a minute: at 6, the waves move by one wave every 10 seconds; 0 keeps them still. The waves go the other way: rings come towards the centre. - + The waves go the other way: rings come towards the centre. @@ -1877,27 +1877,27 @@ Step out of the picture and do not move - + Step out of the picture and do not move The camera changed the size of its images during the scan. - + The camera changed the size of its images during the scan. The camera does not see the projection. Point it at what the projector lights, and darken the room. - + The camera does not see the projection. Point it at what the projector lights, and darken the room. The camera sends no images. - + The camera sends no images. The image of the camera did not settle within %1 seconds: something moves in the picture. - + The image of the camera did not settle within %1 seconds: something moves in the picture. @@ -1905,191 +1905,192 @@ Auto-Mapping - + Auto-Mapping Simulated scene (--auto-mapping-simulation) - + Simulated scene (--auto-mapping-simulation) %1 - %2 × %3 - + %1 - %2 × %3 Place the camera next to the projector, so that it sees everything the projector lights. Nobody in the picture, and darken the room. After the scan, do not touch the zoom, the focus or the framing of the projector: the image would no longer match. - + Place the camera next to the projector, so that it sees everything the projector lights. Nobody in the picture, and darken the room. +After the scan, do not touch the zoom, the focus or the framing of the projector: the image would no longer match. Skip the finest stripes (faster, for a blurry camera, but less precise) - + Skip the finest stripes (faster, for a blurry camera, but less precise) Start - Start + Start Create Shapes - + Create Shapes Make a layer of each face found, with a colour of its own - + Make a layer of each face found, with a colour of its own Camera: - + Camera: Projector screen: - + Projector screen: No camera is connected. - + No camera is connected. %1 images, about %2 seconds. - + %1 images, about %2 seconds. The scan needs the output over the whole screen of the projector. - + The scan needs the output over the whole screen of the projector. Scanning: do not move. - + Scanning: do not move. Scan cancelled. - + Scan cancelled. Done: %1, %2. The camera saw %3 % of the output: the scene seen from the projector is under the shapes of the output editor; in red, what the camera did not see. Tools > Show Auto-Mapping Image hides it with the outlines. - + Done: %1, %2. The camera saw %3 % of the output: the scene seen from the projector is under the shapes of the output editor; in red, what the camera did not see. Tools > Show Auto-Mapping Image hides it with the outlines. %n face(s) found - - - + + %n face found + %n faces found %n outline(s) to place by hand - - - + + %n outline to place by hand + %n outlines to place by hand Update Shapes - + Update Shapes Move the layers of the previous scan onto their faces, and make a layer of each new face - + Move the layers of the previous scan onto their faces, and make a layer of each new face %n layer(s) of the previous scan will follow their face: they keep their source and their effects, only their corners move. - - - + + %n layer of the previous scan will follow its face: it keeps its source and its effects, only its corners move. + %n layers of the previous scan will follow their face: they keep their source and their effects, only their corners move. %n new face(s) will be added. - - - + + %n new face will be added. + %n new faces will be added. %n layer(s) of the previous scan were not found again: %1. - - - + + %n layer of the previous scan was not found again: %1. + %n layers of the previous scan were not found again: %1. Update and Remove Them - + Update and Remove Them Update and Keep Them - + Update and Keep Them Update - + Update %n layer(s) moved - - - + + %n layer moved + %n layers moved %n shape(s) created - - - + + %n shape created + %n shapes created %n layer(s) removed - - - + + %n layer removed + %n layers removed %1. Edit > Undo takes it all back at once. - + %1. Edit > Undo takes it all back at once. Cancel - + Cancel Close - + Close @@ -2116,7 +2117,7 @@ After the scan, do not touch the zoom, the focus or the framing of the projector No camera is connected. - + No camera is connected. @@ -2388,12 +2389,12 @@ After the scan, do not touch the zoom, the focus or the framing of the projector Mix - + Mix How much of the effect shows: at 0 % the image is unchanged, at 100 % only the effect shows. - + How much of the effect shows: at 0 % the image is unchanged, at 100 % only the effect shows. @@ -3687,32 +3688,32 @@ Save over it anyway? &Auto-Mapping… - + &Auto-Mapping… Film stripes projected on the scene, to see it from the projector - + Film stripes projected on the scene, to see it from the projector &Show Auto-Mapping Image - + &Show Auto-Mapping Image Show the scene seen from the projector under the shapes of the output - + Show the scene seen from the projector under the shapes of the output &Clear Auto-Mapping Image - + &Clear Auto-Mapping Image Forget the scene seen from the projector - + Forget the scene seen from the projector @@ -3827,7 +3828,7 @@ Save over it anyway? &Tools - + &Tools @@ -3935,12 +3936,12 @@ They are kept with their layers, which show a "missing" image, and sav Face %1 - + Face %1 Auto-Mapping - + Auto-Mapping