set_text_model_param
时间: 2023-03-26 21:04:56 浏览: 94
set_text_model_param是一个函数,用于设置文本模型的参数。该函数可以接受多个参数,包括模型的名称、模型的输入维度、模型的输出维度、模型的隐藏层大小等。通过设置这些参数,可以调整文本模型的性能和效果。例如,可以通过增加隐藏层大小来提高模型的准确率,或者通过调整输入维度来适应不同的数据集。
相关问题
* This example shows how to use shape-based matching * in order to find a model region and use it for * further tasks. * Here, the additional task consists of reading text * within a certain region, wherefore the image has * to be aliged using the matching transformation. * * Initialization. dev_update_window ('off') dev_close_window () * Initialize visualization. read_image (ReferenceImage, 'board/board_01') get_image_size (ReferenceImage, Width, Height) initialize_visualization (Width / 2, Height / 2, WindowHandle, WindowHandleText) disp_continue_message (WindowHandle, 'black', 'true') disp_description_text (WindowHandleText) * * Define ROIs: * ROI for the shape model. dev_set_window (WindowHandle) dev_display (ReferenceImage) gen_rectangle1 (ROIModel, 60, 535, 185, 900) dev_display (ROIModel) * ROI for the text. gen_rectangle1 (ROIText, 445, 585, 590, 765) dev_display (ROIText) disp_model_message (WindowHandle) stop () * * Prepare the shape-based matching model. reduce_domain (ReferenceImage, ROIModel, ModelImage) * Create shape model and set parameters (offline step). create_generic_shape_model (ModelHandle) * Train the shape model. train_generic_shape_model (ModelImage, ModelHandle) * * Prepare the text model. create_text_model_reader ('auto', 'Industrial_0-9A-Z_Rej.omc', TextModel) * * We look for the reference transformation which we will need * for the alignment. We can extract it by finding the instance * on the reference image. * Set find parameters. set_generic_shape_model_param (ModelHandle, 'num_matches', 1) set_generic_shape_model_param (ModelHandle, 'min_score', 0.5) find_generic_shape_model (ReferenceImage, ModelHandle, MatchResultID, Matches) get_generic_shape_model_result (MatchResultID, 'all', 'hom_mat_2d', HomMat2DModel) * * Find the object in other images (online step). for i := 1 to 9 by 1 read_image (SearchImage, 'board/board_' + i$'02') find_generic_shape_model (SearchImage, ModelHandle, MatchResultID, Matches) get_generic_shape_model_result (MatchResultID, 'all', 'hom_mat_2d', HomMat2DMatch) * Compute the transformation matrix. hom_mat2d_invert (HomMat2DMatch, HomMat2DMatchInvert) hom_mat2d_compose (HomMat2DModel, HomMat2DMatchInvert, TransformationMatrix) affine_trans_image (SearchImage, ImageAffineTrans, TransformationMatrix, 'constant', 'false') * * Visualization. dev_set_window (WindowHandle) dev_display (SearchImage) get_generic_shape_model_result_object (InstanceObject, MatchResultID, 'all', 'contours') dev_display (InstanceObject) * * Reading text and numbers on the aligned image. reduce_domain (ImageAffineTrans, ROIText, ImageOCR) find_text (ImageOCR, TextModel, TextResultID) get_text_object (Characters, TextResultID, 'all_lines') get_text_result (TextResultID, 'class', RecognizedText) * * Visualization. dev_set_window (WindowHandleText) dev_display (ImageAffineTrans) dev_set_colored (12) dev_display (Characters) disp_finding_text (Characters, WindowHandle, WindowHandleText, RecognizedText) wait_seconds (0.5) endfor disp_end_of_program_message (WindowHandle, 'black', 'true') stop () dev_close_window ()
这段代码是一个示例程序,演示了如何使用基于形状匹配的方法来找到一个模型区域,并将其用于进一步的任务。在这个示例中,额外的任务是在一个固定的区域内读取文本,在这种情况下,需要使用匹配变换来对图像进行对齐。
代码的具体步骤如下:
1. 初始化程序,并展示图像。
2. 定义形状模型和文本区域的ROI。
3. 准备形状模型。
4. 创建形状模型,并训练模型。
5. 准备文本模型。
6. 查找参考图像中的实例,并提取变换矩阵。
7. 在其他图像中查找实例,并计算变换矩阵。
8. 对齐图像,并在对齐后的图像中读取文本。
9. 可视化结果。
10. 结束程序。
这段代码主要使用了HALCON库中的形状匹配和文本识别功能,通过这些功能实现了对一个模型区域的识别和定位,并在其他图像中查找并对齐该模型区域。同时,代码还使用了HALCON库中的可视化功能,将结果展示给用户。
function startSimApplication(app, index) % 是否选择了虚拟CAN通道 if app.canChannelInfo.DeviceModel(index) == "Virtual" % 在尝试运行之前,检查模型是否已加载 if bdIsLoaded(app.mdl) % 模型已加载,现在检查它是否已经在运行 if ~strcmp('running',get_param(app.mdl,'SimulationStatus')) % 启动CAN通道、启动接收处理计时器(如果计时器尚未运行) startCANChannel(app); % 模型尚未运行,请启动它 set_param(app.mdl, 'SimulationCommand', 'start'); % 将按钮图标设置为停止图标,表示模型已成功启动 app.SimStartStopButton.Icon = "IconEnd.png"; app.Label_6.Text = "停止模型"; else % 模型已在运行,请通知用户 warnStr = sprintf('Warning: Model %s is already running', app.mdl); % 使用指定的消息创建一个非模态警告对话框 warndlg(warnStr, 'Warning'); end else % 模型尚未加载,因此警告用户 warnStr = sprintf('Warning: Model %s is not loaded\nPlease load the model and try again', app.mdl); warndlg(warnStr, 'Warning'); end end end
这是一段 MATLAB 代码,它定义了一个名为 startSimApplication 的函数。该函数需要两个参数:app 和 index。该函数的主要目的是启动一个模型,并在需要时启动虚拟 CAN 通道和接收处理计时器。该函数首先检查是否选择了虚拟 CAN 通道,如果是,则检查模型是否已加载。如果模型已加载,则检查它是否已经在运行。如果模型尚未运行,则启动 CAN 通道、启动接收处理计时器,并将按钮图标设置为停止图标,表示模型已成功启动。如果模型已在运行,则通知用户。如果模型尚未加载,则警告用户。