Halcon深度学习,异常值缺陷检测

news2024/9/22 23:26:36

前言

halcon深度学习分为常见的4大类。分类,语义分割,异常值检测,深度OCR。本篇主要针对halcon的异常值检测,如何训练和部署,并通过图像预处理的方式实现对异常值缺陷检测的精准实现。
异常值检测不同于语义分割的项目,异常值检测可以仅训练OK图像,不训练NG图像,但是使用NG图像训练可以显著提高准确度

1.总结程序

ImageDir := 'E:/New/图像文件/异常值检测单块'
ImageSubDirs := ['OK','NG']
OutputDir := 'E:/New/图像文件/异常值检测单块/样品'
ExampleSpecificPreprocessing := true

ImageWidth := 160
ImageHeight := 160

Complexity := 15

*******************1.拆分数据集***************
create_dict (GenParamDataset)
set_dict_tuple (GenParamDataset, 'image_sub_dirs', ImageSubDirs)
read_dl_dataset_anomaly (ImageDir, [], [], [], GenParamDataset, DLDataset)
* 

split_dl_dataset (DLDataset, 50, 10, [])
* 
* 加载异常值检测模型
read_dl_model ('initial_dl_anomaly_medium.hdl', DLModelHandle)
set_dl_model_param (DLModelHandle, 'image_width', ImageWidth)
set_dl_model_param (DLModelHandle, 'image_height', ImageHeight)
set_dl_model_param (DLModelHandle, 'complexity', Complexity)
* 校验GPU
query_available_dl_devices (['runtime','id'], ['gpu',0], DLDevice)
set_dl_model_param (DLModelHandle, 'device', DLDevice)
* 
* 设置参数和预处理模型
create_dict (PreprocessSettings)
set_dict_tuple (PreprocessSettings, 'overwrite_files', true)
create_dl_preprocess_param ('anomaly_detection', ImageWidth, ImageHeight, 3, [], [], 'constant_values', 'full_domain', [], [], [], [], DLPreprocessParam)
preprocess_dl_dataset (DLDataset, OutputDir, DLPreprocessParam, PreprocessSettings, DLDatasetFileName)
* 
get_dict_tuple (DLDataset, 'samples', DatasetSamples)
if (ExampleSpecificPreprocessing)
    read_dl_samples (DLDataset, [0:|DatasetSamples| - 1], DLSampleBatch)
    preprocess_dl_samples_bottle (DLSampleBatch)
    write_dl_samples (DLDataset, [0:|DatasetSamples| - 1], DLSampleBatch, [], [])
endif
*随机抽取检查标注情况
create_dict (WindowDict)
for Index := 0 to 9 by 1
    SampleIndex := int(rand(1) * |DatasetSamples|)
    read_dl_samples (DLDataset, SampleIndex, DLSample)
    dev_display_dl_data (DLSample, [], DLDataset, 'anomaly_ground_truth', [], WindowDict)
    dev_disp_text ('Press Run (F5) to continue', 'window', 'bottom', 'right', 'black', [], [])
    * 
    get_dict_tuple (WindowDict, 'anomaly_ground_truth', WindowHandles)
    dev_set_window (WindowHandles[0])
    dev_disp_text ('Preprocessed image', 'window', 'top', 'left', 'black', [], [])
    * 
    stop ()
