← Labs

Photo to 3D

Lift a flat photo into a 3D point cloud you can orbit — monocular depth runs in your browser, the way a robot turns a single camera frame into geometry.

How to use

When the page opens it downloads a depth network (about 94 MB) and shows a progress bar while it does. There is no server doing the work — the model runs entirely inside your browser, on your GPU where one is available, and falls back to a slower WebAssembly path otherwise. Once it is ready, the first sample scene is lifted into a point cloud and starts rotating. A scan-line sweeps through it front-to-back, painting the points as it passes.

Drag to orbit, scroll (or pinch) to zoom. Switch between the three sample scenes — a living room, a street, a desk — and each one is run through the model live; you are watching the same inference a robot’s perception stack would do on a camera frame. The point-size slider thickens or thins the cloud; the scan-line and drift toggles control the animation.

Use webcam and Upload image run the same model on your own scene. Everything stays on the device — no frame is ever uploaded anywhere. One honest caveat: monocular depth is trained on rooms, streets, and objects, so it reads scenes well but gives mushy, unconvincing depth for a close-up face. Point it at a room, not a selfie.

What is actually happening

A single photograph has no depth in it. The camera flattened a 3D world onto a 2D sensor and threw the range away. Recovering it from one image — monocular depth estimation — is genuinely hard, because infinitely many 3D scenes project to the same picture. What makes it possible at all is prior knowledge: a network that has seen enough rooms and streets learns the statistics of how the world is usually arranged, and guesses the depth that is most consistent with the cues in the image — perspective lines, the apparent size of familiar objects, occlusion, texture gradients, shading.

The model here is Depth-Anything-V2-Small, exported to ONNX and run with ONNX Runtime Web. It takes a 518×518 RGB image and returns one relative-depth value per pixel. “Relative” matters: it does not know the scene is four metres deep rather than four hundred — it only knows what is nearer and what is farther, and by roughly how much. That is enough to build geometry you can orbit, and it is exactly the regime a lot of real perception lives in before a second sensor (stereo, LiDAR, structured light) pins down absolute scale.

From a depth map to a point cloud

Once every pixel has a depth, turning the image into 3D points is the pinhole camera model run backwards. A pinhole camera maps a 3D point onto the sensor by dividing out the distance: a point at (X, Y, Z) lands at pixel (u, v) = (f·X/Z + cx, f·Y/Z + cy), where f is the focal length in pixels and (cx, cy) is the image centre. Forward projection is what the camera did when it took the picture. Back-projection undoes it: given a pixel (u, v) and a depth d, the 3D point that produced it is

X = (u - cx) · d / f
Y = (v - cy) · d / f
Z = d

Do that for every pixel, colour each resulting point with that pixel’s RGB, and you have a point cloud. That is the whole trick. A camera frame plus a per-pixel depth is, geometrically, a cloud of coloured points in space — which is why an RGB-D camera is sometimes just called a “point cloud camera.”

There is one honesty note in this lab. We do not know the camera’s true focal length for an arbitrary photo, and the depth is relative rather than metric, so a literal back-projection would funnel the scene into a distorted cone. Instead the points keep the image’s shape in X and Y and are displaced along Z by the depth — a relief, rather than a metrically reconstructed scene. It reads clearly as “this is the geometry the model sees” without pretending to a precision the single image cannot support. With a known intrinsic matrix and metric depth — a calibrated RGB-D sensor — the same equations give you a true, measurable cloud.

Why this is the front end of everything

This back-projection is the first step of a large fraction of robotics perception. A LiDAR scan is a point cloud. An RGB-D camera gives you a colour image and a depth image, and the driver back-projects them into exactly this kind of cloud. SLAM systems consume clouds frame after frame and stitch them into a map; object-pose estimators fit models to them; navigation stacks turn them into occupancy grids. Long before any of that, something has to take a sensor frame and lift it into geometry — and that something is the arithmetic above.

Running it from a single ordinary camera, with the depth hallucinated by a network instead of measured by a second sensor, is the part that has changed recently. It used to need stereo rigs or active depth hardware. Now a model running in a browser tab does a passable job, on your GPU, with nothing leaving the machine. The sample scenes are CC0 photographs from Pexels; the depth you see for every one of them — and for your own webcam or uploads — is computed live, here, by the same model.