YOLO V8训练自己的数据集并测试

目录

1 YOLOV8部署

2 标注软件labelme安装

3 将labelme转化为YOLOV8支持的数据格式

4 开始训练

5 利用训练结果进行测试


1 YOLOV8部署

        我的一篇博客已经提到,这里不再赘述:

YOLO V8语义分割模型部署-CSDN博客YOLO V8语义分割模型部署https://blog.csdn.net/qq_41694024/article/details/133983334

2 标注软件labelme安装

        我们采用一键安装的方式:

 pip install labelme

        这个对python版本有要求,python版本最好是3.8。如果不是那就再茶ungjiange虚拟环境吧。

        直接命令行输入labelme启动,可能会出现这个问题:

(yo) liuhongwei@liuhongwei-Legion-Y9000P-IRX8H:~/Desktop/ultralytics/examples/YOLOv8-CPP-Inference/build$ labelme
[INFO   ] __init__:get_config:70 - Loading config file from: /home/liuhongwei/.labelmerc
QObject::moveToThread: Current thread (0x564cffaed340) is not the object's thread (0x564d01248510).
Cannot move to target thread (0x564cffaed340)qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "/home/liuhongwei/anaconda3/envs/yo/lib/python3.8/site-packages/cv2/qt/plugins" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.Available platform plugins are: xcb, eglfs, linuxfb, minimal, minimalegl, offscreen, vnc, wayland-egl, wayland, wayland-xcomposite-egl, wayland-xcomposite-glx, webgl.

        这是QT版本太高了.....,降低QT版本:

pip install pyqt5==5.14.0

        再次启动labelme:

        可以用了。

        label使用就是打开一个含有图像的文件夹就可以,使用很简单,上过本科的一看界面就会,给大家展示一张标注结果:

3 将labelme转化为YOLOV8支持的数据格式

        先装依赖:

pip install pycocotools

        用我的脚本将labelme形式的标注文件转化为yolo格式的文件:

