API Response Structure

API Response Structure

The function
onResults
takes only one argument. This argument contains the output structure of all tools in the current job.
The
tool_results
and
tool_results_by_names
fields contain tools that display in the job but allow access to them differently. For example,
tool_results
is a list of tools where each index already has a defined tool type. In cases where the engine does not yet support the tools, the index takes the value
null
. The tools are sorted in the order they display in the job.
tool_results_by_names
allows access to tools by their name, using dot notation, and support from IntelliSense, so
tool_results_by_names .my_tool
is the correct syntax. In
tool_results_by_names
, only currently supported tools display after their names. When FlowBuilder uses multiple tools, each tool is accessible by its friendly name.
A friendly name might contain characters that are not valid as part of a JavaScript variable name. In this case, all invalid characters are replaced with underscore characters. In some instances, two tools might have the same JavaScript name (for example, friendly names were
tool!
and
tool@
and both got translated to
tool\_
). In this case, the red triangle with an exclamation mark displays on the top right side of the editor (right before the script enabling switch). The warning sign explains which tools have a naming collision and which friendly names can be changed.
The descriptions of both fields are generated dynamically during job editing. As a result, changing the tool or its order generates IntelliSense errors at the script editing stage.
Only incoming data from the following tools is supported:
  • Identification and OCR Tools
    • Read Barcode (
      IBarcodeResultArguments
      )
    • Read DPM (
      IBarcodeResultArguments
      )
    • Read DPM & Barcode (
      IBarcodeResultArguments
      )
    • Datacode (
      IDatacodeResultArguments
      )
    • Deep Learning OCR (
      IDeepLearningOcrResultArguments
      )
    • Classification (
      IClassifyObjectResultArguments
      )
    Classification is available with the following licenses:
    • NS42 - Essential Toolset (Machine Vision) with Deep Learning MV Tools (LIC-DL002-0100
    • FS42 - Deep Learning Anomaly Detection, Classification and MV Standard Upgrade License (LIC-DL003-0100)
  • Image Pre-Processing and Enhancement
    • Brightness (
      IBrightnessResultArguments
      )
    • Contrast (
      IContrastResultArguments
      )
    • Binarization (
      IBinarizationResultArguments
      )
    • Morphological Tools (
      IFilterResultArguments
      )
    • Gradient Full (
      IGradientFullResultArguments
      )
    • Gradient Horizontal (
      IGradientHorizontalResultArguments
      )
    • Gradient Vertical (
      IGradientVerticalResultArguments
      )
  • Edge Tools and Feature Location
    • Locate Edge (
      IEdgeResultArguments
      /
      ILocateEdgeResultArguments
      )
    • Edge Detect (
      IEdgeResultArguments
      )
    • Edge Count (
      IEdgeCountResultArguments
      )
  • Blob Analysis and Counting
    • Pixel Count (
      IPixelCountResultArguments
      )
    • Blob Count (
      IBlobCountResultArguments
      )
    • Blob Presence/Absence (
      IBlobPAResultArguments
      )
    • Blob Location (
      IBlobLocateResultArguments
      )
  • Pattern Match and Object Count
    • Pattern Match (
      IPatternMatchResultArguments
      )
    • Pattern Match Plus (
      IPatternMatchPlusResultArguments
      )
    • Object Count (
      IObjectCountResultArguments
      )
  • Measurement
    • Measure Distance (
      IDistanceMeasurementResultArguments
      )
    • Measure Width (
      IMeasureObjectWidthResultArguments
      )
  • Flaw and Anomaly Detection
    • Edge Detection (
      IFlawDetectionEdgesResultArguments
      )
    • Intensity Detection (
      IFlawDetectionIntensityResultArguments
      )
    • Anomaly Detection (
      IAnomalyDetectionResultArguments
      )
These tools share a common type and display in the argument in the same order as in Aurora Focus.
The following code snippet describes the input argument in TypeScript. In a typical development process, it is recommended to use the field subtitles feature in the editor.
    
interface IJobInformationArguments { name: string; start_time: string; acquisition_images_count: number; metrics: IMetricsArguments; }
    
interface IMetricsArguments { trigger_counts: number; trigger_overruns: number; total_pass: number; total_fail: number; job_time_min: number; job_time_max: number; job_time_average: number; }
The
job_success
field indicates if the job was completed successfully. The script can override this value using an output structure.
    
interface IMainArguments { tool_results: TOOL_RESULTS_TYPE[]; tool_results_by_names: TOOL_RESULTS_BY_NAMES_TYPE; job_info: IJobInformationArguments; job_success: boolean; }
The following code snippet describes definitions for additional types.

Identification & OCR (Data Capture)

The
IBarcodeResultArguments
interface in TypeScript defines the structure for barcode scanning results.
It includes the following properties:
  • time: number;
    this number indicates the time a tool or process takes, such as image acquisition.
  • tool_time: number;
    similar to
    time
    , this is a number that might indicate the time taken by a tool or process.
  • success: boolean;
    indicates whether a specific operation or process was successful (
    true
    ) or not (
    false
    ).
  • decode_time: number;
    represents the time taken to decode a barcode.
  • decode_count: number;
    represents the count of successful decodes.
  • decode_totalcount: number;
    represents the total count of attempted decodes, successful or not.
  • decodes: IDecodeArguments[];
    an array of objects that conform to the
    IDecodeArguments
    interface. Each element in this array represents a decoded result, and
    IDecodeArguments
    would be another interface that describes the structure of these decoded results.
  • unmatched_decodes: IDecodeArguments[];
    similar to
    decodes
    , but the codes that do not match the pattern specified in the tool have been detected.
  • statistics: IStatisticsArguments;
    contain the tool's execution statistics accumulated between operations.
    
interface IBarcodeResultArguments { time: number; tool_time: number; success: boolean; decode_time: number; decode_count: number; decode_totalcount: number; decodes: IDecodeArguments[]; unmatched_decodes: IDecodeArguments[]; statistics: IStatisticsArguments; }
The
IDecodeArguments
interface defines the structure of an object representing the result of a decoding process, such as decoding a barcode.
  • value: string;
    represents the decoded value, such as the data extracted from a barcode.
  • raw_value: number[];
    represents the decoded value, such as the data extracted from a barcode in ASCII codes.
  • symbology: string;
    indicates the type or format of the decoded code, such as QR or Code128.
  • position: IPointArguments[];
    an array of
    IPointArguments
    objects, each representing a point in two-dimensional space. It typically denotes the positions or corners of the decoded symbol within an image or a scanning field.
  • ppm: number | null;
    represents pixel per module, which is used to measure barcode module density in the images being decoded. It can also be
    null
    , indicating that this information is not available or applicable.
  • score: IDecodeBQMArguments | null;
    an object conforming to the
    IDecodeBQMArguments
    interface, representing the quality score of the decoding process. It can also be
    null
    , indicating that a score is not available or applicable.
    
interface IDecodeArguments { value: string; raw_value: number[]; symbology: string; position: IPointArguments[]; ppm: number | null; score: IDecodeBQMArguments | null; }
The
IDecodeBQMArguments
interface in TypeScript defines the structure for an object representing Barcode Quality Metrics (BQM). Each property typically involves quality grading, using the
IQualityGradeArguments
interface, and provides a numerical grade and a letter grade.
    
interface IDecodeBQMArguments { overall_grade: IQualityGradeArguments; decodability: IQualityGradeArguments | null; decode: IQualityGradeArguments; defects: IQualityGradeArguments | null; minimum_edge_contrast: IQualityGradeArguments | null; modulation: IQualityGradeArguments; symbol_contrast: IQualityGradeArguments; quiet_zone: IQualityGradeArguments | null; left_quiet_zone: IQualityGradeArguments | null; right_quiet_zone: IQualityGradeArguments | null; wide_to_narrow_ratio: IQualityGradeArguments | null; inter_char_gap_2_narrow: IQualityGradeArguments | null; max_pixel_value_in_extended_area: number | null; maximum_reflectance: IQualityGradeArguments | null; minimum_reflectance: IQualityGradeArguments | null; unused_error_correction: IQualityGradeArguments | null; fixed_pattern_damage: IQualityGradeArguments | null; axial_nonuniformity: IQualityGradeArguments | null; grid_nonuniformity: IQualityGradeArguments | null; contrast_uniformity: IQualityGradeArguments | null; reflectance_margin: IQualityGradeArguments | null; horizontal_print_growth: IQualityGradeArguments | null; vertical_print_growth: IQualityGradeArguments | null; }
The
IDeepLearningOcrResultArguments
interface in TypeScript defines the structure for deep learning-based OCR results. It includes the following properties:
  • time: number;
    a number that might indicate the time a tool or process takes, such as image acquisition.
  • tool_time: number;
    similar to time, this number might indicate the time taken by a tool or process.
  • success: boolean;
    indicates whether a specific operation or process was successful (true) or not (false).
  • characters: ICharacterResultArguments[];
    an array of ICharacterResultArguments objects, each representing a decoded character.
  • ocr_result: string;
    represents the decoded characters.
  • statistics: IStatisticsArguments;
    contain the tool's statistics accumulated between operations.
    
interface IDeepLearningOcrResultArguments { time: number; tool_time: number; success: boolean; characters: ICharacterResultArguments[]; ocr_result: string; statistics: IStatisticsArguments; }
The
ICharacterResultArguments
interface defines an object structure representing a decoded character. It includes the following properties:
  • value: string;
    represents the decoded character.
  • roi: IPointArguments[];
    an array of IPointArguments objects, each representing a point in a two-dimensional space. It typically denotes the positions or corners of the decoded character.
  • confidence: number;
    represents the confidence of the character.
  • quality: number;
    represents the quality of the character.
  • height: number;
    represents the height of the character.
  • is_part_of_result_string: boolean;
    indicates if a character is contained in the result string.
    
interface ICharacterResultArguments { value: string; roi: IPointArguments[]; confidence: number; quality: number; height: number; is_part_of_result_string: boolean; }

Image Pre-processing & Enhancement

The
IBrightnessResultArguments
interface in TypeScript defines the structure for brightness tool results. The brightness tool measures the average pixel intensity within a region of interest. It includes the following properties:
  • time
    : number; this number indicates the time taken by a tool or process, including image acquisition.
  • tool_time
    : number; similar to time, this number indicates the time required by a tool or process.
  • success
    : boolean; indicates whether a specific operation or process was successful (true) or not (false).
  • value
    : number; represents the measured brightness value (average pixel intensity) in the region of interest.
  • minimum_threshold
    : number; indicates the minimum acceptable brightness threshold for pass/fail evaluation.
  • maximum_threshold
    : number; indicates the maximum acceptable brightness threshold for pass/fail evaluation.
  • statistics
    :
    IStatisticsArguments
    ; contain the tool's statistics accumulated between operations.
    
interface IBrightnessResultArguments { time: number ; tool_time: number ; success: boolean ; value: number ; minimum_threshold: number ; maximum_threshold: number ; statistics: IStatisticsArguments; }
The
IContrastResultArguments
interface in TypeScript defines the structure for contrast results. It includes the following properties:
  • time: number;
    indicates the time taken by a tool or process including image acquisition.
  • tool_time: number;
    similar to time, this number indicates the time taken by a tool or process.
  • success: boolean;
    indicates whether a specific operation or process was successful (true) or not (false).
  • value: number;
    indicates contrast value.
  • minimum_threshold: number;
    indicates the minimum threshold value set in the tool configuration.
  • maximum_threshold: number;
    indicates the maximum threshold value set in the tool configuration.
  • minimum_calculation_value: number;
    indicates the minimum pixel value.
  • maximum_calculation_value: number;
    indicates the maximum pixel value.
  • statistics: IStatisticsArguments;
    contain the tool's statistics accumulated between operations.
    
interface IContrastResultArguments { time: number; tool_time: number; success: boolean; value: number; minimum_threshold: number; maximum_threshold: number; minimum_calculation_value: number; maximum_calculation_value: number; statistics: IStatisticsArguments; }
The IBinarizationResultArguments interface in TypeScript defines the structure for binarization tool results. Binarization converts a grayscale image into a binary (black-and-white) image using specified threshold values. It includes the following properties:
  • time
    : number; this number indicates the time taken by a tool or process, including image acquisition.
  • tool_time
    : number; similar to time, this number indicates the time taken by a tool or process.
  • success
    : boolean; indicates whether a specific operation or process was successful (true) or not (false).
  • minimum_threshold
    : number; indicates the minimum pixel intensity threshold used for binarization. Pixels with intensity values below this threshold are set to black (0).
  • maximum_threshold
    : number; indicates the maximum pixel intensity threshold used for binarization. Pixels with intensity values above this threshold are set to black (0).
  • statistics
    :
    IStatisticsArguments
    ; contains the tool's execution statistics accumulated between operations.
    
interface IBinarizationResultArguments { time : number ; tool_time: number ; success: boolean ; minimum_threshold: number ; maximum_threshold: number; statistics: IStatisticsArguments; }
Morphological Tools
Morphological operations are fundamental image processing techniques that process images based on shapes. These operations apply a structuring element to an input image to produce an output image. All morphological tools return results using the
IFilterResultArguments
interface.
The IFilterResultArguments interface in TypeScript defines the structure for morphological filter results. It includes the following properties:
  • time
    : number; this number indicates the time taken by a tool or process including image acquisition.
  • tool_time
    : number; similar to time, this number indicates the time taken by a tool or process.
  • success
    : boolean; indicates whether a specific operation or process was successful (true) or not (false).
  • statistics
    :
    IStatisticsArguments
    ; contain the tool's statistics accumulated between operations.
    
interface IFilterResultArguments { time : number ; tool_time: number ; success: boolean ; statistics: IStatisticsArguments; }
Morphological Erode
The morphological erode operation shrinks or thins objects in the foreground of an image. It removes pixels from object boundaries, causing bright regions to shrink and dark regions to grow. The erosion is performed using a structuring element that determines the extent of the erosion.
Common uses include:
  • Removing small bright details or noise.
  • Separating connected objects.
  • Shrinking object sizes.
  • Removing protrusions from object boundaries.
Returns:
IFilterResultArguments
Morphological Dilate
The morphological dilate operation expands or thickens objects in the foreground of an image. It adds pixels to object boundaries, causing bright regions to grow and dark regions to shrink. The dilation is performed using a structuring element that determines the extent of the dilation.
Common uses:
  • Filling small holes within objects.
  • Connecting nearby objects.
  • Expanding object sizes.
  • Bridging gaps between objects.
Returns:
IFilterResultArguments
Morphological Open
The morphological open operation is an erosion followed by a dilation. It is useful for removing small objects or noise from the foreground of an image while preserving the shape and size of larger objects. The open operation removes small bright regions that are smaller than the structuring element, while preserving the boundaries of larger bright regions.
Common uses:
  • Removing small bright spots or noise.
  • Smoothing object contours.
  • Breaking narrow connections between objects.
Returns:
IFilterResultArguments
Morphological Close
The morphological close operation is a dilation followed by an erosion. It is useful for closing small holes or gaps in the foreground of an image while preserving the shape and size of larger objects. The close operation fills dark regions smaller than the structuring element while preserving the boundaries of larger bright regions.
Common uses:
  • Filling small holes or gaps in objects.
  • Connecting nearby objects.
  • Smoothing object contours.
Returns:
IFilterResultArguments

Edge Tools & Feature Location

The
IEdgeResultArguments
interface in TypeScript defines the structure for edge detection results. It includes the following properties:
  • time: number;
    indicates the time taken by a tool or process, including image acquisition.
  • tool_time: number;
    similar to time, this number indicates the time taken by a tool or process.
  • success: boolean;
    indicates whether a specific operation or process was successful (true) or not (false).
  • edge_count: number;
    indicates the number of detected edges.
  • line_segments: ILineArguments[];
    an array of ILineArguments objects, each representing a line in two-dimensional space.
  • statistics: IStatisticsArguments;
    contain the tool's statistics accumulated between operations.
    
interface IEdgeResultArguments { time: number; tool_time: number; success: boolean; edge_count: number; line_segments: ILineArguments[]; statistics: IStatisticsArguments; }
The
ILineArguments
interface defines an object structure representing a line in a two-dimensional space. It includes two properties: point1 and point2, both are IPointArguments.
  • point1: IPointArguments;
    represents the line start point.
  • point2: IPointArguments;
    represents the line endpoint.
    
interface ILineArguments { point1: IPointArguments; point2: IPointArguments; }

Blob Analysis & Counting

The
IPixelCountResultArguments
interface in TypeScript defines the structure for pixel count tool results. The pixel count tool counts the number of pixels whose intensity values fall within a specified threshold range. It includes the following properties:
  • time
    : number; indicates the time taken by a tool or process, including image acquisition.
  • tool_time
    : number; similar to time, this number indicates the time taken by a tool or process.
  • success
    : boolean; indicates whether a specific operation or process was successful (true) or not (false).
  • pixel_count
    : number; indicates the total number of pixels within the specified threshold range.
  • minimum_threshold
    : number; indicates the minimum pixel intensity threshold. Pixels with intensity values at or above this value are counted.
  • maximum_threshold
    : number; indicates the maximum pixel intensity threshold. Pixels with intensity values at or below this value are counted.
  • statistics
    :
    IStatisticsArguments
    ; contains the tool's execution statistics accumulated between operations.
    
interface IPixelCountResultArguments { time : number ; tool_time: number ; success: boolean ; pixel_count: number ; minimum_threshold: number ; maximum_threshold: number ; statistics: IStatisticsArguments; }
The
IBlobCountResultArguments
interface in TypeScript defines the structure for blob count results. It includes the following properties:
  • time: number; this number indicates the time taken by a tool or process, including image acquisition.
  • tool_time: number; similar to time, this number indicates the time taken by a tool or process.
  • success: boolean; indicates whether a specific operation or process was successful (true) or not (false).
  • threshold: number; indicates the pixel intensity threshold used for blob detection.
  • blob_count: number; indicates the total number of blobs found.
  • statistics: IStatisticsArguments; contains the tool's execution statistics accumulated between operations.
    
interface IBlobCountResultArguments { time: number;tool_time: number;success: boolean;threshold: number;blob_count: number;statistics: IStatisticsArguments; }
The
IBlobPAResultArguments
interface in TypeScript defines the structure for blob presence/absence results. It includes the following properties:
  • time
    : number;  indicates the time taken by a tool or process, including image acquisition.
  • tool_time
    : number; similar to time, this number indicates the time taken by a tool or process.
  • success
    : boolean; indicates whether a specific operation or process was successful (true) or not (false).
  • threshold
    : number; indicates the pixel intensity threshold used for blob detection.
  • blob_count
    : number; indicates the total number of blobs found.
  • statistics
    : IStatisticsArguments; contain the tool's statistics accumulated between operations.
    
interface IBlobPAResultArguments { time: number;tool_time: number;success: boolean;threshold: number;blob_count: number;statistics: IStatisticsArguments; }
The
IBlobLocateResultArguments
interface in TypeScript defines the structure for blob location results. It includes the following properties:
  • time
    : number; indicates the time taken by a tool or process, including image acquisition.
  • tool_time
    : number; similar to time, this number indicates the time taken by a tool or process.
  • success
    : boolean; indicates whether a specific operation or process was successful (true) or not (false).
  • threshold
    : number; indicates the pixel intensity threshold used for blob detection.
  • blob_count
    : number; indicates the total number of blobs found.
  • matches:
    IBlobMatchResultArguments[]; an array of IBlobMatchResultArguments objects, each representing a single detected blob.
  • statistics
    : IStatisticsArguments; contain the tool's statistics accumulated between operations.
    
interface IBlobLocateResultArguments { time: number;tool_time: number;success: boolean;threshold: number;blob_count: number;matches: IBlobMatchResultArguments[];statistics: IStatisticsArguments; }
The
IBlobMatchResultArguments
interface defines an object structure representing a single detected blob. It includes the following properties:
  • angle_in_degrees
    : number; represents the orientation angle of the blob.
  • center_x:
    : number; represents the x-coordinate of the blob's geometric center.
  • center_y:
    : number; represents the y-coordinate of the blob's geometric center.
  • area
    : number; represents the total area of the blob in pixels.
  • major_axis_length
    : number; represents the length of the major axis of the blob.
  • minor_axis_length
    : number; represents the length of the minor axis of the blob.
    
interface IBlobMatchResultArguments { angle_in_degrees: number;center_x: number;center_y: number;area: number;major_axis_length: number;minor_axis_length: number; }

Pattern Matching & Object Counting

The
IPatternMatchResultArguments
interface in TypeScript defines the structure for <pattern match locate tool>, <pattern match tool>, and <locate objectcount> results. It includes the following properties:
  • time
    : number; indicates the time taken by a tool or process, including image acquisition.
  • tool_time
    : number; similar to time, indicating the time taken by a tool or process.
  • success
    : boolean; indicates whether a specific operation or process was successful (true) or not (false).
  • matches_count
    : number; indicates the number of matches.
  • matches
    : table of IMatchResultArguments; indicates the detail of each match. An
    IMatchResultArguments
    is composed of:
    • roi: IRegionArguments, information about the position, width/height and rotation of the match. An IRegionArguments is composed of:
      • x
        : number, position x of the match.
      • y
        : number, position y of the match.
      • width
        : number, width of the match.
      • height
        : number, height of the match.
      • rotation
        : number, angle of the match (in radians).
      • angle
        : number, angle of the match in degrees.
    • score
      : number, indicates the score of the match.
    • scale
      : scale of the match.
  • statistics: IStatisticsArguments
    ; contains tool execution statistics accumulated between operations.
    
interface IPatternMatchResultArguments { time: number;tool_time: number;success: boolean;matches_count: number;matches: IMatchResultArguments[];statistics: IStatisticsArguments; } interface IMatchResultArguments { roi: IRegionArguments;score: number;scale: number; } interface IRegionArguments { x: number;y: number;width: number;height: number;rotation: number;angle: number; }
The
IPatternMatchPlusResultArguments
interface in TypeScript defines the structure for <advanced pattern match tool> and <advanced pattern match toolPA> results. It includes the following properties:
  • time
    : number; indicates the time taken by a tool or process, including image acquisition.
  • tool_time
    : number; similar to time, indicating the time taken by a tool or process.
  • success
    : boolean; indicates whether a specific operation or process was successful (true) or not (false).
  • matches_count
    : number; indicates the number of matches.
  • matches
    : table of IMatchPlusResultArguments; indicates the detail of each match. An
    IMatchPlusResultArguments
    is composed of:
    • roi: IRegionArguments, information about the position, width/height and rotation of the match. An IRegionArguments is composed of:
      • x
        : number, position x of the match.
      • y
        : number, position y of the match.
      • width
        : number, width of the match.
      • height
        : number, height of the match.
      • rotation
        : number, angle of the match (in radians).
      • angle
        : number, angle of the match in degrees.
    • score
      : number, indicates the score of the match.
    • scale:
      scale of the match.
  • statistics: IStatisticsArguments
    ; contains tool execution statistics accumulated between operations.
    
interface IPatternMatchPlusResultArguments { time: number;tool_time: number;success: boolean;matches_count: number;matches: IMatchPlusResultArguments[];statistics: IStatisticsArguments; } interface IMatchPlusResultArguments { roi: IRegionArguments;score: number;scale: number; } interface IRegionArguments { x: number;y: number;width: number;height: number;rotation: number;angle: number; }

Measurement & Metrology

The
IDistanceMeasurementResultArguments
interface in TypeScript defines the structure for <distancetool> results. It includes the following properties:
  • time
    : number; indicates the time taken by a tool or process, including image acquisition.
  • tool_time
    : number; similar to time, indicating the time taken by a tool or process.
  • success
    : boolean; indicates whether a specific operation or process was successful (true) or not (false).
  • pixel_distance
    : number; indicates the measured distance in pixels.
  • calibrated_distance
    : number; indicates the measured distance of calibrated units. If this measurement is 0.0, there is no calibration.
    • calibration_units
      :
      UnitTypeArguments
      is an enum type that indicates the calibration units. Possible
      UnitTypeArguments
      units include:
      • NONE = "NONE"
      • MICRONS = "MICRONS"
      • MILLIMETERS = "MILLIMETERS"
      • CENTIMETERS = "CENTIMETERS"
      • INCHES = "INCHES"
  • statistics: IStatisticsArguments
    ; contains tool execution statistics accumulated between operations.
    
interface IDistanceMeasurementResultArguments { time: number;tool_time: number;success: boolean;statistics: IStatisticsArguments;pixel_distance: number;calibrated_distance: number;calibration_units: UnitTypeArguments; } enum UnitTypeArguments { NONE = "NONE", MICRONS = "MICRONS", MILLIMETERS = "MILLIMETERS", CENTIMETERS = "CENTIMETERS", INCHES = "INCHES", }
The
IMeasureObjectWidthResultArguments
interface in TypeScript defines the structure for measuring object width results. It includes the following properties:
  • time: number;
    indicates the time taken by a tool or process, including image acquisition.
  • tool_time: number;
    similar to time, a numerical value that indicates the time taken by a tool or process.
  • success: boolean;
    indicates whether a certain operation or process was successful (true) or not (false)
  • statistics: IStatisticsArguments;
    contain the tool's statistics accumulated between operations.
  • width: number;
    width of measured object.
  • scaled_width: number;
    scaled width in configured units.
  • segments: ILineArguments[];
    measured object edge segments
  • approximated_segments: ILineArguments[];
    measured object edge approximated segments.
  • connection_point_1: (IPointArguments | null);
    first connection point.
  • connection_point_2: (IPointArguments | null);
    second connection point.
  • magnitudes: number[];
    edge magnitudes.
  • distance_units: string;
    scaled distance units.
    
interface IMeasureObjectWidthResultArguments { time: number; tool_time: number; success: boolean; statistics: IStatisticsArguments; width: number; scaled_width: number; segments: ILineArguments[]; approximated_segments: ILineArguments[]; connection_point_1: (IPointArguments | null); connection_point_2: (IPointArguments | null); magnitudes: number[]; distance_units: string; }

Flaw & Anomaly Inspection

The
IFlawDetectionEdgesResultArguments
interface in TypeScript defines the structure for flaw detection (edges) results. It includes the following properties:
  • time
    : number; indicates the time taken by a tool or process, including image acquisition.
  • tool_time
    : number; similar to time, indicating the time taken by a tool or process.
  • success
    : boolean; indicates whether a specific operation or process was successful (true) or not (false).
  • defects_present
    : boolean; indicates if one or more defects were found.
  • defects_length
    : number; indicates the total length of all detected flaws in pixels.
  • statistics: IStatisticsArguments
    ; contains tool execution statistics accumulated between operations.
    
interface IFlawDetectionEdgesResultArguments { time: number;tool_time: number;success: boolean;defects_present: boolean;defects_length: number;statistics: IStatisticsArguments; }
The
IFlawDetectionIntensityResultArguments
interface in TypeScript defines the structure for flaw detection (intensity) results. It includes the following properties:
  • time
    : number; indicates the time taken by a tool or process, including image acquisition.
  • tool_time
    : number; similar to time, indicating the time taken by a tool or process.
  • success
    : boolean; indicates whether a specific operation or process was successful (true) or not (false).
  • defects_present
    : boolean; indicates if one or more defects were found.
  • defects_area
    : number; indicates the total area of all detected flaws in pixels.
  • statistics: IStatisticsArguments
    ; contains tool execution statistics accumulated between operations.
    
interface IFlawDetectionIntensityResultArguments { time: number;tool_time: number;success: boolean;defects_present: boolean;defects_area: number;statistics: IStatisticsArguments; }
Classification Tool
The Classification tool is available on NS42 and FS42 devices only.
The
IClassifyObjectResultArguments
interface in TypeScript defines the structure for classification tool results. The classification tool uses a trained deep learning model to categorize the object in a region of interest into one of the classes defined by that model. A job can contain at most one classification tool, and its result is available only in the
onResults
callback. It includes the following properties:
  • time: number;
    indicates the time taken by a tool or process, including image acquisition.
  • tool_time: number;
    similar to time, this number indicates the time taken by a tool or process.
  • success: boolean;
    indicates whether a specific operation or process was successful (true) or not (false). When using the classification tool, a passing result requires the predicted class to be enabled in the configuration and its confidence threshold to meet or exceed the defined threshold. A failing result occurs if either condition is missed, or if the tool or job times out. The result is reversed if the Invert Pass/Fail Result option is enabled.
  • statistics: IStatisticsArguments;
    contain the tool's statistics accumulated between operations.
  • predicted_class_name: string;
    indicates the name of the class with the highest score. It is an empty string when the tool did not produce a prediction.
  • score: number;
    indicates the score of the predicted class, in the range 0.0 to 1.0. The value is produced as a single-precision float and widened to a JavaScript number, so a score of 0.95 is read as 0.949999988079071. Compare it using a tolerance rather than testing for equality, and format it for display.
  • score_matrix: IClassificationArguments[];
    contains one entry for every class defined by the model, including the predicted class, in ascending class id order. The entries are not ordered by score. It is empty when the tool did not produce a prediction.
  • accepted_class: boolean;
    indicates whether the predicted class is enabled in the tool configuration (true) or not (false). It does not take the confidence threshold into account, and it is true when the tool did not produce a prediction, so it must not be used on its own to decide whether the tool passed.
    
interface IClassifyObjectResultArguments { time: number; tool_time: number; success: boolean; statistics: IStatisticsArguments; predicted_class_name: string; score: number; score_matrix: IClassificationArguments[]; accepted_class: boolean; }
The
IClassificationArguments
interface in TypeScript defines the structure of a single class score inside score_matrix. It includes the following properties:
  • class_id: number;
    indicates the zero-based index of the class in the model. It is also the position of the entry in score_matrix.
  • class_name: string;
    indicates the name of the class as defined by the model.
  • score: number;
    indicates the score for this class, in the range 0.0 to 1.0.
    
interface IClassificationArguments { class_id: number; class_name: string; score: number; }
Reading the classification result
A tool result is read from
args.tool_results_by_names
using the tool's script name. The script name is the tool's name in the job, with every character that is not a letter or a digit replaced by an underscore. For example, the default name Classification 1 becomes Classification_1. A tool that did not run contributes no entry; therefore, the property is undefined and must be checked before use.
Reporting the predicted class and the runner-up
    
export function onResults (args) { const result = args.tool_results_by_names['Classification_1']; if (!result) { return {}; } const ranked = [...result.score_matrix].sort((a, b) => b.score - a.score); console.log(`Predicted: ${result.predicted_class_name} (${result.score.toFixed(2)})`); if (ranked.length > 1) { console.log(`Runner-up: ${ranked.class_name} (${ranked.score.toFixed(2)})`); } return {}; }
Sending the verdict, the class, and the score over TCP/IP
The verdict comes from
success
, which accounts for the confidence threshold, not from
accepted_class
.
    
export function onResults (args) { const result = args.tool_results_by_names['Classification_1']; if (!result) { return { tcp_ip: 'NO_RESULT\r\n' }; } const verdict = result.success ? 'PASS' : 'FAIL'; return { tcp_ip: `${verdict},${result.predicted_class_name},${result.score.toFixed(3)}\r\n` }; }
Failing the job when the predicted class is not the expected one
Returning
null
for
job_success
leaves the job's own verdict untouched, whereas returning
false
forces the job to fail.
    
export function onResults (args) { const result = args.tool_results_by_names['Classification_1']; if (!result) { return { job_success: null }; } return { job_success: result.success && result.predicted_class_name === 'ClassA' }; }
Classification tool settings that affect a script
  • Model
    - each classification tool holds one trained model, which defines the set of classes reported in
    score_matrix
    and the
    class_id
    of each one.
  • Class enable and confidence threshold
    - every class of the model can be enabled or disabled individually and given its own confidence threshold in the range 0.0 to 1.0, which defaults to 0.90. The enabled state of the predicted class is reported as
    accepted_class
    , and together with that class's threshold it determines
    success
    .
  • Invert Pass/Fail Result
    - reverses
    success
    .
  • Region of Interest (ROI)
    - a rectangle or a circle. The classification tool does not act as a fixture leader; however, it can follow a fixture leader. The transformed region of interest is not reported to scripts.
The predicted class identifier and the model version are not reported to scripts. Match a class by
class_name
and read its
class_id
from
score_matrix
if a numeric identifier is needed.
The
IAnomalyDetectionResultArguments
interface in TypeScript defines the structure for anomaly detection results. It includes the following properties:
  • time: number;
    indicates the time taken by a tool or process, including image acquisition.
  • tool_time: number;
    similar to time, this number indicates the time taken by a tool or process.
  • success: boolean;
    indicates whether a specific operation or process was successful (true) or not (false).
  • statistics: IStatisticsArguments;
    contains the tool's statistics accumulated between operations.
  • valid: boolean;
    indicates whether an image is considered valid (true) or not (false).
  • score: number;
    represents the score of an image.
  • confident: boolean;
    indicates whether a result is considered confident (true) or not (false).
  • roi: IPointArguments[];
    an array of IPointArguments objects, each representing a point in two-dimensional space. It typically denotes the positions or corners of the tool region of interest.
    
interface IAnomalyDetectionResultArguments { time: number; tool_time: number; success: boolean; statistics: IStatisticsArguments; valid: boolean; score: number; confident: boolean; roi: IPointArguments[]; }

Supporting Data Structures

The following interfaces are common data structures used as properties within the main tool result interfaces.
The
IPointArguments
interface defines an object structure representing a point in a two-dimensional space. It includes two properties:
x
and
y
, both are numbers.
  • x: number;
    expected to be a number representing the x-coordinate of a point in a two-dimensional space.
  • y: number;
    a number representing the y-coordinate of the point.
    
interface IPointArguments { x: number; y: number; }
The
IQualityGradeArguments
interface defines an object structure for representing a quality grade.
  • grade_: number;
    represents the numerical value of the grade.
  • letter_grade: string;
    represents the letter equivalent of the grade, such as A, B, or C.
    
interface IQualityGradeArguments { grade_: number; letter_grade: string; }
IStatisticsArguments
defines the tool execution statistics, considering all iterations (including the current iteration).
  • total_pass : number;
    total number of tool successes.
  • total_fail : number;
    total number of tool failures.
  • tool_time_min : number;
    minimum tool execution time.
  • tool_time_max : number;
    maximum tool execution time.
  • tool_time_average : number;
    average execution time.
    
interface IStatisticsArguments { total_pass: number; total_fail: number; tool_time_min: number; tool_time_max: number; tool_time_average: number; }