A robot that handles glassware has to know which glasses it can grip before any arm moves: an upright tumbler gets filled, an inverted one gets skipped or flipped. One top-down camera settles this without a trained classifier. You threshold the tray, label the connected regions, erode the binary image with one disc, and keep every blob above one area threshold — the upright glass survives as a large region, the inverted base as a small one, and the surviving centroids are the pick points. This page works the numbers for a 400 x 300 mm tray at 0.173 mm per pixel: sizing the camera and lens, choosing the erosion radius, placing the threshold, and handing millimeter coordinates to the robot. The same chain sorts caps, connectors and any pair of orientations that differ in silhouette area.
What does blob analysis measure in this image?
Blob analysis thresholds the frame, labels every connected region of set pixels and measures each one, so a tray shot becomes a short table of regions, each carrying an area in pixels and a centroid, and every region of glass-sized area is one candidate glass.
Labeling is the step that makes one glass one object: pixels that touch count as one region, and whether diagonal neighbors also join depends on the connectivity setting. For round glasses, 8-connectivity is the safe default, and the connectivity choice for circular markers shows the failure mode the 4-pixel setting invites. Each region then reports area, centroid, bounding box and hole count, which is everything this sort needs.
Plain counting stops at the tally: the rod-shaped parts counted with blob analysis end there, while this task needs orientation, and that is why erosion enters. The same area trick separates capped bottles from open necks, seated connectors from flipped ones and right-side-up ICs from lead-side-up, anywhere two orientations differ in silhouette area.
How many pixels do you need to split a rim from a base?
At 400 mm working distance, a 5 MP, 2448 x 2048, 3.45 µm sensor with an 8 mm lens gives a 423 x 354 mm field of view at 0.173 mm per pixel: an 80 mm rim reads a 232 px radius, a 65 mm base 188 px.
Worked example, and the arithmetic you repeat with your own parts. The sensor width is 2448 x 3.45 µm = 8.45 mm, and the pinhole relation gives the field of view:
The tray is 400 x 300 mm, so it fits in one shot with a 23 mm margin on the width. Scale the parts: rim radius = 40 mm / 0.1726 mm/px ≈ 232 px; base radius = 32.5 mm / 0.1726 mm/px ≈ 188 px. Keep the two radii at least 20 px apart so a ±5 px silhouette error cannot flip a glass; this geometry has a 44 px gap. The 8 mm focal length also keeps the camera mountable on a frame above the table instead of on the ceiling. For a different tray or part size, the calculator below repeats this arithmetic for your focal length and working distance.
Why erode the image before you filter by area?
Erosion with a 30-pixel disc deletes every feature narrower than 60 pixels — the 44-pixel rim band of an inverted glass, droplets, bridges between touching glasses — and shrinks each solid region by 30 pixels all around, which widens the orientation gap into a stable number.
Erosion keeps a pixel only when the whole structuring element fits inside the region. Three consequences do the work here. A solid disc of radius R erodes to a disc of radius R − r, so both orientations shrink by a known, equal amount. A band narrower than 2r disappears completely, which erases the inverted glass's rim band and any arc fragments of it. And specks, droplets and thin bridges under 2r wide vanish or split, cleaning the count before it starts — the same morphology family that pulls dark specks out of uniform surfaces.
Set the radius from two limits. It must exceed half the rim band: a 44 px band needs r > 22 px. It must leave the smaller shape measurable: with the base at 188 px, r below roughly 90 px keeps a usable disc. Take the middle: r = 30 px, which is 5.2 mm on the part and a 61-px disc. At 2r = 60 px against a 44 px band, the band dies with 16 px of margin.
Where do you set the area threshold?
Set the minimum eroded area at 100,000 pixels: the upright glass survives erosion at about 128,000 pixels and the inverted base at about 78,000, so the threshold sits 22 percent below the upright area and 28 percent above the inverted one.
The full chain from silhouette to decision, in one place:
What moves those numbers: a silhouette radius error of 1 mm is 5.8 px at this scale, and eroded area changes by about 2πR per pixel of radius — 7,400 px on the upright glass, 5,800 on the base, six to seven percent. A chipped rim or a water film would need to move the effective radius nearly 4 mm before either class crosses 100,000 px. That margin is what the 22/28 percent placement buys, and it is why you re-measure rather than nudge if the parts change.
Area is a pixel count, and the pixel-counting area method cross-checks any library's number by hand. Gate the cycle on the counts: blobs above 100,000 px are fillable glasses, blobs between the 5,000 px floor and the threshold are inverted ones to route away — the routing to a robot and reject pusher pattern handles the reject side.
Lock exposure and gain once the lighting is final; auto exposure chases ambient light and drags your threshold with it, which the ambient light control for pick-and-place vision piece tracks across a full shift.
How do blob centers become coordinates your robot can pick?
Multiply each surviving centroid by the 0.173 mm-per-pixel scale and subtract the tray origin you taught once, and every glass becomes an X-Y pair in tray millimeters that your program sends to the robot as one short line per pick.
Calibration is one reference mark, taught once: read its centroid, set x0 and y0, and convert with X_mm = (cx − x0) x 0.1726 and the same for Y. If the table rotates between the shot and the pick, rotate each point about the table center by the known step angle θ:
with Xt, Yt the table center in tray millimeters. A 180° turn maps each centroid to its far-side position exactly, and a half-degree indexing error at a 150 mm radius puts the point out by 150 mm x sin(0.5°) ≈ 1.3 mm — so set the table's index accuracy against the pick tolerance. The wire format and handshake with the robot program follow the part coordinates over TCP pattern: frame ID, two millimeter floats, done.
Which hardware runs the count, the sort and the hand-off?
A single station with fixed logic runs entirely on a smart camera — threshold, erosion, blob tools and the result output live on the device — while a cell that adds bottle identification, a second table or robot hand-off wants a vision controller with enough LAN ports and light channels.
For this tray station, on-device is the simpler build: one camera, one cable, results out. Two fitted-lens smart cameras cover the worked-example scale:
- Interface
- GigE
- Resolution
- 5 MP
- Interface
- GigE
- Resolution
- 6-10 MP
The SC6000 unit brings a 5 MP color global-shutter sensor with its 8 mm M12 lens fitted; the SC5000X reads 6 MP mono through the same 8 mm M12 mount with a rolling shutter. The tray is stationary during exposure, so the rolling shutter costs nothing here, and mono skips the color filter array so every pixel feeds the threshold. Browse the smart cameras by sensor, mount and shutter, or use the camera finder.
For a smaller tray or a tight mount, the LS-SMC-0063 carries a 1.6 MP sensor, a 16 mm lens and its own white light, polarized, delivering 60 fps. The polarization is worth having over glass: it cuts the specular glare that eats rim edges, and the built-in light means one less unit to wire and strobe.
- Interface
- GigE
- Resolution
- Up to 3 MP
When the cell grows — tray counting plus bottle identification plus a second table — move the logic to a controller so both cameras and the light outputs run from one box. The MV-VC3301H-128G66 pairs 5+ LAN ports with 4 built-in light channels and PCIe expansion on an Intel Core i3 with 8 GB of memory, so one box runs tray counting, bottle identification and the strobes together; the larger series sit in vision controllers.
- LAN ports
- 5+ LAN ports
- USB 3 ports
- 3-4 USB 3 ports
- Light outputs
- 4 built-in channels
- Memory
- 8 GB
Throughput sanity check, as an estimate: a 5 MP 8-bit frame is about 5 MB, one GigE link moves roughly 110 MB/s, so about 20 frames per second per camera. One frame per tray cycle leaves an order of magnitude of headroom; the pour, not the vision, sets the pace.
When does erosion and area filtering give the wrong answer?
It goes wrong when the two orientations stop differing in area — no contrast on clear glass, glasses touching into one region, wet or frosted silhouettes, blur from a moving table — and each cause has an ordered fix before you touch the 100,000 px number.
Work the causes in this order, most common first.
- No contrast. Clear glass over a tray of similar brightness produces no region at all, and no threshold recovers information the lighting never delivered. Fix it in the light: a dark matte tray under the glasses, diffuse overhead light, a polarizer on glass-heavy scenes — the lighting-before-thresholding fix for glass walks that sequence. Test: threshold the empty tray, then one glass, at final exposure; the region must appear without gain tricks.
- Touching glasses. Two rims that touch threshold into one blob whose area exceeds both classes. Erosion separates them when the bridge is narrower than 2r — 60 px, about 10 mm here. Wider contact needs physical spacing: tray slots or a simple part spreader. Test: two glasses 20 mm apart, edges nearly touching.
- Wet or frosted glass. Droplets add specks, which the 5,000 px floor kills; films move the silhouette radius, which the 4 mm margin absorbs. If a wet glass still flips the classification, the parts changed — re-measure both eroded areas and re-derive the threshold rather than nudging it.
- Motion blur. Shooting while the table turns smears the rim; the exposure numbers are in the FAQ below. Test rim-edge sharpness at the final speed, and expose between table steps.
What do you check before ordering the parts?
Two measurements decide the order: caliper the real rim and base diameters, then shoot one upright and one inverted glass on the lit tray at final exposure — the design holds if the two eroded areas straddle your threshold by 20 percent or more on each side.
- Rim and base diameters, calipered. Every pixel number in this page derives from the two diameters and the scale; your parts set the threshold, not this page's 80 mm and 65 mm.
- Both orientations on the lit tray. Threshold, erode at your chosen r, read both areas, compute the straddle percentages.
- 20 percent straddle each side. Below that, change the geometry — longer focal length, tighter field, a tray insert — before touching software.
- Exposure freeze. Table stopped during exposure, blur under 1 px, which is 0.17 mm at this scale.
- Port and light-channel count. Camera outputs plus communications plus strobe channels must fit the camera, or move up to a controller's ports.
- Toolset check. The camera or library must expose threshold, erosion with a settable disc size, connected-component labeling, an area filter and centroid output — five standard tools.
When the straddle holds, size the camera and controller in the system configurator, or send both measured areas through the contact page and we will check the arithmetic with you before you order. More applied walk-throughs sit on the applications topic page.
Questions
How fast does the vision step run at 60 fps?
At 60 fps a camera delivers a new frame every 16.7 ms, but a tray station needs one good frame per cycle, not a stream. Threshold, erosion and labeling on a 1.6 to 5 MP image take tens of milliseconds on a smart camera or controller, so vision never bottlenecks a serve cycle; the pour sets the pace.
Can I shoot while the turntable is still rotating?
Only if the blur stays under about a pixel. At 0.173 mm per pixel that is 0.17 mm, so a rim moving at 0.4 m/s needs an exposure under 0.4 ms. At a practical 5 ms the rim smears 2 mm, about 12 px — shoot between table steps, then check rim sharpness at the final speed.
Does the same method work for stemware or bottles?
Yes, wherever the two orientations differ in silhouette area. An upright wine glass gives a large rim blob with a thin stem; inverted, it is a compact base disc. Bottles differ more: an open neck thresholds as a ring, a capped one as a solid disc. Measure both eroded areas on your parts and place the threshold between them, exactly as with tumblers.
Should the structuring element be a disc or a square?
Use a disc for round parts. A square element eats corners, so a circular glass loses area unevenly as it rotates on the tray, and the threshold inherits that wobble. The 61 x 61 square matching a 30-pixel disc runs faster on some processors, but sort stability is worth more than a few milliseconds here.



