OptrisOptrisDocumentation

Documentation/OTC SDK/OTC SDK — C++ API referencev12.0

optris::sdk::Optics

The lens: whether it can be focused, and where.

Everything else that used to be here has gone somewhere it actually belongs. The temperature range and the operation mode are the first things anyone asks a thermal camera, so they are on the camera itself. Detector heating went to Detector(), next to the shutter -- both exist because the detector drifts. One-point calibration went to Radiometry(), with the other corrections. Sub-sampling went to ProcessingConfig, because deciding how many frames arrive is a property of the delivery path.

A handle, not an owner. It refers to one imager's optics and is valid while that imager is. Reached through Imager::Optics(), the way Imager::GetPif() reaches the process interface.

Everything here is a property of the physical camera rather than of the processing pipeline.

Public functions

Optics

Optics(ClientBridge *bridge)

Wraps the imager's shared state. Constructed by the SDK; get one from Imager::Optics() rather than building it yourself.

GetCapability

auto GetCapability() const -> FocusCapability

Whether this camera's lens can be driven at all.

Ask this first. It is the only member here that answers on every camera; the three below refuse on one with no motor. It never throws, so it is safe to call on a camera that is not open, where it reports FocusCapability::kUnknown.

Use IsFocusable() on the result rather than comparing it yourself: kUnknown is not "no", and treating it as one hides the focus control on a camera that simply has not been opened yet.

Latched when the camera opens, from the same capability flag the refusal below is decided on, so this and the calls below cannot disagree.

GetDiagnosis

auto GetDiagnosis() const -> std::string

Why, in words: for the tooltip on a disabled focus control, and for a support report. Never empty.

SetFocus

void SetFocus(float fraction)

Focus as a fraction of the lens's travel: 0.0 is the near end of GetFocusRange() and 1.0 the far end.

The way to offer focus to a person. The motor's step units differ between models (an Xi 410 travels 1194..2903, an Xi 400 912..3184) and mean nothing to a user; a fraction means the same on every lens. The SDK maps it onto the travel the camera reports and rounds it to the nearest step. Use SetFocusPosition() only to repeat an exact step saved from GetFocusPosition().

Like SetFocusPosition(), it returns as soon as the command is on the wire; the lens takes seconds to get there. See GetTargetPosition().

Exceptions

Name Description
InvalidArgumentException if fraction is outside 0.0 to 1.0, or not a number. Nothing is sent to the lens.
FeatureNotSupportedException if this camera has no focus motor, or is not open.
DeviceException if the motor could not be reached.

GetFocus

auto GetFocus() -> float

Where the lens is now, as a fraction of its travel: 0.0 at the near end of GetFocusRange(), 1.0 at the far end. The counterpart of SetFocus(), for showing a person where the focus is.

Read from the motor, so while the lens is still travelling after a SetFocus() it reports where the lens is, not where it is going. A lens that settles a few steps short of an end reads a little inside 0.0 or 1.0.

Exceptions

Name Description
FeatureNotSupportedException if this camera has no focus motor, or is not open.
DeviceException if the motor could not be reached.

SetFocusPosition

void SetFocusPosition(uint16_t position)

Drive the lens to an absolute position, in the motor's own step units. Out-of-range positions clamp to the travel.

Exceptions

Name Description
FeatureNotSupportedException if this camera has no focus motor, or is not open. Ask GetCapability() before offering the control, and the exception never arises.
DeviceException if the motor could not be reached.

GetFocusPosition

auto GetFocusPosition() -> uint16_t

Where the lens is now, in the same motor step units SetFocusPosition() takes -- not millimetres and not a distance. The step is the lens's own unit and means nothing across models, so it is good for returning to a setting on the same camera and not for describing one.

Exceptions

Name Description
FeatureNotSupportedException if this camera has no focus motor, or is not open. It used to return 0 in that case, which is also a perfectly legal position on a camera that has one, so nothing could tell the two apart.
DeviceException if the motor could not be reached.

GetFocusRange

auto GetFocusRange() -> std::pair< uint16_t, uint16_t >

The travel available, as {near, far}, in those same step units.

Read from the camera. It used to be a fixed {0, 100} on every model, motorized or not, which made it a percentage under another name and gave a resolution of one percent -- coarser than any motor the SDK drives.

Exceptions

Name Description
FeatureNotSupportedException if this camera has no focus motor, or is not open.
DeviceException if the motor could not be reached.

GetTargetPosition

auto GetTargetPosition() -> uint16_t

The position last asked for: where the lens is heading.

A focus command does not wait for the lens. SetFocusPosition() returns as soon as the command is on the wire, and the motor takes seconds to cross its travel -- 1.9 s for a two-thirds traverse, measured on an Xi 400. GetFocusPosition() read straight afterwards therefore reports where the lens was, which looks exactly like the command having been ignored and makes a slider bound to it snap back under the user's hand.

Bind your control to this and it stays where the user put it; poll GetFocusPosition() beside it and watch the lens walk there.

Do not poll for the position to equal the target. How close the lens ends up is a property of the motor, and on one of the two families measured it never reaches the number at all:

  • Xi 400 (serial 21074191, travel 912..3184): settles within 4 steps of the target and jitters there. Equality was reached on 4 of 4 commanded end-stop traverses.
  • Xi 410 (serial 26074397, travel 1194..2903): settles within 3 steps at the near end stop, but stops 4 to 8 steps short of the far one -- measured 5, 4, 4 and 8 on four traverses, and never equal to it. A loop waiting for equality runs until its own timeout on a lens that arrived seconds earlier.

So the lens has arrived when the position stops changing, not when it reaches a particular number. Read it twice a settle interval apart and compare the two readings against a small tolerance -- about 10 steps covers both families above.

The interval matters as much as the tolerance, and is the easier of the two to get wrong. A focus command does not take effect instantly; the lens takes a moment to start. Two reads close together both catch it still stationary, which is indistinguishable from a lens that has finished. Polling every 37 ms declared arrival with the motor still running on 3 of 4 traverses on the Xi 410 over Ethernet (two of them 1677 and 1695 steps from the target) and on 2 of 4 on the Xi 400 over USB (one 2199 steps away).

Polling every 400 ms was correct on 4 of 4 traverses on each camera: 8 of 8 across both.

There is deliberately no call that blocks until arrival, and none that reports "moving". Blocking would hold a caller for seconds and break the one-second bound every other command on this camera keeps. As for "moving": the camera's FM_GET answer carries a motion byte, and on the Xi 400 measured it reads 1 permanently -- with the lens stationary, in flight, and twenty seconds after arrival alike. Exposing it would be a call that reports something it cannot actually determine, so it is left unexposed until somebody establishes what that field really does.

Reports 0 when nothing has been commanded since the camera opened.

Exceptions

Name Description
FeatureNotSupportedException if this camera has no focus motor, or is not open.