endfor
dev_close_window_dict (WindowDict)
* ***   2.) 训练   ***
* 
* 创建训练参数
* 
* C显示训练进度
EnableDisplay := true
* 
*设置最小训练误差和最大迭代次数
ErrorThreshold := 0.001
MaxNumEpochs := 30
* 
*控制每张图像的大小训练参数,越大可以增加准确率,但是训练时间会显著增加
DomainRatio := 0.25
* 
* 设置稳健性,当训练失败时,可以调高参数值
RegularizationNoise := 0.01
* 
create_dict (TrainParamAnomaly)
set_dict_tuple (TrainParamAnomaly, 'regularization_noise', RegularizationNoise)
set_dict_tuple (TrainParamAnomaly, 'error_threshold', ErrorThreshold)
set_dict_tuple (TrainParamAnomaly, 'domain_ratio', DomainRatio)
create_dl_train_param (DLModelHandle, MaxNumEpochs, [], EnableDisplay, 73, 'anomaly', TrainParamAnomaly, TrainParam)
* 
* 调用数据集,并开始训练
train_dl_model (DLDataset, DLModelHandle, TrainParam, 0, TrainResults, TrainInfos, EvaluationInfos)
dev_disp_text ('Press Run (F5) to continue', 'window', 'bottom', 'right', 'black', [], [])
stop ()
* 
dev_close_window ()
* ***   3.评估模型   ***
* 
* 计算异常评分系数,当缺陷过小时,可以提高系数,使得评估更准确
StandardDeviationFactor := 1.0
set_dl_model_param (DLModelHandle, 'standard_deviation_factor', StandardDeviationFactor)
* 
*预估阀值,用于分割缺陷和背景
create_dict (GenParamThreshold)
set_dict_tuple (GenParamThreshold, 'enable_display', 'true')
compute_dl_anomaly_thresholds (DLModelHandle, DLDataset, GenParamThreshold, AnomalySegmentationThreshold, AnomalyClassificationThresholds)
dev_disp_text ('Press Run (F5) to continue', 'window', 'bottom', 'right', 'black', [], [])
stop ()
* 
dev_close_window ()
* 
* 设置评估参数跟评估模型
create_dict (GenParamEvaluation)
set_dict_tuple (GenParamEvaluation, 'measures', 'all')
set_dict_tuple (GenParamEvaluation, 'anomaly_classification_thresholds', AnomalyClassificationThresholds)
evaluate_dl_model (DLDataset, DLModelHandle, 'split', 'test', GenParamEvaluation, EvaluationResult, EvalParams)
* 
* 设置显示参数
create_dict (GenParamDisplay)
*显示评估模型
set_dict_tuple (GenParamDisplay, 'display_mode', ['score_histogram','score_legend'])
create_dict (WindowDict)
dev_display_anomaly_detection_evaluation (EvaluationResult, EvalParams, GenParamDisplay, WindowDict)
dev_disp_text ('Press Run (F5) to continue', 'window', 'bottom', 'right', 'black', 'box', 'true')
stop ()
* 
dev_close_window_dict (WindowDict)
* 
* 可视化评估参数
set_dict_tuple (GenParamDisplay, 'display_mode', ['pie_charts_precision','pie_charts_recall','absolute_confusion_matrix'])
* 
ClassificationThresholdIndex := |AnomalyClassificationThresholds| - 1
set_dict_tuple (GenParamDisplay, 'classification_threshold_index', 0)
create_dict (WindowDict)
dev_display_anomaly_detection_evaluation (EvaluationResult, EvalParams, GenParamDisplay, WindowDict)
dev_disp_text ('Press Run (F5) to continue', 'window', 'bottom', 'right', 'black', [], [])
stop ()
* 
dev_close_window_dict (WindowDict)
* 
* 写出模型
write_dl_model (DLModelHandle, 'E:/New/图像文件/异常值检测/model_final.hdl')


* ***   4.推理   ***

InferenceClassificationThreshold := AnomalyClassificationThresholds[0]

InferenceSegmentationThreshold := AnomalySegmentationThreshold
create_dict (DLDatasetInfo)
set_dict_tuple (DLDatasetInfo, 'class_names', ['OK','NG'])
set_dict_tuple (DLDatasetInfo, 'class_ids', [0,1])
create_dict (WindowDict)

