FB_VN_WriteCalibrationResult
This FB writes calibration results as a json file to the hard drive.
Syntax
Definition:
FUNCTION_BLOCK FB_VN_WriteCalibrationResult
VAR_INPUT
sFilePath : STRING;
aCameraMatrix : Reference To TcVnMatrix3x3_LREAL;
aDistortionCoefficients : Reference To TcVnArray8_LREAL;
aRotationMatrix : Reference To TcVnMatrix3x3_LREAL;
aTranslationVector : Reference To TcVnVector3_LREAL;
bWrite : BOOL;
nTimeout : TIME;
END_VAR
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
nErrorId : UDINT;
END_VAR
Inputs
Name |
Type |
Default |
Description |
---|---|---|---|
sFilePath |
STRING |
|
Full path of the file or relative path to the default directory on the target pc (e.g. only a file name). If the string is empty, a file name will be generated (containing the current time). |
aCameraMatrix |
Reference To TcVnMatrix3x3_LREAL |
|
Returns the camera matrix |
aDistortionCoefficients |
Reference To TcVnArray8_LREAL |
|
Returns the distortion coefficients |
aRotationMatrix |
Reference To TcVnMatrix3x3_LREAL |
|
Returns the rotation matrix |
aTranslationVector |
Reference To TcVnVector3_LREAL |
|
Returns the translation vector |
bWrite |
BOOL |
|
Writing the container is triggered by a rising edge at this input. |
nTimeout |
TIME |
VISION_ADS_TIMEOUT |
Indicates the time before the function is cancelled. |
Outputs
Name |
Type |
Description |
---|---|---|
bBusy |
BOOL |
This output remains TRUE until the function block has executed a command, but at the longest for the duration supplied to the 'nTimeout' input. While bBusy = TRUE, no new command will be accepted at the inputs. |
bError |
BOOL |
This output is switched to TRUE as soon as an error occurs during the execution of a command. The command-specific error code is contained in ‘nErrorId’. If the function block has a timeout error, 'bError' is TRUE and 'nErrorId' is 1861 (hexadecimal 0x745). Is reset to FALSE by the execution of a command at the inputs. |
nErrorId |
UDINT |
Contains the ADS error code or the command-specific error code of the last executed command. Is reset to 0 by the execution of a command at the inputs. |
Further information
The function block FB_VN_WriteCalibrationResult
saves the calibration results from the PLC asynchronously in a file.
Parameter
Some parameters are described centrally in the section File Access Parameters.
Calibration results
The following results of the calibration functions are saved under the specified file path in JSON
format.
// Calibration results
aCameraMatrix : TcVnMatrix3x3_LREAL;
aDistortionCoefficients : TcVnArray8_LREAL;
aRotationMatrix : TcVnMatrix3x3_LREAL;
aTranslationVector : TcVnVector3_LREAL;
File path and format
If sFilePath
is empty, a file name with the current time is generated and the extension json
is used.
Application
Saving the calibration results to the C:\TcVision\CalibrationResult.json
file looks like this, for example:
fbWriteCalibrationResult(
sFilePath := 'C:\TcVision\CalibrationResult.json',
aCameraMatrix := aCameraMatrix,
aDistortionCoefficients := aDistortionCoefficients,
aRotationMatrix := aRotationMatrix,
aTranslationVector := aTranslationVector,
bWrite := TRUE,
nTimeout := T#500MS);
IF NOT fbWriteCalibrationResult.bBusy AND NOT fbWriteCalibrationResult.bError THEN
// Calibration result was written successfully to file
END_IF
Related function block: FB_VN_ReadCalibrationResult.
Required License
TC3 Vision Base
System Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT V3.1.4024.54 or later | PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU | Tc3_Vision |