# Feature Finding Sub Tasks

The following subtasks are used in feature finding tasks.

## Corrector Subtask

Images captured by the cameras can have a non-linear relationship between the image pixel locations and real world locations, due to non-linearities in the imaging system. The Corrector subtask generates images free from these non-linearities. The output images will be corrected images without lens distortion and perspective distortion.

The input and output pin names depend upon the finding task name. Output pin names depend upon the camera names and the acquisition positions.

- Hand-eye Calibration Corrector

- Cross Calibration Corrector

This subtask has five inputs generally named: Accumulated Commands, Accumulated Image Collection, Acquisition Settings, Command, and Image Collection.

Input | Type | Description
--- | --- | ---
AccumulatedCommands | List<CommandArgs> | Accumulated commands that have been sent to Acquisition subtask to acquire a whole set of images at all acquisition positions.
AccumulatedImageCollection | List<CogImageCollection> | Accumulated images acquired at different acquisition positions.
AcquisitionSettings | AcquisitionSettings | The acquisition settings for current task, which includes camera indexes, camera enable/disable status, exposure time and position indexes.
Command | CommandArgs | Current command of the mother task, it's the same with the input Command.
ImageCollection | CogImagesCollection | A list of images acquired at current position index.

Outputs are corrected images for each camera's acquisition position.

Output | Type | Description
--- | --- | ---
Camera0Pos0 | ICogImage | Corrected image of Camera0 at position0
Camera0Pos1 | ICogImage | Corrected image of Camera0 at position1
Camera1Pos0 | ICogImage | Corrected image of Camera1 at position0
Camera1Pos1 | ICogImage | Corrected image of Camera1 at position1

Note: Input and output descriptor labels in the tables above are illustrative only, the actual input and output pin names will be based on project configuration.

## Feature Extractor Subtask

Feature extractor subtask extracts features from corrected image. The feature type could be point, line, or generic features (see more information about generic feature in AlignPlus Concept\Feature Finding\Features) depending on which type is selected in configuration wizard. The input and output names are appended with feature finder name and/or its connected calibration name. For example, "AcquisitionSettingsFeatures0CrossCalib" means Acquisition Settings for "Features0" finder which connects "CrossCalib" calibration component.

The input image number would change according to the number of images a feature finding task acquires for feature extraction.

Input | Type | Description
--- | --- | ---
AcquisitionSettings | AcquisitionSettings | The acquisition settings for current task, which includes camera indexes, camera enable/disable status, exposure time and position indexes.
Command | CommandArgs | Current command of the task, it is the same with the input pin.
Camera0Pos0 | ICogImage | Corrected image of Camera0 at position0.
Camera0Pos1 | ICogImage | Corrected image of Camera0 at position1.
Camera1Pos0 | ICogImage | Corrected image of Camera1 at position0.
Camera1Pos1 | ICogImage | Corrected image of Camera1 at position1.

The outputs include train time and run time features and their corresponding commands, feature extraction OK/NG signal, feature extraction data, and VisionPro Records.

Output | Type | Description
--- | --- | ---
Command | CommandArgs | Current run time command, it is the same with input pin.
CommandTrain | CommandArgs | Command that is saved when stage pose is trained.
DetectedFeatures | List<CogAlpsPointFeature> / List<CogAlpsLineFeature> / List<CogAlpsGenericFeature> | Current run time feature list.
DetectedFeaturesTrain | List<CogAlpsPointFeature> / List<CogAlpsLineFeature> / List<CogAlpsGenericFeature> | Saved train time feature list.
FeatureExtractorData | CogDictionary | A dictionary which tracks the serial number of current part and whether its feature finding is OK or NG. It has two keys inside: "IsNG" and "TagFileName".
FeatureExtractorIsNG | Boolean | Whether current part's feature are all found and valid
OffsetCameraCenters | List<CogAlpsPointFeature> | A list of point features whose locations are provided by user's inputs on "Camera Center Parameters" page. This list of features will be used as trained golden pose feature locations for pose computer in alignment task if user choose "Align To Camera Center" on HMI
VisionProRecords | IReadOnlyDictionary<String, vprorecord> | A dictionary of VisionPro records which saves each camera acquisition position's image and graphics.

## L-Check Subtask

L-Check subtask checks lengths between pairs of feature points. It only supports single part point features currently.

The input is a point feature list.

Input | Type | Description
--- | --- | ---
InputPointFeatures | List<CogAlpsPointFeature> | A list of found point features

Outputs are each length and its OK/NG check result, and the overall L-Check result.

Output | Type | Description
--- | --- | ---
L-CheckIsNG | Boolean | Whether input point features pass all length checks specified by user on user interface.
Results | List<Tuple<String, Double, Boolean>> | A dictionary of all length checks with length values and whether they pass specifications.

## Results Publisher Subtask

Results publisher subtask publishes: run time and train time features, run time and train time commands. The published data is subscribed by other tasks in the application.

Input pins includes run time and train time features and their commands and three NG checks: Feature extraction OK/NG check, L-Check OK/NG check and customized OK/NG check. For the sake of generality, specific finder name and corresponding calibration name in input names are ignored.

Input | Type | Description
--- | --- | ---
Command | CommandArgs | Current command of the task
CommandTrain | CommandArgs | Save train time command
CustomizationIsNG | Nullable Boolean | Open pin for user to input customized OK/NG check
DetectedFeatures | List<CogAlpsPointFeature> / List<CogAlpsLineFeature> / List<CogAlpsGenericFeature> | Current run time feature list
DetectedFeaturesTrain | List<CogAlpsPointFeature> / List<CogAlpsLineFeature> / List<CogAlpsGenericFeature> | Train time feature list
FeatureExtractorIsNG | Nullable Boolean | Whether feature extraction is successful or not for current part
L-CheckIsNG | Nullable Boolean | Whether L-Check is passed or not for current part
OffsetCameraCenters | List<CogAlpsPointFeature> | A list of point features whose locations are provided by user's inputs on "Camera Center Parameters" page. This list of features will be used as trained golden pose feature locations for pose computer in alignment task if user choose "Align To Camera Center" on HMI

The output is the overall OK/NG judgement.

Output | Type | Description
--- | --- | ---
IsNG | Boolean | Overall OK/NG check based on FeatureExtractorIsNG, L-CheckIsNG and CustomizationIsNG input pins

## Display Record Generator Subtask

Display Recorder Generator subtask merges VisionPro records from feature extractor subtask with customized VisionPro records for image displays.

Input | Type | Description
--- | --- | ---
CustomizationFeatureExtractorData | CogDictionary | Customized feature extraction data. It depends on user how to specify the content inside.
CustomizationVisionProRecords | IReadOnlyDictionary<String, vprorecord> | Customized VisionPro records
FeatureExtractorData | CogDictionary | A dictionary which tracks the serial number of current part and whether its feature finding is OK or NG. It has two keys inside: "IsNG" and "TagFileName".
VisionProRecords | IReadOnlyDictionary<String, vprorecord> | A dictionary of VisionPro records from feature extractor subtask which saves each camera acquisition position's image and graphics.

The output is a dictionary of merged VisionPro records for each camera at each acquisition position.

Input | Type | Description
--- | --- | ---
VisionProRecords | IReadOnlyDictionary<String, vprorecord> | A dictionary of merged VisionPro records which saves each camera acquisition position's image and graphics.