'''
Created on Oct 23, 2023
@author: Liuhongwei
'''
import os
import sys
import argparse
import shutil
import math
from collections import OrderedDictimport json
import cv2
import PIL.Imagefrom sklearn.model_selection import train_test_split
from labelme import utilsclass Labelme2YOLO(object):def __init__(self, json_dir):self._json_dir = json_dirself._label_id_map = self._get_label_id_map(self._json_dir)def _make_train_val_dir(self):self._label_dir_path = os.path.join(self._json_dir, 'YOLODataset/labels/')self._image_dir_path = os.path.join(self._json_dir, 'YOLODataset/images/')for yolo_path in (os.path.join(self._label_dir_path + 'train/'), os.path.join(self._label_dir_path + 'val/'),os.path.join(self._image_dir_path + 'train/'), os.path.join(self._image_dir_path + 'val/')):if os.path.exists(yolo_path):shutil.rmtree(yolo_path)os.makedirs(yolo_path)    def _get_label_id_map(self, json_dir):label_set = set()for file_name in os.listdir(json_dir):if file_name.endswith('json'):json_path = os.path.join(json_dir, file_name)data = json.load(open(json_path))for shape in data['shapes']:label_set.add(shape['label'])return OrderedDict([(label, label_id) \for label_id, label in enumerate(label_set)])def _train_test_split(self, folders, json_names, val_size):if len(folders) > 0 and 'train' in folders and 'val' in folders:train_folder = os.path.join(self._json_dir, 'train/')train_json_names = [train_sample_name + '.json' \for train_sample_name in os.listdir(train_folder) \if os.path.isdir(os.path.join(train_folder, train_sample_name))]val_folder = os.path.join(self._json_dir, 'val/')val_json_names = [val_sample_name + '.json' \for val_sample_name in os.listdir(val_folder) \if os.path.isdir(os.path.join(val_folder, val_sample_name))]return train_json_names, val_json_namestrain_idxs, val_idxs = train_test_split(range(len(json_names)), test_size=val_size)train_json_names = [json_names[train_idx] for train_idx in train_idxs]val_json_names = [json_names[val_idx] for val_idx in val_idxs]return train_json_names, val_json_namesdef convert(self, val_size):json_names = [file_name for file_name in os.listdir(self._json_dir) \if os.path.isfile(os.path.join(self._json_dir, file_name)) and \file_name.endswith('.json')]folders =  [file_name for file_name in os.listdir(self._json_dir) \if os.path.isdir(os.path.join(self._json_dir, file_name))]train_json_names, val_json_names = self._train_test_split(folders, json_names, val_size)self._make_train_val_dir()# convert labelme object to yolo format object, and save them to files# also get image from labelme json file and save them under images folderfor target_dir, json_names in zip(('train/', 'val/'), (train_json_names, val_json_names)):for json_name in json_names:json_path = os.path.join(self._json_dir, json_name)json_data = json.load(open(json_path))print('Converting %s for %s ...' % (json_name, target_dir.replace('/', '')))img_path = self._save_yolo_image(json_data, json_name, self._image_dir_path, target_dir)yolo_obj_list = self._get_yolo_object_list(json_data, img_path)self._save_yolo_label(json_name, self._label_dir_path, target_dir, yolo_obj_list)print('Generating dataset.yaml file ...')self._save_dataset_yaml()def convert_one(self, json_name):json_path = os.path.join(self._json_dir, json_name)json_data = json.load(open(json_path))print('Converting %s ...' % json_name)img_path = self._save_yolo_image(json_data, json_name, self._json_dir, '')yolo_obj_list = self._get_yolo_object_list(json_data, img_path)self._save_yolo_label(json_name, self._json_dir, '', yolo_obj_list)def _get_yolo_object_list(self, json_data, img_path):yolo_obj_list = []img_h, img_w, _ = cv2.imread(img_path).shapefor shape in json_data['shapes']:# labelme circle shape is different from others# it only has 2 points, 1st is circle center, 2nd is drag end pointif shape['shape_type'] == 'circle':yolo_obj = self._get_circle_shape_yolo_object(shape, img_h, img_w)else:yolo_obj = self._get_other_shape_yolo_object(shape, img_h, img_w)yolo_obj_list.append(yolo_obj)return yolo_obj_listdef _get_circle_shape_yolo_object(self, shape, img_h, img_w):obj_center_x, obj_center_y = shape['points'][0]radius = math.sqrt((obj_center_x - shape['points'][1][0]) ** 2 + (obj_center_y - shape['points'][1][1]) ** 2)obj_w = 2 * radiusobj_h = 2 * radiusyolo_center_x= round(float(obj_center_x / img_w), 6)yolo_center_y = round(float(obj_center_y / img_h), 6)yolo_w = round(float(obj_w / img_w), 6)yolo_h = round(float(obj_h / img_h), 6)label_id = self._label_id_map[shape['label']]return label_id, yolo_center_x, yolo_center_y, yolo_w, yolo_hdef _get_other_shape_yolo_object(self, shape, img_h, img_w):def __get_object_desc(obj_port_list):__get_dist = lambda int_list: max(int_list) - min(int_list)x_lists = [port[0] for port in obj_port_list]        y_lists = [port[1] for port in obj_port_list]return min(x_lists), __get_dist(x_lists), min(y_lists), __get_dist(y_lists)obj_x_min, obj_w, obj_y_min, obj_h = __get_object_desc(shape['points'])yolo_center_x= round(float((obj_x_min + obj_w / 2.0) / img_w), 6)yolo_center_y = round(float((obj_y_min + obj_h / 2.0) / img_h), 6)yolo_w = round(float(obj_w / img_w), 6)yolo_h = round(float(obj_h / img_h), 6)label_id = self._label_id_map[shape['label']]return label_id, yolo_center_x, yolo_center_y, yolo_w, yolo_hdef _save_yolo_label(self, json_name, label_dir_path, target_dir, yolo_obj_list):txt_path = os.path.join(label_dir_path, target_dir, json_name.replace('.json', '.txt'))with open(txt_path, 'w+') as f:for yolo_obj_idx, yolo_obj in enumerate(yolo_obj_list):yolo_obj_line = '%s %s %s %s %s\n' % yolo_obj \if yolo_obj_idx + 1 != len(yolo_obj_list) else \'%s %s %s %s %s' % yolo_objf.write(yolo_obj_line)def _save_yolo_image(self, json_data, json_name, image_dir_path, target_dir):img_name = json_name.replace('.json', '.png')img_path = os.path.join(image_dir_path, target_dir,img_name)if not os.path.exists(img_path):img = utils.img_b64_to_arr(json_data['imageData'])PIL.Image.fromarray(img).save(img_path)return img_pathdef _save_dataset_yaml(self):yaml_path = os.path.join(self._json_dir, 'YOLODataset/', 'dataset.yaml')with open(yaml_path, 'w+') as yaml_file:yaml_file.write('train: %s\n' % \os.path.join(self._image_dir_path, 'train/'))yaml_file.write('val: %s\n\n' % \os.path.join(self._image_dir_path, 'val/'))yaml_file.write('nc: %i\n\n' % len(self._label_id_map))names_str = ''for label, _ in self._label_id_map.items():names_str += "'%s', " % labelnames_str = names_str.rstrip(', ')yaml_file.write('names: [%s]' % names_str)if __name__ == '__main__':parser = argparse.ArgumentParser()parser.add_argument('--json_dir',type=str,help='Please input the path of the labelme json files.')parser.add_argument('--val_size',type=float, nargs='?', default=None,help='Please input the validation dataset size, for example 0.1 ')parser.add_argument('--json_name',type=str, nargs='?', default=None,help='If you put json name, it would convert only one json file to YOLO.')args = parser.parse_args(sys.argv[1:])convertor = Labelme2YOLO(args.json_dir)if args.json_name is None:convertor.convert(val_size=args.val_size)else:convertor.convert_one(args.json_name)

        将标注文件全部放在labelmeannotation文件夹内:

        启动脚本,参数1为这个文件夹,参数2为val占数据集的比例,比如是0.1。命令如下:

 python 222.py --json_dir labelmeannotation/ --val_size 0.1

        开始转换ing:

        转化完毕:

        转化好的文件在labelmeannotation文件夹内。

        我们把这个文件拷贝到yolo的主目录下:

        新建一个文件default_copy.yaml,里面有几个部分注意修改。

