Skip to content

Client-side stereo detection transfer via ONNX (first pass)#1709

Open
mattdawkins wants to merge 10 commits into
mainfrom
dev/stereo-onnx-transfer
Open

Client-side stereo detection transfer via ONNX (first pass)#1709
mattdawkins wants to merge 10 commits into
mainfrom
dev/stereo-onnx-transfer

Conversation

@mattdawkins

Copy link
Copy Markdown
Member

First pass at warping a detection from one camera to the other entirely
client-side (web + Electron renderer), with no backend, by running VIAME's
epipolar template-matching stereo model (stereo measurement "method 1")
exported to ONNX and executed with onnxruntime-web.

This is the client counterpart to the desktop backend stereo service: the
desktop ViewerLoader warps via native IPC (stereoTransferLine /
stereoTransferPoints); this does the equivalent correspondence search in the
browser so it also works on the web.

What's here (client/dive-common/use/stereo/)

  • StereoOnnxMatcher — loads the match ONNX model and warps source points to
    target points (epipolar candidate generation + NCC along the curve).
  • calibration.ts / npz.ts — parse .npz/.json calibration in-browser
    (mirrors read_stereo_rig), plus invertRig to swap source/target camera.
  • image.ts — RGBA to BT.601 grayscale (matches OpenCV BGR2GRAY used by the NCC).
  • frameSource.ts — read full-res frame pixels from a GeoJS viewer.
  • useStereoOnnxTransfer — on stereo-annotation-complete, warp a box (corners)
    or head/tail line (keypoints) to the other camera and write the feature.
  • Web glue: platform/web-girder/useStereoOnnxWeb.ts, bound to the Viewer's
    stereo-annotation-complete event in the web ViewerLoader.vue.

onnxruntime-web is added as a dependency. The exported model is served as a
static asset (default /models/stereo_match.onnx).

Testing

  • Core is unit-tested (__tests__/stereoOnnx.spec.ts, runs under npm test):
    calibration parsing, grayscale, and point warping validated against the VIAME
    C++/Python reference (matches to ~0.25 px) via onnxruntime-web in Node.
  • The web glue (frame-pixel read, ViewerLoader binding, calibration retrieval) is
    type-checked and lint-clean but has not been live-tested in a running web
    viewer with a real stereo dataset.

Notes

  • Disparity search range is currently a permissive default; should become a user
    setting.
  • DINO-augmented method 2 exists on the VIAME side but is not wired here yet.

Brings in the SAM2/SAM3-based interactive segmentation feature, the
SAM3 text-query workflow, and the desktop interactive stereo mode.
Web-girder paths are intentionally untouched for now — web support
will come in a follow-up.

- New segmentation point-click recipe + EditorMenu wiring; SAM2/SAM3
  models loaded via VIAME install configs.
- Desktop backend: viame_segmentation_service-backed IPC handlers and
  matching frontend API for segmentationInitialize/Predict/SetImage/
  ClearImage/Shutdown/IsReady, textQuery/refineDetections/
  runTextQueryPipeline, and stereoEnable/Disable/SetFrame/GetStatus/
  TransferLine/TransferPoints/SetCalibration/IsEnabled, plus disparity
  ready/error event hooks.
- EditAnnotationLayer: track shift-key state and right-click for Point
  mode, propagate background flag for negative SAM points.
- Sidebar / ViewerLoader / Viewer: stereo annotation mode UI, error
  dialog when seg or text-query model fails to load, dot-only-on-source
  -frame fix.
- useModeManager / EditAnnotationLayer / recipes: keep existing geometry
  type when current editing mode already matches; right-click in Point
  creation finalises and deselects.
A track-frame's polygon now expands to a list of polygons each with
their own keys, and each polygon supports holes.

- Server CSV (de)serializer: emit polygon-key column per polygon, support
  holes in the geoJSON FeatureCollection; auto_key path to append a new
  polygon to an existing track frame.
- Client recipes / useModeManager: handleAddHole / handleAddPolygon /
  handleCancelCreation; PolygonLayer emits polygon-clicked.
- Hole drawing reuses the polygon edit pipeline (left-click places a
  hole vertex without exiting creation mode).
- Test fixtures cover multi-polygon and polygons-with-holes round-trip.
(cherry picked from commit c2f3cd0)
…tton)

Strip the SAM3 text-query button, dialog, API, and IPC handlers from the interactive editor, keeping segmentation and stereo intact. The full text-query feature lives on the follow-up branch dev/text-query-annot-button.
Strip the no-transcode NativeVideoAnnotator path that should not be on the
segmentation/stereo branch: removes the residual Viewer.vue async-component,
nativeVideoPath plumbing, and template branch, plus the stale settings field.
The rebase onto main dropped the opening <template> tag, so vite parsed the
root <div> as a custom block and the electron build failed. Restore it.
@mattdawkins mattdawkins force-pushed the dev/stereo-onnx-transfer branch from eb3573d to 42ca8d8 Compare June 22, 2026 16:25
Runs VIAME's epipolar template-matching model (stereo method 1) in the browser
with onnxruntime-web to warp a detection (box / head-tail keypoints) from one
camera to the other, with no backend. Includes calibration (.npz/.json) and
grayscale helpers, a platform-agnostic transfer composable, and web ViewerLoader
wiring. Core is validated against the VIAME reference in unit tests.
@mattdawkins mattdawkins force-pushed the dev/stereo-onnx-transfer branch from 42ca8d8 to a55690f Compare June 22, 2026 17:11
Base automatically changed from dev/add-interactive-seg-and-stereo to main June 27, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant