Operator Reference

write_bar_code_modelT_write_bar_code_modelWriteBarCodeModelWriteBarCodeModelwrite_bar_code_model (Operator)

write_bar_code_modelT_write_bar_code_modelWriteBarCodeModelWriteBarCodeModelwrite_bar_code_model — Write a bar code model to a file.

Signature

write_bar_code_model( : : BarCodeHandle, FileName : )

Herror T_write_bar_code_model(const Htuple BarCodeHandle, const Htuple FileName)

void WriteBarCodeModel(const HTuple& BarCodeHandle, const HTuple& FileName)

void HBarCode::WriteBarCodeModel(const HString& FileName) const

void HBarCode::WriteBarCodeModel(const char* FileName) const

void HBarCode::WriteBarCodeModel(const wchar_t* FileName) const   ( Windows only)

static void HOperatorSet.WriteBarCodeModel(HTuple barCodeHandle, HTuple fileName)

void HBarCode.WriteBarCodeModel(string fileName)

def write_bar_code_model(bar_code_handle: HHandle, file_name: str) -> None

Description

The operator write_bar_code_modelwrite_bar_code_modelWriteBarCodeModelWriteBarCodeModelwrite_bar_code_model writes the bar code model BarCodeHandleBarCodeHandleBarCodeHandlebarCodeHandlebar_code_handle to the file FileNameFileNameFileNamefileNamefile_name. The model can be read again with read_bar_code_modelread_bar_code_modelReadBarCodeModelReadBarCodeModelread_bar_code_model. The stored data contains all generic and all specific model parameters (see set_bar_code_paramset_bar_code_paramSetBarCodeParamSetBarCodeParamset_bar_code_param and set_bar_code_param_specificset_bar_code_param_specificSetBarCodeParamSpecificSetBarCodeParamSpecificset_bar_code_param_specific, respectively). If the model is in training mode (see set_bar_code_paramset_bar_code_paramSetBarCodeParamSetBarCodeParamset_bar_code_param with parameter 'train'"train""train""train""train"), the current training state is stored as well. After restoring the model, the training can be proceeded.

Besides the training state no other results of find_bar_codefind_bar_codeFindBarCodeFindBarCodefind_bar_code are stored in the file.

The default HALCON file extension for bar code model is 'bcm'.

Execution Information

  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).
  • Multithreading scope: global (may be called from any thread).
  • Processed without parallelization.

Parameters

BarCodeHandleBarCodeHandleBarCodeHandlebarCodeHandlebar_code_handle (input_control)  barcode HBarCode, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Handle of the bar code model.

FileNameFileNameFileNamefileNamefile_name (input_control)  filename.write HTuplestrHTupleHtuple (string) (string) (HString) (char*)

Name of the bar code model file.

Default: 'bar_code_model.bcm' "bar_code_model.bcm" "bar_code_model.bcm" "bar_code_model.bcm" "bar_code_model.bcm"

File extension: .bcm

Example (HDevelop)

*
* Create the bar code model in the training mode
create_bar_code_model ('train', 'all', BarCodeHandle)
*
* Set all additional, non-trained parameters in advance:
* Here, we specify that the training images have check characters
set_bar_code_param (BarCodeHandle, 'check_char', 'present')
*
* Train the model with several images
for I := 1 to 7 by 1
    FileName := 'barcode/25interleaved/25interleaved' + I$'.02'
    read_image (Image, FileName)
    *
    * Apply the training
    find_bar_code (Image, SymbolRegion, BarCodeHandle, '2/5 Interleaved', \
                   DecodedDataStrings)
endfor
*
* The training may be interrupted and the intermediate state
* of the model can be stored in a file
write_bar_code_model (BarCodeHandle, 'bar_code_model.bcm')
*
* RESTORE TRAINING:
* Later, when, e.g., new images are available, the training
* may be restored
read_bar_code_model ('bar_code_model.bcm', BarCodeHandle)
FileName := 'barcode/25interleaved/25interleaved08'
read_image (Image, FileName)
*
* Apply the training to the new image
find_bar_code (Image, SymbolRegion, BarCodeHandle, '2/5 Interleaved', \
               DecodedDataStrings)
*
* Finally, the training can be completed
set_bar_code_param (BarCodeHandle, 'train', '~all')
*
* The trained model can be stored for ONLINE use
write_bar_code_model (BarCodeHandle, 'trained_bar_code_model.bcm')
*
* ONLINE USE:
read_bar_code_model ('trained_bar_code_model.bcm', BarCodeHandle)
* ...

Result

The operator write_bar_code_modelwrite_bar_code_modelWriteBarCodeModelWriteBarCodeModelwrite_bar_code_model returns the value 2 ( H_MSG_TRUE) if the passed handle is valid and if the model can be written into the named file. Otherwise, an exception is raised.

Possible Predecessors

create_bar_code_modelcreate_bar_code_modelCreateBarCodeModelCreateBarCodeModelcreate_bar_code_model, set_bar_code_paramset_bar_code_paramSetBarCodeParamSetBarCodeParamset_bar_code_param

See also

create_bar_code_modelcreate_bar_code_modelCreateBarCodeModelCreateBarCodeModelcreate_bar_code_model, set_bar_code_paramset_bar_code_paramSetBarCodeParamSetBarCodeParamset_bar_code_param, find_bar_codefind_bar_codeFindBarCodeFindBarCodefind_bar_code

Module

Bar Code