# Cross Calibration Task

Cross calibration task uses the result of hand-eye calibration that has been performed on one of the substations to compute the relationship between Raw2D and Home2D for the cameras at the other substations. The task has 7 subtasks: Command, Acquisition, Calibration, HECalibCalib2DFromStage2D, Image Saver2, ImageSaver2 Sync Trigger, and Raw Image Display. To trigger a cross calibration task, you can use IC command.

## Command

When a command string is received by the CommandHandler script, an equivalent CommandArgs object is created. This object contains all the data that is needed to execute the target task. Command subtask is the interface to receive CommandArgs object from task scheduler which makes the object available to current task as an output pin and a public tag.

There are two properties in CommandArgs object that control the work flow of cross calibration task: Execution Mode and PositionIndex. ExecutionMode decides whether current task should acquire image and/or process image. PositionIndex specifies which position cameras should acquire images at.

### Execution Mode

- ExecutionMode: Acquire

  When cameras are not at their last acquisition position, cross calibration task shall only acquire images when it's called. Therefore, the ExecutionMode should be set as Acquire in this case, and accordingly, the task will only run Acquisition, Image Saver2 and Raw Image Display subtasks to acquire, accumulate, and display raw images at current position.

- ExecutionMode: AcquireAndProcessImage

  When cameras are at their last acquisition position, cross calibration task should acquire images and run calibration when it's called. ExecutionMode here should be set as AcquireAndProcessImage so that the task will run Acquisition, Calibration, and HECalib Calib2D From Stage2D subtasks sequentially to finish image acquisition, run checkerboard calibration, and map Home2D from hand-eye calibrated station to Raw2D for cameras at current station. It also save images to image files if image saving function is enabled and generates raw image records in case user wants to show raw images on image display. The work flow below shows all its sub tasks and their execution sequence.

## Acquisition

Running condition:[ExecutionMode = Acquire || AcquireAndProcessImage]

For a cross-calibration task where cameras at a second substation are cross-calibrated to a set of hand-eye calibrated cameras at the first station the cross-calibration task is executed twice. The first using a command string with an encodedID that encodes the one of the positions and with execution mode set to Acquire. The second using a command string with an encodedID that encodes the other position and with execution mode set to AcquireAndProcessImage. Both the executions execute the Acquisition subtask.

Command | ExecutionMode | Position Index | Image Item | Before Acquisition | Acquisition at Pos0 | Acquisition at Pos1
--- | --- | --- | --- | --- | --- | ---
1 | Acquire | 0 | Cam0Pos0 | Null |  | /
0 | Cam1Pos0 | Null |  | /
2 | AcquireAndProcessImage | 1 | Cam0Pos1 | Null | Null |
1 | Cam1Pos1 | Null | Null |

## Calibration

Running condition:[ExecutionMode = ProcessImage || AcquireAndProcessImage]

Calibration subtask is only available in checkerboard-based or hybrid cross calibration, it runs checkerboard calibration for each input raw images, and publish their train correctors for later use in feature finding task's image correction subtask. The output is a dictionary of VisionPro records with corrected checkerboard images and their extracted features.

## HECalib Calib2D FromStage2D

Running condition: [ExecutionMode = ProcessImage || AcquireAndProcessImage]

This subtask establishes transforms between Home2D from hand-eye calibrated stations with Raw2D from cameras in current station. These transforms will be used for run time feature finding.

## Image Saving

Cross calibration task can save all raw images in TIF files for user to playback cross calibration process. It also supports screenshots saving in JPG files for user to manually review feature extraction results.

### Image Saver2

Running condition: Always run.

Image Saver2 subtask accumulates raw images and their corresponding commands every time when current task acquires images. The accumulates images and commands would get cleared when Image Saver2 Sync Trigger subtask is called at the end of the task.

### Image Saver2 Sync Trigger

Running condition:[ExecutionMode = ProcessImage || AcquireAndProcessImage]

Image Saver2 Sync Trigger subtask saves all accumulated raw images and their commands from Image Saver2 subtask into TIF files if current task's raw image saving function is enabled. It also saves image records into JPG files when screenshot saving function is enabled. See how to enable raw image saving and screenshot saving in Image Saving

## Raw Image Display

Running condition:[ExecutionMode = ProcessImage || AcquireAndProcessImage]

Raw Image Display subtask generates raw image records(images without graphics) for image display. Those records will be shown on task's image display page if "Display Raw Image" is selected in functional panel below navigation tree. See more information at Show Graphics in Multiple Display.