F_VN_TrainImageColor_ITcVnMlModel
Create a new color model, describing the image color.
Can use available TwinCAT Job Tasks for executing parallel code regions.
Can return partial results when canceled by Watchdog.
Syntax
Definition:
FUNCTION F_VN_TrainImageColor_ITcVnMlModel : HRESULT
VAR_INPUT
ipSrcImage : ITcVnImage;
ipColorModel : Reference To ITcVnMlModel;
nDifferentColors : UDINT;
hrPrev : HRESULT;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipSrcImage |
Source image (3 channels (RGB) of type USINT) | |
ipColorModel |
Reference To ITcVnMlModel |
Returns the color model |
nDifferentColors |
UDINT |
Number of different colors to distinguish |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_TrainImageColor_ITcVnMlModel
trains a color model on the basis of a reference image. The color model can be saved and loaded on the hard disk with the corresponding function blocks.
Parameter
Reference image
The reference image ipSrcImage
must have 3 channels in RGB format and the element type USINT
(8-bit).
Color model
The parameter ipColorModel
returns the trained color model. This is an interface pointer of type ITcVnMlModel.
Number of colors to be distinguished
The number nDifferentColors
defines the number of colors to be trained. Note that the image background, for example, can also have its own color.
Expert parameters
Further parameters can be found in the expert version F_VN_TrainImageColorExp_ITcVnMlModel.
Application
The training of a color model for a reference image with 4 differently colored objects and a dark background looks like this, for example:
VAR
ipColorModel : ITcVnMlModel;
END_VAR
hr := F_VN_TrainImageColor_ITcVnMlModel(
ipSrcImage := ipImageRef,
ipColorModel := ipColorModel,
nDifferentColors:= 5, // 4 colors + 1 background = 5
hrPrev := hr);
Related functions
There are three ways to pass the reference color to the corresponding F_VN_ReferenceColorSimilarity
function:
- As a trained color model of the type
ITcVnColorModel
- As a trained color model of the type
ITcVnMlModel
- Directly with values in a
TcVnVector3_LREAL
For the color models there are corresponding functions for training and for all three data types one function each for execution:
- F_VN_TrainImageColor for the training of a color model
- F_VN_ReferenceColorSimilarity for segmentation by means of a color model
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 |