* Image Acquisition 01: Code generated by Image Acquisition 01
list_files ('E:/New/图像文件/异常值检测单块/OK', ['files','follow_links'], ImageFiles)
tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
for Index := 0 to |ImageFiles| - 1 by 1
    read_image (Image, ImageFiles[Index])
    * Image Acquisition 01: Do something
    dev_set_color ('red')
    *预处理图像,将所要检测的区域提取出
    threshold (Image, Regions, 29, 156)
    closing_circle (Regions, RegionClosing, 20)
    fill_up (RegionClosing, RegionFillUp)
    reduce_domain (Image, RegionFillUp, ImageReduced)
    *缩放图像,将图像缩放到与训练预处理一致,方便筛选
    get_image_size (ImageReduced, Width, Height)
    zoom_image_size (Image, ImageZoom,160,160, 'constant')
    zoom_region (RegionFillUp, RegionZoom,0.89,0.89)
    *将图像加载进行推理
    gen_dl_samples_from_images (Image, DLSample)
    preprocess_dl_samples (DLSample, DLPreprocessParam)
    apply_dl_model (DLModelHandle, DLSample, [], DLResult)

      read_dict_object (AnomalyImage, DLResult, 'anomaly_image')
    read_dict_tuple (DLResult, 'anomaly_score', AnomalyScore)
    * 
    *使用二值化选择所需要的区域
    threshold (AnomalyImage, AnomalyRegion,0.2,0.6)
    *对图像取交集,提取所检测的区域
    intersection (AnomalyRegion, RegionZoom, RegionIntersection)
    connection (RegionIntersection, ConnectedRegions)
    select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 100, 50000000)
     gen_contour_region_xld (SelectedRegions, Contours, 'border')
     *统计NG的区域个数
     count_obj (Contours, Number)
     dev_get_window (WindowHandle)
     if (Number>0)
         disp_message (WindowHandle, 'NG', 'window', 12, 12, 'black', 'true')
         stop ()
     else
         disp_message (WindowHandle, 'OK', 'window', 12, 12, 'black', 'true')
     endif
     
     reduce_domain (ImageZoom, RegionZoom, ImageReduced1)
     dev_display (ImageReduced1)
     dev_set_color ('green')
     dev_display (Contours)
endfor
dev_close_window_dict (WindowDict)

2.程序分析

2.1预处理和选择路径

*图像输入
ImageDir := 'E:/New/图像文件/异常值检测单块'
*检测数组
ImageSubDirs := ['OK','NG']
*预处理输出路径
OutputDir := 'E:/New/图像文件/异常值检测单块/样品'
ExampleSpecificPreprocessing := true

ImageWidth := 160
ImageHeight := 160

Complexity := 15

*******************1.拆分数据集***************
create_dict (GenParamDataset)
set_dict_tuple (GenParamDataset, 'image_sub_dirs', ImageSubDirs)
read_dl_dataset_anomaly (ImageDir, [], [], [], GenParamDataset, DLDataset)

注意事项:1.选择输入的预处理图像时,需要满足图像的大小是20的进制倍数。当我们训练的图像非常小时,比如我要训练的图像200190 。那么应该选取的是160160的预处理模型。预处理模型只支持:40,80,160,320,640,4中预处理格式,如果设置的格式错误是预处理将无法进行下去

2.2设置训练参数

 ***   2.) 训练   ***
* 
* 创建训练参数
* 
* 显示训练进度
EnableDisplay := true
* 
*设置最小训练误差和最大迭代次数
ErrorThreshold := 0.001
MaxNumEpochs := 30
* 
*控制每张图像的大小训练参数,越大可以增加准确率,但是训练时间会显著增加
DomainRatio := 0.25
* 
* 设置稳健性,当训练失败时,可以调高参数值
RegularizationNoise := 0.01
* 
create_dict (TrainParamAnomaly)
set_dict_tuple (TrainParamAnomaly, 'regularization_noise', RegularizationNoise)
set_dict_tuple (TrainParamAnomaly, 'error_threshold', ErrorThreshold)
set_dict_tuple (TrainParamAnomaly, 'domain_ratio', DomainRatio)
create_dl_train_param (DLModelHandle, MaxNumEpochs, [], EnableDisplay, 73, 'anomaly', TrainParamAnomaly, TrainParam)
* 
* 调用数据集,并开始训练
train_dl_model (DLDataset, DLModelHandle, TrainParam, 0, TrainResults, TrainInfos, EvaluationInfos)
dev_disp_text ('Press Run (F5) to continue', 'window', 'bottom', 'right', 'black', [], [])
stop ()

