Client API. The Codename One framework your app is built on: this runs on the device, not in a backend.
public final class VisionOptions
- Object
- VisionOptions
Common analyzer configuration. An analyzer captures the supplied options when constructed; reuse it for frames needing the same backend, confidence threshold, and result limit.
ImageLabeler labeler = new ImageLabeler(new VisionOptions()
.minimumConfidence(0.6f) // drop guesses below 60%
.maximumResults(5)); // keep the top five labelsThe analyzer snapshots these values, so mutating the options object
afterwards changes nothing – construct a second analyzer instead. Not
every analyzer reads every setting: textScript(TextScript) applies
only to TextRecognizer, and a backend may ignore a limit it has no
way to enforce.
Constructors
public VisionOptions() |
Methods
Inherited methods
Constructor details
VisionOptions
public VisionOptions()Method details
backend
public VisionOptions backend(VisionBackend value)Parameters
valueVisionBackend- selector, or
nullto restore automatic selection
Returns
textScript
public VisionOptions textScript(TextScript value)TextRecognizer should read. Analyzers
other than the text recognizer ignore it.Parameters
valueTextScript- script selector, or
nullfor the platform default (Latin)
Returns
minimumConfidence
public VisionOptions minimumConfidence(float value)Parameters
valuefloat- requested threshold
Returns
Throws
IllegalArgumentException- if
valueis NaN
maximumResults
public VisionOptions maximumResults(int value)Parameters
valueint- requested limit
Returns
barcodeFormats
public VisionOptions barcodeFormats(String... values)Limits BarcodeScanner to the given BarcodeFormat
constants. The platform detector is configured with only these
symbologies, so it neither spends frame time on formats the application
will never accept nor reports one of them by mistake – which matters
most for dense codes such as PDF417, where every frame counts.
Analyzers other than the barcode scanner ignore it, as does a backend
with no way to restrict its detector (it still reports every format).
CodeScannerOptions.formats(String...) sets this for the
scanner it opens, so a CodeScanner caller does not need both.
Parameters
valuesString...- format constants; empty or
nulldetects every format the backend supports
Returns
strictBarcodes
public VisionOptions strictBarcodes(boolean value)Makes a BarcodeScanner report a code only once two frames have
read it identically. By default this applies to PDF417 codes in camera
frames alone, and every other code, and any code in a still image, is
reported as soon as it decodes;
true extends it to every symbology, false turns it off
for PDF417 as well.
Turn this on for codes printed with little or no error correction. A PDF417 at error correction level 0 carries two check codewords, which is enough to “correct” one wrong codeword but not to notice when a blurred frame got several wrong: the decoder then repairs the frame into a different, valid-looking payload with a few wrong characters. That happens on a measurable share of frames, and differently on each, so two frames that agree byte for byte filter those reads out, at the cost of one more frame.
This is state kept by the scanner between calls to
BarcodeScanner.process(VisionImage), which is what a camera
pipeline (VisionCameraView, CodeScanner) does once per
frame. A frame with no code keeps the pending read for up to 15 frames,
and every code in a
frame is checked against every code of the pending frame, so codes in
view whose order changes between frames still confirm. With this set to
true a single still image processed once reports nothing.
Parameters
valueboolean- whether a code must be read identically twice
Returns
isStrictBarcodes
public boolean isStrictBarcodes()Returns
isStrictBarcode(String) for the PDF417 defaultisStrictBarcode
public boolean isStrictBarcode(String format)strictBarcodes(boolean) was called, that is true of
PDF417 alone: it is the symbology printed at error correction level 0
(payment slips), where a blurred frame decodes into a plausible wrong
payload on a large share of frames.Parameters
formatString- a
BarcodeFormatconstant
Returns
getBarcodeFormats
public String[] getBarcodeFormats()Returns
getBackend
public VisionBackend getBackend()Returns
nullgetMinimumConfidence
public float getMinimumConfidence()Returns
getMaximumResults
public int getMaximumResults()Returns
getTextScript
public TextScript getTextScript()Returns
null for the platform
default