# Ultralytics YOLO 🚀, AGPL-3.0 license
# Default training settings and hyperparameters for medium-augmentation COCO trainingtask: detect  # (str) YOLO task, i.e. detect, segment, classify, pose
mode: train  # (str) YOLO mode, i.e. train, val, predict, export, track, benchmark# Train settings -------------------------------------------------------------------------------------------------------
model:  # (str, optional) path to model file, i.e. yolov8n.pt, yolov8n.yaml
data: /home/liuhongwei/Desktop/ultralytics/YOLODataset/dataset.yaml # (str, optional) path to data file, i.e. coco128.yaml
epochs: 300  # (int) number of epochs to train for
patience: 50  # (int) epochs to wait for no observable improvement for early stopping of training
batch: -1  # (int) number of images per batch (-1 for AutoBatch)
imgsz: 640  # (int | list) input images size as int for train and val modes, or list[w,h] for predict and export modes
save: True  # (bool) save train checkpoints and predict results
save_period: -1 # (int) Save checkpoint every x epochs (disabled if < 1)
cache: False  # (bool) True/ram, disk or False. Use cache for data loading
device: 0  # (int | str | list, optional) device to run on, i.e. cuda device=0 or device=0,1,2,3 or device=cpu
workers: 16  # (int) number of worker threads for data loading (per RANK if DDP)
project:  # (str, optional) project name
name: /home/liuhongwei/Desktop/ultralytics/666/ # (str, optional) experiment name, results saved to 'project/name' directory
exist_ok: False  # (bool) whether to overwrite existing experiment
pretrained: True  # (bool | str) whether to use a pretrained model (bool) or a model to load weights from (str)
optimizer: auto  # (str) optimizer to use, choices=[SGD, Adam, Adamax, AdamW, NAdam, RAdam, RMSProp, auto]
verbose: True  # (bool) whether to print verbose output
seed: 0  # (int) random seed for reproducibility
deterministic: True  # (bool) whether to enable deterministic mode
single_cls: False  # (bool) train multi-class data as single-class
rect: False  # (bool) rectangular training if mode='train' or rectangular validation if mode='val'
cos_lr: False  # (bool) use cosine learning rate scheduler
close_mosaic: 10  # (int) disable mosaic augmentation for final epochs (0 to disable)
resume: False  # (bool) resume training from last checkpoint
amp: True  # (bool) Automatic Mixed Precision (AMP) training, choices=[True, False], True runs AMP check
fraction: 1.0  # (float) dataset fraction to train on (default is 1.0, all images in train set)
profile: False  # (bool) profile ONNX and TensorRT speeds during training for loggers
freeze: None  # (int | list, optional) freeze first n layers, or freeze list of layer indices during training
# Segmentation
overlap_mask: True  # (bool) masks should overlap during training (segment train only)
mask_ratio: 4  # (int) mask downsample ratio (segment train only)
# Classification
dropout: 0.0  # (float) use dropout regularization (classify train only)# Val/Test settings ----------------------------------------------------------------------------------------------------
val: True  # (bool) validate/test during training
split: val  # (str) dataset split to use for validation, i.e. 'val', 'test' or 'train'
save_json: False  # (bool) save results to JSON file
save_hybrid: False  # (bool) save hybrid version of labels (labels + additional predictions)
conf:  # (float, optional) object confidence threshold for detection (default 0.25 predict, 0.001 val)
iou: 0.7  # (float) intersection over union (IoU) threshold for NMS
max_det: 300  # (int) maximum number of detections per image
half: False  # (bool) use half precision (FP16)
dnn: False  # (bool) use OpenCV DNN for ONNX inference
plots: True  # (bool) save plots during train/val# Prediction settings --------------------------------------------------------------------------------------------------
source:  # (str, optional) source directory for images or videos
show: False  # (bool) show results if possible
save_txt: False  # (bool) save results as .txt file
save_conf: False  # (bool) save results with confidence scores
save_crop: False  # (bool) save cropped images with results
show_labels: True  # (bool) show object labels in plots
show_conf: True  # (bool) show object confidence scores in plots
vid_stride: 1  # (int) video frame-rate stride
stream_buffer: False  # (bool) buffer all streaming frames (True) or return the most recent frame (False)
line_width:   # (int, optional) line width of the bounding boxes, auto if missing
visualize: False  # (bool) visualize model features
augment: False  # (bool) apply image augmentation to prediction sources
agnostic_nms: False  # (bool) class-agnostic NMS
classes:  # (int | list[int], optional) filter results by class, i.e. classes=0, or classes=[0,2,3]
retina_masks: False  # (bool) use high-resolution segmentation masks
boxes: True  # (bool) Show boxes in segmentation predictions# Export settings ------------------------------------------------------------------------------------------------------
format: torchscript  # (str) format to export to, choices at https://docs.ultralytics.com/modes/export/#export-formats
keras: False  # (bool) use Kera=s
optimize: False  # (bool) TorchScript: optimize for mobile
int8: False  # (bool) CoreML/TF INT8 quantization
dynamic: False  # (bool) ONNX/TF/TensorRT: dynamic axes
simplify: False  # (bool) ONNX: simplify model
opset:  # (int, optional) ONNX: opset version
workspace: 4  # (int) TensorRT: workspace size (GB)
nms: False  # (bool) CoreML: add NMS# Hyperparameters ------------------------------------------------------------------------------------------------------
lr0: 0.01  # (float) initial learning rate (i.e. SGD=1E-2, Adam=1E-3)
lrf: 0.01  # (float) final learning rate (lr0 * lrf)
momentum: 0.937  # (float) SGD momentum/Adam beta1
weight_decay: 0.0005  # (float) optimizer weight decay 5e-4
warmup_epochs: 3.0  # (float) warmup epochs (fractions ok)
warmup_momentum: 0.8  # (float) warmup initial momentum
warmup_bias_lr: 0.1  # (float) warmup initial bias lr
box: 7.5  # (float) box loss gain
cls: 0.5  # (float) cls loss gain (scale with pixels)
dfl: 1.5  # (float) dfl loss gain
pose: 12.0  # (float) pose loss gain
kobj: 1.0  # (float) keypoint obj loss gain
label_smoothing: 0.0  # (float) label smoothing (fraction)
nbs: 64  # (int) nominal batch size
hsv_h: 0.015  # (float) image HSV-Hue augmentation (fraction)
hsv_s: 0.7  # (float) image HSV-Saturation augmentation (fraction)
hsv_v: 0.4  # (float) image HSV-Value augmentation (fraction)
degrees: 0.0  # (float) image rotation (+/- deg)
translate: 0.1  # (float) image translation (+/- fraction)
scale: 0.5  # (float) image scale (+/- gain)
shear: 0.0  # (float) image shear (+/- deg)
perspective: 0.0  # (float) image perspective (+/- fraction), range 0-0.001
flipud: 0.0  # (float) image flip up-down (probability)
fliplr: 0.5  # (float) image flip left-right (probability)
mosaic: 1.0  # (float) image mosaic (probability)
mixup: 0.0  # (float) image mixup (probability)
copy_paste: 0.0  # (float) segment copy-paste (probability)# Custom config.yaml ---------------------------------------------------------------------------------------------------
cfg:  # (str, optional) for overriding defaults.yaml# Tracker settings ------------------------------------------------------------------------------------------------------
tracker: botsort.yaml  # (str) tracker type, choices=[botsort.yaml, bytetrack.yaml]

        1.data:改成我们生成文件的dataset.yaml文件路径 其他就用我的就行了