2.3显示评估混淆矩阵

 ***   3.评估模型   ***
* 
* 计算异常评分系数,当缺陷过小时,可以提高系数,使得评估更准确
StandardDeviationFactor := 1.0
set_dl_model_param (DLModelHandle, 'standard_deviation_factor', StandardDeviationFactor)
* 
*预估阀值,用于分割缺陷和背景
create_dict (GenParamThreshold)
set_dict_tuple (GenParamThreshold, 'enable_display', 'true')
compute_dl_anomaly_thresholds (DLModelHandle, DLDataset, GenParamThreshold, AnomalySegmentationThreshold, AnomalyClassificationThresholds)
dev_disp_text ('Press Run (F5) to continue', 'window', 'bottom', 'right', 'black', [], [])
stop ()
* 
dev_close_window ()
* 
* 设置评估参数跟评估模型
create_dict (GenParamEvaluation)
set_dict_tuple (GenParamEvaluation, 'measures', 'all')
set_dict_tuple (GenParamEvaluation, 'anomaly_classification_thresholds', AnomalyClassificationThresholds)
evaluate_dl_model (DLDataset, DLModelHandle, 'split', 'test', GenParamEvaluation, EvaluationResult, EvalParams)
* 
* 设置显示参数
create_dict (GenParamDisplay)
*显示评估模型
set_dict_tuple (GenParamDisplay, 'display_mode', ['score_histogram','score_legend'])
create_dict (WindowDict)
dev_display_anomaly_detection_evaluation (EvaluationResult, EvalParams, GenParamDisplay, WindowDict)
dev_disp_text ('Press Run (F5) to continue', 'window', 'bottom', 'right', 'black', 'box', 'true')
stop ()
* 
dev_close_window_dict (WindowDict)
* 
* 可视化评估参数
set_dict_tuple (GenParamDisplay, 'display_mode', ['pie_charts_precision','pie_charts_recall','absolute_confusion_matrix'])
* 
ClassificationThresholdIndex := |AnomalyClassificationThresholds| - 1
set_dict_tuple (GenParamDisplay, 'classification_threshold_index', 0)
create_dict (WindowDict)
dev_display_anomaly_detection_evaluation (EvaluationResult, EvalParams, GenParamDisplay, WindowDict)
dev_disp_text ('Press Run (F5) to continue', 'window', 'bottom', 'right', 'black', [], [])
stop ()
* 
dev_close_window_dict (WindowDict)
* 
* 写出模型

2.3.1评估分数表

在这里插入图片描述
上图是二值化区域表,纵轴错误分类的图像比例,横轴代表匹配分数。通常来看OK与NG的交叉点是最小匹配分数的阈值。一般选取稍大的部分可以有效防止误判情况。以上图而言,可以选取0.15-0.2之间。

3.应用推理


* ***   4.推理   ***

InferenceClassificationThreshold := AnomalyClassificationThresholds[0]

InferenceSegmentationThreshold := AnomalySegmentationThreshold
create_dict (DLDatasetInfo)
set_dict_tuple (DLDatasetInfo, 'class_names', ['OK','NG'])
set_dict_tuple (DLDatasetInfo, 'class_ids', [0,1])
create_dict (WindowDict)

