Optics & lighting

Lighting and ROI for a visible liquid boundary

Separate a real liquid boundary from wall reflections, seams and foam before using a fixed ROI to calculate a visible level proxy.

Send samples for engineering review
Lighting and ROI for a visible liquid boundary
Engineering illustration; not a photograph or a completed production test.

Define the contrast contract

A brighter bottle image is not necessarily a better liquid-level image. A reflection from the wall may become stronger than the liquid boundary, while foam can produce another horizontal transition. Define the contrast contract before selecting illumination: which transition represents the agreed visible boundary, what image polarity it has, and which wall or label features must remain outside the observation zone. The target is a stable observable boundary, not an attractive preview. A visible-height or coverage ratio remains a proxy. Lighting changes do not establish a conversion to volume, especially with curved containers or an uncertain meniscus.

Keep polarity samples

Save source images of empty, nominal and visibly low containers before testing a threshold. Include wall seams, label offsets and foam conditions that could mimic the desired transition. Record whether the region below the boundary is expected to be brighter or darker than the region above it. That polarity belongs to the actual illumination and material combination; it is not universal for all liquids. Use the same source images when comparing derived grayscale and binary views. Keep an empty-bottle control in the trial because a line that persists without liquid may be a wall or fixture feature rather than useful level evidence.

Choose lighting geometry

Compare a backlight arrangement with the proposed alternative at a fixed container pose, using the same camera and lens geometry. A backlight can expose a transmitted-intensity transition in some containers, but a thick, colored or curved wall may weaken or displace it. A diffuse arrangement may reduce a bright wall reflection while also reducing the boundary gradient. Record those tradeoffs directly. Move the light without changing the observation zone or gain in the same trial. If the boundary requires a new viewpoint, treat that as a separate geometry revision rather than attributing the whole improvement to an illumination adjustment.

Tie the ROI to the container datum

The visible boundary is read in a declared local coordinate system rather than a movable display crop.

  1. Stable container datum
  2. Fixed original-image ROI
  3. Downward boundary coordinate
  4. Visible-height proxy only
Illustrative geometry; changing the ROI requires a new comparison basis.
View full-size diagram

Declare the ROI coordinates

Declare the ROI in original-image coordinates and define how the detected boundary maps into that local coordinate system. In an illustrative synthetic zone of height 20 px, a unique boundary at y=8 measured downward from the top produces a visible-height ratio of 0.6. At y=14 the same convention produces 0.3. The calculation below expresses the coordinate convention, not the volume of a real bottle. A crop shift changes the reference height, so preserve the crop origin, dimensions and container datum with every revision. Do not compare ratios from different ROIs as if only the fill state changed.

H = 20
y = 8
visible_ratio = (H - y) / H  # 0.6
y = 14
visible_ratio = (H - y) / H  # 0.3
# y is measured downward from the top of the fixed ROI.
# This is a synthetic image-height proxy, not liquid volume.

Run paired lighting trials

Run a paired trial in which each identified container is captured under the baseline and candidate light setting without changing the reference class. Keep exposure, gain, pose, settling condition and ROI fixed. Repeat the pair after the normal lighting warm-up and under the expected ambient-light extremes. Save both original images even when the candidate looks worse. Compare boundary visibility and ambiguity by container group, rather than selecting only the clearest image from each condition. If an automatic camera control cannot be disabled, record its actual setting for every capture and recognize that the trial no longer isolates lighting alone.

Inspect the boundary profile

Inspect an intensity or gradient profile across the agreed observation zone before tuning a final decision. Mark the intended boundary and the competing transitions created by a seam, reflection or foam. Examine the profile at the permitted horizontal positions; a single favorable column can hide a poor view elsewhere. Save the grayscale profile, the proposed boundary coordinate and the source crop identity. Thresholding is a derived-image operation with a declared polarity, not independent evidence of the physical liquid surface. Any smoothing or morphology must be recorded as a separate parameter revision, because it may remove a small genuine transition or connect unrelated regions.

Record the contrast workbook

Use the contrast workbook to join each lighting configuration to a container identity, image identity, ROI coordinates, polarity and observability result. Include a reason when the image contains competing edges instead of forcing a coordinate into the numeric column. Keep the synthetic calculations in their own worksheet and label them as illustrations. The table below distinguishes a stable unique boundary from ambiguous or missing information. Its example ratios demonstrate coordinate arithmetic only; they do not prescribe acceptance limits for a customer container. A reproducible trial must retain failures and complete sample groups, including the empty controls and the container designs that did not support the proposed lighting route.

Synthetic coordinate and observability worksheet; not volume or production limits
Input conditionRecorded proxyDisposition
ROI height 20 px; unique edge y=80.6Illustrative observable boundary
ROI height 20 px; unique edge y=140.3Illustrative lower visible level
Equally plausible liquid edgesNo trusted coordinateReview ambiguity; do not select the passing edge
Boundary hidden by label or saturationNo trusted coordinateRetain unobservable state; do not infer volume

Reject ambiguous boundaries

A result with equally plausible boundaries should be retained for review, not resolved by choosing whichever coordinate would pass. The source-reviewed fixed-station case treats equally strong liquid edges as Review; it does not infer a hidden correct surface. In a proposed production trial, define the ambiguity rule before examining acceptance answers. A second edge caused by foam, wall glare or a sloshing surface may require a changed capture condition or another sensor. Raising a contrast threshold until only the convenient edge remains is not a valid correction unless it is tested against all frozen defect and unobservable groups.

A controlled lighting comparison

Keep container and acquisition controls fixed while comparing original boundary evidence.

  1. Identify container and reference class
  2. Capture baseline and candidate light
  3. Compare unique and competing boundaries
  4. Freeze configuration or retain ambiguity
Proposed experiment, not a measured production result.
View full-size diagram

Freeze lighting and ROI

Freeze lighting geometry, warm-up behavior, exposure, ROI coordinates, polarity and the observability rule when the paired evidence supports a repeatable boundary. Preserve the baseline as well as the selected candidate so the next engineer can reproduce the comparison. Proceed to a saved-image workflow only after the original images meet the agreed observation condition; an algorithm cannot recover a boundary that lighting and capture did not reveal. Deyi Vision workflow evaluation requires the actual supported node and runtime to be checked for the project. This article specifies a lighting experiment and coordinate proxy, not a completed line test, ready browser executor or guarantee of fill volume.

Sources and technical references

These references explain the methods and limits used in this tutorial. Example checks are guidance; production acceptance requires evidence from your own samples.

  1. Image ThresholdingOpenCV

    Threshold polarity and grayscale input conventions; the paired lighting protocol is a proposed station experiment.

    Checked
  2. Contours: Getting StartedOpenCV

    Binary foreground conventions and preserving the source image while analyzing derived boundaries.

    Checked
  3. Deyi Vision Vision WorkbenchDeyi Vision

    Supported saved-image trials require recorded settings and a separate project-specific integration check.

    Checked

Engineering review

Bring the inspection problem and the evidence.

Send sample images, your current setup and the check that failed. Include field of view, working distance, line speed and acceptance criteria for a practical review.

Send samples for engineering review
Contact

Direct RFQ contact

Talk to engineering about the inspection problem.

Send sample images, competitor model, FOV, working distance and line speed before model selection.

Target: selection brief within 24h
Send sample images