4 开始训练

        将YOLODataset文件夹移动到ultralytics文件夹(YOLO主目录),修改/home/liuhongwei/Desktop/ultralytics/YOLODataset/datasetsyaml文件,改成绝对路径。

train: /home/liuhongwei/Desktop/ultralytics/YOLODataset/images/train/
val: /home/liuhongwei/Desktop/ultralytics/YOLODataset/images/val/nc: 6names: ['ZD', 'XALYS', 'ZZS', 'BH', 'SQL', 'HPYS']

       打开我们的yolo环境输入开始训练

yolo cfg=/home/liuhongwei/Desktop/ultralytics/default_copy.yaml

        开始训练!这里训练300个epoch!GPU一定显存一定要大!!!mAP一直提高,yolo内部损失函数计算做的很好。

        训练完毕!

        得到我们的训练结果:

5 利用训练结果进行测试

        YOLOV8为我们封装好了测试的功能包:

        直接调用我的代码即可:

from ultralytics import YOLO# 预测
model = YOLO("/home/liuhongwei/Desktop/ultralytics/YOLODataset/runs/detect/train2/weights/best.pt")
source = "/home/liuhongwei/Desktop/ultralytics/test_images"
results = model.predict(source,save=True,show_conf=True)  # predict on an image
print('ok')

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

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【仙逆】王林用计灭富二代,有长命锁也没用,藤化元一怒请一人出山