* Image Acquisition 01: Code generated by Image Acquisition 01
list_files ('E:/New/图像文件/异常值检测单块/OK', ['files','follow_links'], ImageFiles)
tuple_regexp_select (ImageFiles, ['\\.(tif|tiff|gif|bmp|jpg|jpeg|jp2|png|pcx|pgm|ppm|pbm|xwd|ima|hobj)$','ignore_case'], ImageFiles)
for Index := 0 to |ImageFiles| - 1 by 1
    read_image (Image, ImageFiles[Index])
    * Image Acquisition 01: Do something
    dev_set_color ('red')
    *预处理图像,将所要检测的区域提取出
    threshold (Image, Regions, 29, 156)
    closing_circle (Regions, RegionClosing, 20)
    fill_up (RegionClosing, RegionFillUp)
    reduce_domain (Image, RegionFillUp, ImageReduced)
    *缩放图像,将图像缩放到与训练预处理一致,方便筛选
    get_image_size (ImageReduced, Width, Height)
    zoom_image_size (Image, ImageZoom,160,160, 'constant')
    zoom_region (RegionFillUp, RegionZoom,0.89,0.89)
    *将图像加载进行推理
    gen_dl_samples_from_images (Image, DLSample)
    preprocess_dl_samples (DLSample, DLPreprocessParam)
    apply_dl_model (DLModelHandle, DLSample, [], DLResult)

      read_dict_object (AnomalyImage, DLResult, 'anomaly_image')
    read_dict_tuple (DLResult, 'anomaly_score', AnomalyScore)
    * 
    *使用二值化选择所需要的区域
    threshold (AnomalyImage, AnomalyRegion,0.2,0.6)
    *对图像取交集,提取所检测的区域
    intersection (AnomalyRegion, RegionZoom, RegionIntersection)
    connection (RegionIntersection, ConnectedRegions)
    select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 100, 50000000)
     gen_contour_region_xld (SelectedRegions, Contours, 'border')
     *统计NG的区域个数
     count_obj (Contours, Number)
     dev_get_window (WindowHandle)
     if (Number>0)
         disp_message (WindowHandle, 'NG', 'window', 12, 12, 'black', 'true')
         stop ()
     else
         disp_message (WindowHandle, 'OK', 'window', 12, 12, 'black', 'true')
     endif
     
     reduce_domain (ImageZoom, RegionZoom, ImageReduced1)
     dev_display (ImageReduced1)
     dev_set_color ('green')
     dev_display (Contours)
endfor
dev_close_window_dict (WindowDict)

3.1输入的图像

在这里插入图片描述
输入一张NG图像进行测试。如上图所示,在110的字符中心存在漏印的部分,

3.2将区域提取出来

在这里插入图片描述

*预处理图像,将所要检测的区域提取出
    threshold (Image, Regions, 29, 156)
    closing_circle (Regions, RegionClosing, 20)
    fill_up (RegionClosing, RegionFillUp)
    reduce_domain (Image, RegionFillUp, ImageReduced)
    *缩放图像,将图像缩放到与训练预处理一致,方便筛选
    get_image_size (ImageReduced, Width, Height)
    zoom_image_size (Image, ImageZoom,160,160, 'constant')
    zoom_region (RegionFillUp, RegionZoom,0.89,0.89)

在推理的过程中,由于异常值深度学习的特性,会导致将大量的背景定义为异常区域,所以在推理前需要将图像三角标志提取出来。

3.3匹配异常区域

 intersection (AnomalyRegion, RegionZoom, RegionIntersection)
    connection (RegionIntersection, ConnectedRegions)
    select_shape (ConnectedRegions, SelectedRegions, 'area', 'and', 100, 50000000)
     gen_contour_region_xld (SelectedRegions, Contours, 'border')
     *统计NG的区域个数
     count_obj (Contours, Number)

将提取成功的三角区域与异常区域取交集,即可完成NG图像的判定
在这里插入图片描述

4.总结

4.1为什么要使用异常值检测

异常值检测通常运用在缺陷检测的项目里面,他的特点是,可以不训练NG图,训练速度快,多特殊缺陷可以快速识别。
其次,可以针对图像中的缺陷类型不固定,缺陷区域不固定,物体大小不一等语义分割无法准确识别的缺陷。

