cad-3d-reconstruction / verification_code /make_pipeline_figs.py
acd23's picture
Add METADOC.md: full verified project report with figures, verification data and corrections
ad19db2 verified
Raw History Blame Contribute Delete
4.37 kB
"""Draw the pipeline diagrams used in the metadoc."""
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
from matplotlib.patches import FancyBboxPatch, FancyArrowPatch
BG = "#1e2126"; FG = "#e8eaee"; OK = "#4ea36b"; BAD = "#c8503f"; WARN = "#c99a3a"; ACC = "#5b9bd5"
def box(ax, x, y, w, h, text, color, sub=None):
ax.add_patch(FancyBboxPatch((x, y), w, h, boxstyle="round,pad=0.02,rounding_size=0.06",
linewidth=1.8, edgecolor=color, facecolor=color + "22"))
nlines = text.count("\n") + 1
ty = y + h / 2 + (0.10 if sub else 0) + (0.0 if nlines == 1 else 0.03)
ax.text(x + w / 2, ty, text, ha="center", va="center", color=FG,
fontsize=8.6, weight="bold", linespacing=1.25)
if sub:
ax.text(x + w / 2, y + 0.10, sub, ha="center", va="center", color=color, fontsize=7.2)
def arrow(ax, x1, y1, x2, y2, color=FG, ls="-"):
ax.add_patch(FancyArrowPatch((x1, y1), (x2, y2), arrowstyle="-|>", mutation_scale=13,
linewidth=1.5, color=color, linestyle=ls, shrinkA=0, shrinkB=0))
def new_ax(w, h):
fig, ax = plt.subplots(figsize=(w, h), dpi=170)
fig.patch.set_facecolor(BG); ax.set_facecolor(BG)
ax.set_xlim(0, 10); ax.set_ylim(0, h / w * 10); ax.axis("off")
return fig, ax
# ------- Figure A: the textbook 3DGS route and where it breaks -------
fig, ax = new_ax(11, 2.6)
Y, H, W = 1.20, 0.62, 1.62
xs = [0.10, 2.08, 4.06, 6.04, 8.02]
for x, (t, s, c) in zip(xs, [
("4-5 CAD views", "input", ACC),
("COLMAP SfM", "match + pose", BAD),
("Camera poses\n+ sparse cloud", "required by 3DGS", BAD),
("3DGS / 2DGS\ntraining", "never reached", BAD),
("Splat -> mesh", "never reached", BAD)]):
box(ax, x, Y, W, H, t, c, s)
for i in range(4):
arrow(ax, xs[i] + W, Y + H / 2, xs[i + 1], Y + H / 2,
FG if i == 0 else BAD, ls="-" if i == 0 else "--")
ax.text(2.95, Y - 0.16, "X 0 geometrically-verified image pairs on 3 of 4 parts;\n"
" only 2 of 5 images registered on timing_pulley",
ha="center", va="top", color=BAD, fontsize=8.0, weight="bold")
ax.text(0.15, Y + H + 0.22, "A. The standard Gaussian-Splatting route - blocked at step 2",
color=FG, fontsize=11, weight="bold")
plt.savefig("report_assets/10_pipeline_3dgs.png", facecolor=BG, bbox_inches="tight"); plt.close()
# ------- Figure B: what was actually run -------
fig, ax = new_ax(11, 5.4)
W2, H2 = 1.95, 0.68
box(ax, 0.15, 3.55, W2, H2, "4-5 CAD views", ACC, "input")
box(ax, 2.55, 3.55, W2, H2, "MASt3R", WARN, "pose + dense depth")
box(ax, 4.95, 3.55, W2, H2, "Point cloud\n200k-600k pts", WARN, "views not fused")
box(ax, 7.60, 4.25, W2, H2, "Poisson mesh", BAD, "Open3D")
box(ax, 7.60, 2.85, W2, H2, "Ball-pivoting mesh", BAD, "Open3D")
arrow(ax, 0.15 + W2, 3.89, 2.55, 3.89)
arrow(ax, 2.55 + W2, 3.89, 4.95, 3.89)
arrow(ax, 4.95 + W2, 3.89, 7.60, 4.59)
arrow(ax, 4.95 + W2, 3.89, 7.60, 3.19)
ax.text(0.15, 4.52, "B. What was actually run", color=FG, fontsize=11, weight="bold")
ax.text(5.92, 3.44, "each view lands on its own depth sheet",
ha="center", va="top", color=BAD, fontsize=7.6)
box(ax, 0.15, 1.35, W2, H2, "Canny edge maps", OK, "OpenCV - usable")
box(ax, 0.15, 0.25, W2, H2, "Watershed masks", BAD, "labels the background")
box(ax, 2.55, 0.80, W2, H2, "Adapted 2-stage\nGaussian training", BAD, "500 pts / 200+100 iters")
box(ax, 4.95, 0.80, W2, H2, "Labeled cloud\nmerged.pcd", BAD, "only 2 k-means labels")
box(ax, 7.60, 1.50, W2, H2, "B-Rep fitting\n(official module)", BAD, "0-1 planes, no edges")
box(ax, 7.60, 0.10, W2, H2, "B-Rep fitting\non dense cloud", WARN, "7-8 planes, 0 cylinders")
arrow(ax, 0.15 + W2, 1.69, 2.55, 1.31)
arrow(ax, 0.15 + W2, 0.59, 2.55, 0.97)
arrow(ax, 2.55 + W2, 1.14, 4.95, 1.14)
arrow(ax, 4.95 + W2, 1.14, 7.60, 1.84)
# dense cloud reused directly for the fallback B-Rep fit
arrow(ax, 5.92, 3.55, 5.92, 2.05, ACC, ls=":")
arrow(ax, 5.92, 2.05, 7.60, 0.44, ACC, ls=":")
ax.text(6.05, 2.75, "dense cloud reused\ndirectly (fallback)", color=ACC, fontsize=7.4, va="center")
ax.text(0.15, 2.25, "BrepGaussian branch (reimplementation of the paper)",
color=FG, fontsize=9.6, weight="bold")
plt.savefig("report_assets/11_pipeline_actual.png", facecolor=BG, bbox_inches="tight"); plt.close()
print("ok")