【侵权联系删除】【文/郑尔巴金】 仙逆动漫第七集已经更新了。而这一集看下来&#xff0c;可以说非常精彩&#xff0c;全程在打&#xff0c;期间还能看到主角王林用谋&#xff0c;是如何一步步的把敌人藤厉引入陷阱灭杀的&#xff0c;更可以看到王林是如何筑基的。那么多的不说…

Xcode14创建github远程仓库Token

1.点击Create a Token on GitHub 2.在打开的网页中,登陆GitHub 3.点击生成Token 这是不能为空 4.Token创建成功如下: 5.复制Token到Xcode然后点击Sign In登陆 正在创建远程我仓库 正在将本地仓库代码推入远程仓库 创建成功

深入理解算法:从基础到实践

深入理解算法&#xff1a;从基础到实践 1. 算法的定义2. 算法的特性3. 算法的分类按解决问题的性质分类&#xff1a;按算法的设计思路分类&#xff1a; 4. 算法分析5. 算法示例a. 搜索算法示例&#xff1a;二分搜索b. 排序算法示例&#xff1a;快速排序c. 动态规划示例&#xf…

07、Python -- 序列相关函数与封包解包

目录 使用函数字符串也能比较大小序列封包序列解包多变量同时赋值 最大值、最小值、长度 序列解包与封包 使用函数 len()、max()、min() 函数可获取元组、列表的长度、最大值和最小值。 字符串也能比较大小 字符串比较大小时&#xff0c;将会依次按字符串中每个字符对应的编…