4.2异常值检测缺点

精度不高,由于异常值检测的特性,背景图像需要也会被提取出来,所以在使用异常值检测进行推理时,还需要将物体区域进行预处理提取出来,再与异常区域取交集,所以异常值检测不能单独使用。
其次,对于内容越多的图像,异常值检测的误判率会越高,所以针对内容较多的图像,需要单独分区域去识别,会极大增加程序运行时间

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1503015.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

股票价格预测项目

项目介绍 背景 股票价格预测一直是金融领域的热点问题。准确的预测可以帮助投资者作出更明智的决策。本项目旨在使用机器学习技术,特别是长短期记忆网络(LSTM),来预测股票价格。 目标 开发一个基于LSTM的股票价格预测模型。使…

FreeRtos Queue(五)

本篇主要分析在中断中向队列里发消息xQueueGenericSendFromISR和在中断里从队列中读取消息xQueueReceiveFromISR。 前言: xQueueGenericSendFromISR 和 xQueueReceiveFromISR都是在中断里调用的而不是任务里调用的,所以队列满了或者是队列为空的时候自然就没有把当…

51 软中断的实现

前言 呵呵 中断机制 也是内核中很常见的机制了 中断机制是现代计算机系统中的基本机制之一,它在系统中起着通信网络的作用,以协调系统对各种外部事件的响应和处理,中断是实现多道程序设计的必要条件,中断是CPU 对系统发生的某个…

考研数学——高数:重积分

直角坐标系下二重积分 助记1: 因为一重积分求出的是二维平面的面积,类比得到二重积分得到的是三维的体积 而用之前求旋转体体积的思路:已知截面面积可求得体积。来表示二重积分 在控制一个变量不变(x / y)时&#x…

天猫淘宝详情接口API揭秘:实现个性化商品推荐!

天猫淘宝作为中国最大的电商平台,拥有庞大的商品库存和众多用户,为了提高用户购物体验并满足其个性化需求,天猫淘宝推出了详情接口API,通过智能算法实现个性化商品推荐。联讯数据将为您揭秘详情接口API的实现原理和功能。 个性化商…

Phoenix:去中心化的AI垂直基础设施|JDI Ventures研报

随着文生视频模型 Sora 的问世,AI 领域迎来了又一个里程碑。毫无疑问,由 ChatGPT 所开启的 AI 浪潮已经势不可挡,这是技术的浪潮,也是商业的浪潮,将对人们的生活带来比互联网更为深刻的改变——改变我们的消费、工作和…

RNN(Recurrent Neural Networks)循环神经网络

循环神经网络(Recurrent Neural Network,简称RNN)是一种处理序列数据的神经网络结构,它具有记忆能力,能够捕捉序列中的时序信息。RNN在自然语言处理、时间序列预测等方面有着很多的应用。 一、RNN 的基本结构 RNN的包…

寒假作业Day 08

寒假作业Day 08 一、选择题 1、下列关于 const 和 #define 定义常量的区别,说法不正确的有( ) A: define宏是在预处理阶段展开。const常量是编译运行阶段使用 B: 宏没有类型,不做任何类型检查,仅仅是展开。const常量…

Docker MySQL 报 2059 错误:认证插件 ‘caching_sha2_password‘ 无法加载

使用docker部署的mysql8.0.29再使用Navicat连接myslq报错Authentication plugin ‘xxxxxxx’ cannot be loaded:XXXXXX (无法加载身份验证插件) 原因:mysql8 之前的版本中加密规则是mysql_native_password,而在mysql8之后,加密规…

实现QT中qDebug()的日志重定向

背景: 在项目开发过程中,为了方便分析和排查问题,我们需要将原本输出到控制台的调试信息写入日志文件,进行持久化存储,还可以实现日志分级等。 日志输出格式: 我们需要的格式包括以下内容: 1.…

