Files
UA-.NETStandard/samples/Vision/VisualInspectionCell
Marc Schier 7e25e1a3d7 Extract remaining shared companion, rendering and packaging changes (#4806)
# Description

The shared AI deployment contracts and instance registration; DI
software-upload outcomes, digest handling and simulator; bounded
Positioning/Pumps reads; PubSub raw-data/matrix and security-provider
handling; Vision read-quality contracts; xRegistry resource writes and
instance projection; OpenUSD authoring, embedded viewport and
retained-frame capture APIs; standalone sample CLI controls; and the
generic Debug/RID package-policy and fork/Dependabot coverage-comment
fixes. The Linux native prerequisite step is retained for **Vision tests
only**.

## Related Issues

- Related tracking issue:
[#4461](https://github.com/OPCFoundation/UA-.NETStandard/issues/4461),
without automatic closure.
- Source work:
[#4462](https://github.com/OPCFoundation/UA-.NETStandard/pull/4462),
which remains intact for the coordinator's later integration.
- Immediate stacked predecessor:
[#4804](https://github.com/OPCFoundation/UA-.NETStandard/pull/4804).

## Checklist

_Put an `x` in the boxes that apply. You can complete these step by step
after opening the PR._

- [ ] I have signed the
[CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf)
and read the
[CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md)
doc.
- [ ] I have added tests that prove my fix is effective or that my
feature works and increased code coverage.
- [x] I have added all necessary documentation.
- [ ] I have verified that my changes do not introduce (new) build or
analyzer warnings.
- [ ] I ran **all** tests locally using the **UA.slnx** solution against
at least .net **framework** and .net **10**, and all passed.
- [ ] I fixed **all** failing and flaky tests in the CI pipelines and
**all** CodeQL warnings.
- [ ] I have addressed **all** PR feedback received.
2026-10-17 07:52:02 +02:00
..

Visual Inspection Cell

VisualInspectionCell is the server half of the visual-inspection sample. It hosts one address space containing four companion areas:

  • Vision — BracketFixtureCamera, the FixtureImages inline PNG clip endpoint, and BracketInspectionPipeline.
  • AI Model Management — the visual-inspection-primary deployment, a learning job, and the Invoke path used for model provenance.
  • ISA-95 Job Control V2 — an allowlisted inspection order and a rework/reject order.
  • Alarms & Conditions — OperatorDispositionDialog, a DialogConditionType used when a result is not decidable.

The server is intentionally a host for companion composition, not the owner of the production decision loop. The paired VisualInspectionAgent connects as an external orchestrator and drives the cycle with typed clients.

graph TD
    Server["VisualInspectionCell server"]
    Vision["Vision root"]
    Sensor["BracketFixtureCamera<br/>ImageSensorType"]
    Clip["FixtureImages<br/>inline PNG clips"]
    Pipeline["BracketInspectionPipeline<br/>InferencePipelineType"]
    AI["AI Model Management<br/>deployment + learning job"]
    Jobs["ISA-95 Job Control V2<br/>fixed order catalogue"]
    Dialog["OperatorDispositionDialog<br/>DialogConditionType"]

    Server --> Vision
    Vision --> Sensor
    Sensor --> Clip
    Vision --> Pipeline
    Pipeline -->|"Deployment"| AI
    Pipeline -->|"LearningJob"| AI
    Server --> Jobs
    Server --> Dialog

Running

Prerequisites: .NET 10 SDK.

dotnet run --project samples\Vision\VisualInspectionCell\VisualInspectionCell.csproj -- --insecure

The default endpoint is opc.tcp://localhost:62865/VisualInspectionCell. --host <name> and --port <number> configure the endpoint host and port. The anonymous operator role is mapped for the local sample.

--insecure is a demo convenience. It accepts untrusted certificates and must not be used for production systems.

It is also, in practice, required to run the pair on a fresh machine. The flag sets AutoAcceptUntrustedCertificates on the server, and without it the cell rejects the agent's self-signed certificate with BadCertificateUntrusted and the agent fails with BadNotConnected - which reads like a connectivity problem rather than a trust one. Start both halves with --insecure, or trust the agent's certificate in the server's PKI store first.

Startup options

Option Meaning
--host <name> Endpoint host name. Default localhost.
--port <number> Endpoint port. Default 62865.
--inferenceLocation OnServer|EdgeOffServer Selects the advertised Vision inference location. Default OnServer.
--insecure Demo-only certificate convenience.
--pki-root <absolute-path> Use a private certificate-store root instead of the hosting default. Does not enable automatic peer trust.
--run-seconds <1-3600> Stop the hosted server after a bounded run. Omit for the normal interactive lifetime.

For an owned, non-rendering qualification run, select a private PKI root and an unused loopback port, without --insecure:

dotnet run --project samples\Vision\VisualInspectionCell\VisualInspectionCell.csproj -- `
  --host 127.0.0.1 --port 62865 --pki-root D:\owned-vision-run\pki --run-seconds 120

Establish trust explicitly in the client's and server's private peer stores before connecting with SignAndEncrypt. The cell uses checked-in PNG fixtures and an in-process backend; it does not need a camera, media download, renderer or GPU.

Fixtures and measurement

The cell serves three 800 x 600 PNG fixtures from Fixtures/ through the Vision media provider. The camera scale is 10 px/mm, so one pixel is 0.10 mm. That one-pixel pitch is carried as VisionCharacteristicDataType.Uncertainty; it is not invented to force a result.

Fixture Why it exists
bracket-ok.png Bore diameter is 12.00 mm, so the interval [11.90, 12.10] is wholly inside [11.80, 12.20].
bracket-not-ok.png Bore diameter is 12.60 mm, so the interval [12.50, 12.70] is wholly outside the bore tolerance.
bracket-ambiguous.png The intended slot is 8.15 mm, but at 10 px/mm it draws as 81.5 px and can only be represented as 8.10 mm. The interval [8.00, 8.20] straddles the 8.15 mm upper limit.

What the cell publishes

  • BracketFixtureCamera (ImageSensorType) with simulated reality, RGB8, 800 x 600 resolution, 10 px/mm intrinsics, and fixture_table as the frame id.
  • FixtureImages, an inline PNG clip endpoint with endpoint URI opcua-inline://visual-inspection-cell/fixtures.
  • BracketInspectionPipeline, bound to the camera, an AI deployment, a learning job, VisualInspectionInferenceProvider, and VisualInspectionFeedbackSink.
  • A fixed ISA-95 V2 catalogue with VIS-INSP-BRACKET-001 and VIS-REWORK-REJECT-001. InspectionJobControlProvider rejects any other job order id instead of accepting invented payloads.
  • OperatorDispositionDialog, the human-disposition condition the agent uses when the deterministic rule returns NotDecidable.

The fixture clip endpoint and pipeline advertise Ready after their in-process providers are attached. GetClip selects a fixture by its file name or a known published ResultId; RunInference requires an explicit acquisition timestamp for stable result correlation. The sample does not implement continuous inference.

Deliberately not implemented

The sample publishes and counts learning samples, but it does not pretend to retrain a model or promote a candidate. That is the same line taken by the AI Model Management sample: a simulated MLOps loop would mislead readers about the part of the specification a sample cannot honestly demonstrate.