华为eNSP配置专题-RIP路由协议的配置

文章目录 华为eNSP配置专题-RIP路由协议的配置0、概要介绍1、前置环境1.1、宿主机1.2、eNSP模拟器 2、基本环境搭建2.1、终端构成和连接2.2、终端的基本配置 3、RIP路由的配置3.1、RIP路由的配置3.2、RIP路由的删除 华为eNSP配置专题-RIP路由协议的配置 0、概要介绍 路由信息…

【python入门篇】字符串(4)

这一章节来说下字符串的使用&#xff0c;字符串是 Python 中最常用的数据类型&#xff0c;我们可以使用单引号( &#xff09;或 双引号&#xff08; " )来创建字符串&#xff0c;那么接下来就进入本章节的一个学习。 一、环境配置 我这边python的环境是3.7.8版本的&…

2024王道考研计算机组成原理——指令系统

零、本章概要 指令寻址&#xff1a;解决的是PC"1"的问题 数据寻址&#xff1a;使用寄存器/内存/结合 基址寻址&#xff1a;用于多道程序的并发执行 直接寻址&#xff1a;call 0x12345678 变址寻址&#xff1a;esi edi用于循环&#xff0c;因为使用直接寻址需要一堆…

dashboard报错 错误:无法获取网络列表、dashboard报错 错误:无法获取云主机列表 解决流程

文章目录 错误说明dashboard上报错底层命令报错查看日志message日志httpd报错日志错误日志分析开始解决测试底层命令dashboard错误说明 dashboard上报错 首先,dashboard上无论是管理员还是其他项目,均无法获取云主机和网络信息,具体报错如下

uniapp实现登录组件之外区域置灰并引导登录

实现需求 每个页面需要根据用户是否登录决定是否显示登陆组件,登录组件半屏底部显示,登录组件之外区域置灰,功能按钮点击之后引导提示登录.页面效果如下: 实现思路说明 设置登录组件背景颜色为灰色,将页面分成登录区域(底部)和非登陆区域(上面灰色显示部分), 置灰区域添加…

《深度学习推荐系统》王喆 笔记

这个笔记&#xff0c;是我记录的阅读该书&#xff0c;对我比较有用的一些点。不算是能完全覆盖全书知识点的笔记。 能完全覆盖全书知识点&#xff0c;比较详尽的笔记&#xff0c;可以参考如下。 《深度学习推荐系统》超级详细读书笔记https://www.zhihu.com/tardis/bd/art/44…