【Java - 框架 - Mybatis】(01) 普通Java项目使用Mybatis操作Mysql - 快速上手

普通Java项目使用Mybatis操作Mysql - 快速上手 说明 通过软件"IntelliJ IDEA"创建"Maven"项目完成;通过"Mybatis"框架操纵"MySQL"数据库完成操作; 环境 Java版本"1.8.0_202";Windows …

根据QQ号获取暗恋的人的全部歌单

文章目录 前言一、成果展示二、后端开发流程三、前后端障碍与难点解决四、待扩展内容五、总结 前言 本人喜欢使用QQ音乐听歌,并且喜欢点击好友栏目观看最近在听,了解暗恋的人最近在听什么歌曲,知己知彼,百战不殆。但是每次都需要…

Python数据分析实验一:Python数据采集与存储

目录 一、实验目的与要求二、实验过程三、主要程序清单和运行结果1、爬取 “中国南海网” 站点上的相关信息2、爬取天气网站上的北京的历史天气信息 四、程序运行结果五、实验体会 一、实验目的与要求 1、目的: 理解抓取网页数据的一般处理过程;熟悉应用…

JAVA实战开源项目:智能停车场管理系统(Vue+SpringBoot)

目录 一、摘要1.1 项目介绍1.2 项目录屏 二、研究内容A. 车主端功能B. 停车工作人员功能C. 系统管理员功能1. 停车位模块2. 车辆模块3. 停车记录模块4. IC卡模块5. IC卡挂失模块 三、界面展示3.1 登录注册3.2 车辆模块3.3 停车位模块3.4 停车数据模块3.5 IC卡档案模块3.6 IC卡挂…

【python】异常处理

前言 省略各种废话,直接快速整理知识点 try-except 基础 作用 程序不可能永远都是对的,当7除a,a由用户输入时,用户输入0就会报错。try-except就是解决这些问题。 结构 多分支自定义错误类型 上方的exception是一个错误类型…

Unity性能优化篇(七) UI优化注意事项以及使用Sprite Atlas打包精灵图集

UI优化注意事项 1.尽量避免使用IMGUI(OnGUI)来做游戏时的UI,因为IMGUI的开销比较大。 2.如果一个UGUI的控件不需要进行射线检测,则可以取消勾选Raycast Target 3.尽量避免使用完全透明的图片和UI控件。因为即使完全透明,我们看不见它&#xf…

【牛客】HJ87 密码强度等级 CM62 井字棋

题目一:密码强度等级 题目链接:密码强度等级_牛客题霸_牛客网 (nowcoder.com) 本题主要考察C语言中逻辑分支语句,基本语句以及对各种特殊字符 ,ASCII值以及条件表达中的逻辑运算符关系运算符各自功能的理解,以及基本使用&#x…

【linuxC语言】dup、dup2函数

文章目录 前言一、dup函数二、dup2函数三、将标准输出重定向到文件总结 前言 在Linux环境下,dup、dup2以及原子操作都是用于文件描述符管理和处理的重要工具。这些功能提供了对文件描述符进行复制和原子操作的能力,使得在多线程或多进程环境中更加安全和…

qt一个项目有且只有有一个maindow,其他小窗口用QWidget,QDialog是带有yes和no的QWidget

QMaindow QWidget QDialog区别很大 我想要在生成一个小窗口,结果选择基类为maindow,应该是QWidget 然后就出现奇奇怪怪的问题 QMaindow和QWidget不能乱选择,而且各自QPaintEvent也有很多区别 以下就是错误: 我继承maindow的基类…

C#,排列组合的堆生成法(Heap’s Algorithm for generating permutations)算法与源代码

1 排列组合的堆生成法 堆生成算法用于生成n个对象的所有组合。其思想是通过选择一对要交换的元素,在不干扰其他n-2元素的情况下,从先前的组合生成每个组合。 下面是生成n个给定数的所有组合的示例。 示例: 输入:1 2 3 输出&a…