Machine Vision Simulator — Threshold, Centroid & Pose Estimation Interactive

Interactive machine-vision laboratory: threshold a synthetic camera image and estimate a part's centroid and orientation from moments.

← Robotics Labs
About this tool — how it works & FAQOpen ▾Close ▴

About the Machine Vision Simulator

This simulator places an overhead camera above a rotated rectangular part and shows the physical scene next to a synthetic 64 by 48 grayscale image, a binary mask and the pose estimated from it. You can dim the lights, raise the threshold or occlude the part and see exactly when the estimate degrades or disappears.

What the simulator shows

• An overhead camera, a rotated inspection part, an occlusion strip, a calibration field and projection rays, alongside the synthetic sensor image and binary mask with an estimated major axis. • Controls for part horizontal and vertical center (±0.2 m and ±0.15 m), orientation (-70° to 70°), illumination factor (0.2-1), segmentation threshold (30-240 gray levels), occluded fraction of part width (0-0.6) and an option to move the part across the field. • Readouts for detected foreground pixels, estimated center x and z in millimeters, estimated orientation modulo 180°, centroid error and whether a pose is available. • Experiments for a clear target and for insufficient contrast, where no object is detected.

From pixels to pose

A pixel is foreground when its intensity exceeds the threshold. The centroid is the mean of foreground pixel coordinates, cx = Σx/N and cz = Σz/N, and orientation comes from second moments, θ = ½ atan2(2 covxz, covxx - covzz). The pixel pitch is 0.8 m / 64 = 0.6 m / 48. Lowering illumination or raising the threshold removes foreground pixels, and occluding part of the part biases the centroid because the algorithm measures only what it sees.

Model boundaries

The camera is synthetic and orthographic with deterministic pixel-center sampling. There is no neural model, real camera access, perspective, lens distortion, motion blur or random noise. When nothing is detected the pose shows as unavailable rather than a fabricated zero.

Frequently asked questions

Why does the estimated centroid differ slightly from the true center?

The image is sampled on a 64 by 48 pixel grid, so the centroid and angle vary slightly with how the part edges land on pixel centers. The centroid error readout shows this pixel-sampling effect even for an ideal rectangle.

What happens when illumination is too low?

If the image falls below the threshold there are no foreground pixels, so there is no valid pose. The lab shows dashes for unavailable values instead of reporting a false zero.

How does occlusion affect the estimate?

The algorithm estimates the visible region only and cannot infer hidden geometry, so the centroid shifts toward the visible part of the object. Increase the occluded fraction to see the bias grow.

How is orientation computed from the mask?

The covariance of foreground pixel coordinates gives the principal axis: θ = ½ atan2(2 covxz, covxx - covzz). The result is an angle modulo 180°, since a rectangle looks the same when turned half a revolution.

Related tools & guides