【PSO-RFR预测】基于粒子群算法优化随机森林回归预测研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

1024程序员节特辑 | 深度解析C/C++内存管理(建议收藏!!)

1024程序员节特辑 | 深度解析C/C内存管理&#xff08;建议收藏&#xff01;&#xff01;&#xff09; 一、C/C内存分布1.1 相关例题 二、 C语言中动态内存管理方式&#xff1a;malloc/calloc/realloc/free2.1 相关面试题 三、C内存管理方式3.1 new/delete操作内置类型3.2 new和…

LeetCode刷题---简单组(一)

文章目录 &#x1f352;题目一 507. 完美数&#x1f352;解法一 &#x1f352;题目二 2678. 老人的数目&#x1f352;解法一 &#x1f352;题目三 520. 检测大写字母&#x1f352;解法一&#x1f352;解法二 &#x1f352;题目一 507. 完美数 对于一个 正整数&#xff0c;如果它…

【茫茫架构路】1. Class File字节码文件解析

本文所有内容的JDK版本为 OpenJDK 11 JDK11 Class File官方说明。 Java解析字节码文件源码参考&#xff0c;以下为部分字节码解析源码展示。 public ClassFile(DataInputStream in) {try {//magic: 0xCAFEBABEthis.magic ClassReader.readInt(in);System.out.println("m…

【C++】继承 ⑧ ( 继承 + 组合 模式的类对象 构造函数 和 析构函数 调用规则 )

文章目录 一、继承 组合 模式的类对象 构造函数和析构函数调用规则1、场景说明2、调用规则 二、完整代码示例分析1、代码分析2、代码示例 一、继承 组合 模式的类对象 构造函数和析构函数调用规则 1、场景说明 如果一个类 既 继承了 基类 ,又 在类中 维护了一个 其它类型 的…

Java基础(第一期):IDEA的下载和安装(步骤图) 项目结构的介绍 项目、模块、类的创建。第一个代码的实现

文章目录 IDEA1.1 IDEA概述1.2 IDEA的下载和安装1.2.1 下载1.2.2 安装 1.3 IDEA中层级结构介绍1.3.1 结构分类1.3.2 结构介绍project&#xff08;项目、工程&#xff09;module&#xff08;模块&#xff09;package&#xff08;包&#xff09;class&#xff08;类&#xff09; …

如何能够获取到本行业的能力架构图去了解自己的能力缺陷与短板,从而能清晰的去弥补差距?

如何能够获取到本行业的能力架构图去了解自己的能力缺陷与短板&#xff0c;从而能清晰的去弥补差距&#xff1f; 获取并利用能力架构图&#xff08;Competency Model&#xff09;来了解自己在特定行业或职位中的能力缺陷和短板&#xff0c;并据此弥补差距&#xff0c;是一个非常…

BetaFlight飞控AOCODAF435V2MPU6500固件编译

BetaFlight飞控AOCODAF435V2MPU6500固件编译 1. 源由2. 准备2.1 板子2.2 代码2.3 工具 3. 配置修改4. 编译4.1 获取代码4.2 获取配置4.3 编译固件4.4 DFU烧录4.5 版本核对 5. 总结6. 跟踪问题 1. 源由 刚拿到一块Aocoda F405V2 (MPU6500) AT32F435飞控板(替换主控芯片)。 Ao…

css伪类元素使用技巧 表达input父级聚焦css实现

:focus-within 可以让它自己被聚焦或者它的后代元素被聚焦input 中有required 加星号在这里插入图片描述

Rust 中的String与所有权机制

文章目录 一、string二、所有权2.1 所有权与作用域2.2 对所有权的操作2.2.1 转移2.2.3 拷贝2.2.3 传递 2.3 引用2.3.1 借用2.3.2 可变引用 一、string 之前学习过 Rust 只有几种基础的数据类型&#xff0c;但是没有常用的字符串也就是String&#xff0c;今天来学习一下 String…