Building a Vision System Pipeline: Lessons from Monet's Observation Method
A practical guide to building a computer vision pipeline. Learn how to define scene samples, design layered architectures with data contracts, and run versioned experiments inspired by Claude Monet's method of controlled observation. Includes Python code and field-level compatibility strategies.
1. Define Scene Samples First, Then Talk About Algorithms
When Monet painted the same stretch of water, he focused on the overall relationship between light and color rather than fixed outlines. In engineering terms, this means the requirements phase should answer three questions first: which environmental variables change the observation, which viewpoints and capture parameters will be used, and which quality dimensions must be recorded. If a requirement is written only as “detect an object,” the team will be unable to pinpoint which layer failed once the system goes live and encounters lighting changes, occlusion, or hardware differences.
A good practice is to define a single observation as a SceneSample. Every field should specify its type, unit, and value range. Missing values should be uniformly represented as None—never as 0—otherwise downstream components will treat “unknown” as “genuinely zero.”
from dataclasses import dataclassfrom typing import Optional, Protocolimport numpy as npclass FeatureError(Exception):"""A known failure type in the feature layer; the caller decides whether to degrade."""@dataclass(frozen=True)class Lighting:intensity_lux: float # Illuminance in lux, range [0, 100000]color_temp_k: float # Color temperature in K, range [2000, 10000]direction_deg: Optional[float] # Dominant light direction in degrees, range [0, 360); None if unestimable@dataclass(frozen=True)class Capture:width: int # Image width in pixelsheight: int # Image height in pixelsexposure_ms: float # Exposure time in millisecondsnoise_sigma: Optional[float] # Estimated noise standard deviation; None if not estimatedcolor_space: str # Enum, e.g. "sRGB", "Rec.709"@dataclass(frozen=True)class SceneSample:sample_id: str # Globally unique; UUID v4 recommended; immutable after creationtimestamp_utc: str # ISO 8601 format, e.g. "2026-11-24T06:17:13Z"lighting: Optional[Lighting]capture: Captureroi: tuple[int, int, int, int] # Region of interest (x, y, w, h) in pixel coordinatesdataset_version: str # Dataset version, following MAJOR.MINOR.PATCHclass Feature(Protocol):name: strversion: strdef extract(self, image: np.ndarray, light: Optional[Lighting]) -> np.ndarray: ...@dataclassclass ColorLayer:layer_id: str # Suggested format: "{sample_id}:{feature_name}:{feature_version}"feature_name: strfeature_version: strdata: Optional[np.ndarray] # None on failureconfidence: float # Range [0, 1]status: str # "ok" | "failed" | "skipped"error: Optional[str] = Nonedef estimate_lighting(image: np.ndarray) -> tuple[Optional[Lighting], float]:"""Returns the lighting estimate and its confidence. Returns (None, 0.0) if unestimable."""...def build_layers(sample: SceneSample, image: np.ndarray,pipeline: list[Feature]) -> list[ColorLayer]:if image.ndim not in (2, 3):raise ValueError(f"image must be 2- or 3-dimensional, got {image.ndim}")base = normalize(image, sample.capture) # Project function: denoise and convert to a unified color spacelight, light_conf = estimate_lighting(base)if light is None:light_conf = 0.0 # Continue with unknown lighting, but flag it in the quality layerlayers = []for feature in pipeline:layer_id = f"{sample.sample_id}:{feature.name}:{feature.version}"try:data = feature.extract(base, light)layers.append(ColorLayer(layer_id, feature.name, feature.version,data, light_conf, "ok"))except FeatureError as exc: # A single feature failure does not halt the pipelinelayers.append(ColorLayer(layer_id, feature.name, feature.version,None, 0.0, "failed", str(exc)))return layers
Three points in this code are key. First, input validation happens at the pipeline entry. Second, when lighting estimation fails, the pipeline keeps running with confidence lowered to 0, and the quality layer handles it centrally. Third, individual feature failures are isolated, so results from other layers remain usable.
2. Layered Architecture and Data Contracts: What Connects the Layers
Layering exists so that components can be replaced locally. If lighting estimation becomes unstable, you swap only the estimation module without touching the decision layer. To achieve this, adjacent layers must be connected by stable data contracts. The table below lists the inputs, outputs, and mandatory constraints for each layer.
| Layer | Input | Output | Mandatory Constraints |
|---|---|---|---|
| Capture & Preprocessing | Raw image, Capture | Normalized image | Unified color space; denoising parameters written into sample metadata |
| Feature | Normalized image, Lighting | List of ColorLayer | Each feature carries name and version; failures must set status |
| Decision | List of ColorLayer | Result and confidence | Confidence must be within [0, 1]; out-of-range values rejected outright |
| Quality | Decision results, sample annotations | Metrics and alerts | Metrics grouped by lighting and device, not just overall averages |
Field-level contracts should be documented just as precisely. The table below works well for interface handoffs across teams.
| Field | Type | Required | Compatibility Policy |
|---|---|---|---|
| sample_id | string | Yes | Immutable; any content change requires a new sample_id |
| dataset_version | string | Yes | Adding fields is a MINOR upgrade; deleting or redefining is a MAJOR upgrade |
| color_space | enum | Yes | When new enum values are added, legacy consumers must treat unknown values as failed |
| confidence | float, range [0, 1] | Yes | Out-of-range records are rejected outright and logged |
| status | enum | Yes | Same as above; unknown values degrade to failed |
The key point in the compatibility column: fields may only be added, never silently redefined. Redefinition causes older consumers to produce wrong results without raising errors—this is the hardest class of bug to debug.
3. Versioned Experiments: Controlled Comparison, the Way Monet Painted Series
Monet painted series around a single subject, changing exactly one condition per painting, so differences could be attributed. Engineering experiments should follow the same principle. Change only one factor per experiment—such as the preprocessing version, feature combination, or threshold—and keep everything else fixed. Experiment results must be traceable to specific dataset versions,
