亚博microros小车-原生ubuntu支持系列:11手指控制与手势识别

识别框架还是沿用之前的了MediaPipe Hand。

背景知识不摘重复,参见之前的:亚博microros小车-原生ubuntu支持系列:10-画笔-CSDN博客

手指控制

src/yahboom_esp32_mediapipe/yahboom_esp32_mediapipe/目录下新建文件10_HandCtrl.py,代码如下:

#!/usr/bin/env python3
# encoding: utf-8
import math
import time
import cv2 as cv
import numpy as np
import mediapipe as mp
import rclpy
from rclpy.node import Node
from cv_bridge import CvBridge
from sensor_msgs.msg import Image, CompressedImagefrom rclpy.time import Time
import datetimevolPer = value = index = 0
effect = ["color", "thresh", "blur", "hue", "enhance"]
volBar = 400
class handDetector:def __init__(self, mode=False, maxHands=2, detectorCon=0.5, trackCon=0.5):self.tipIds = [4, 8, 12, 16, 20]self.mpHand = mp.solutions.handsself.mpDraw = mp.solutions.drawing_utilsself.hands = self.mpHand.Hands(#模型初始化static_image_mode=mode,max_num_hands=maxHands,min_detection_confidence=detectorCon,min_tracking_confidence=trackCon)self.lmDrawSpec = mp.solutions.drawing_utils.DrawingSpec(color=(0, 0, 255), thickness=-1, circle_radius=15)self.drawSpec = mp.solutions.drawing_utils.DrawingSpec(color=(0, 255, 0), thickness=10, circle_radius=10)#距离计算def get_dist(self, point1, point2):x1, y1 = point1x2, y2 = point2return abs(math.sqrt(math.pow(abs(y1 - y2), 2) + math.pow(abs(x1 - x2), 2)))#计算角度def calc_angle(self, pt1, pt2, pt3):point1 = self.lmList[pt1][1], self.lmList[pt1][2]point2 = self.lmList[pt2][1], self.lmList[pt2][2]point3 = self.lmList[pt3][1], self.lmList[pt3][2]a = self.get_dist(point1, point2)b = self.get_dist(point2, point3)c = self.get_dist(point1, point3)try:#余弦定理radian = math.acos((math.pow(a, 2) + math.pow(b, 2) - math.pow(c, 2)) / (2 * a * b))angle = radian / math.pi * 180#弧度转角度except:angle = 0return abs(angle)def findHands(self, frame, draw=True):img = np.zeros(frame.shape, np.uint8)img_RGB = cv.cvtColor(frame, cv.COLOR_BGR2RGB)#图像格式转换self.results = self.hands.process(img_RGB)#检测if self.results.multi_hand_landmarks:for handLms in self.results.multi_hand_landmarks:#输出关键点if draw: self.mpDraw.draw_landmarks(img, handLms, self.mpHand.HAND_CONNECTIONS)return imgdef findPosition(self, frame, draw=True):self.lmList = []if self.results.multi_hand_landmarks:for id, lm in enumerate(self.results.multi_hand_landmarks[0].landmark):# print(id,lm)h, w, c = frame.shapecx, cy = int(lm.x * w), int(lm.y * h)# print(id, lm.x, lm.y, lm.z)self.lmList.append([id, cx, cy])#记录指点序号与坐标if draw: cv.circle(frame, (cx, cy), 15, (0, 0, 255), cv.FILLED)return self.lmListdef frame_combine(slef,frame, src):if len(frame.shape) == 3:frameH, frameW = frame.shape[:2]srcH, srcW = src.shape[:2]dst = np.zeros((max(frameH, srcH), frameW + srcW, 3), np.uint8)dst[:, :frameW] = frame[:, :]dst[:, frameW:] = src[:, :]else:src = cv.cvtColor(src, cv.COLOR_BGR2GRAY)frameH, frameW = frame.shape[:2]imgH, imgW = src.shape[:2]dst = np.zeros((frameH, frameW + imgW), np.uint8)dst[:, :frameW] = frame[:, :]dst[:, frameW:] = src[:, :]return dstclass MY_Picture(Node):def __init__(self, name):super().__init__(name)self.bridge = CvBridge()self.sub_img = self.create_subscription(CompressedImage, '/espRos/esp32camera', self.handleTopic, 1) #获取esp32传来的图像self.hand_detector = handDetector()self.volPer = self.value = self.index = 0self.effect = ["color", "thresh", "blur", "hue", "enhance"]self.volBar = 400self.last_stamp = Noneself.new_seconds = 0self.fps_seconds = 1def handleTopic(self, msg):self.last_stamp = msg.header.stamp  if self.last_stamp:total_secs = Time(nanoseconds=self.last_stamp.nanosec, seconds=self.last_stamp.sec).nanosecondsdelta = datetime.timedelta(seconds=total_secs * 1e-9)seconds = delta.total_seconds()*100if self.new_seconds != 0:self.fps_seconds = seconds - self.new_secondsself.new_seconds = seconds#保留这次的值start = time.time()frame = self.bridge.compressed_imgmsg_to_cv2(msg)frame = cv.resize(frame, (640, 480))action = cv.waitKey(1) & 0xFFimg  = self.hand_detector.findHands(frame)lmList = self.hand_detector.findPosition(frame, draw=False)if len(lmList) != 0:angle = self.hand_detector.calc_angle(4, 0, 8)#计算拇指,0点,食指尖的角度x1, y1 = lmList[4][1], lmList[4][2]x2, y2 = lmList[8][1], lmList[8][2]cx, cy = (x1 + x2) // 2, (y1 + y2) // 2cv.circle(img, (x1, y1), 15, (255, 0, 255), cv.FILLED)cv.circle(img, (x2, y2), 15, (255, 0, 255), cv.FILLED)cv.line(img, (x1, y1), (x2, y2), (255, 0, 255), 3)cv.circle(img, (cx, cy), 15, (255, 0, 255), cv.FILLED)if angle <= 10: cv.circle(img, (cx, cy), 15, (0, 255, 0), cv.FILLED)self.volBar = np.interp(angle, [0, 70], [400, 150])self.volPer = np.interp(angle, [0, 70], [0, 100])self.value = np.interp(angle, [0, 70], [0, 255])# print("angle: {},self.value: {}".format(angle, self.value))print(f'mode:{self.effect[self.index]}')# 进行阈值二值化操作,大于阈值value的,使用255表示,小于阈值value的,使用0表示if self.effect[self.index]=="thresh":gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)frame = cv.threshold(gray, self.value, 255, cv.THRESH_BINARY)[1]# 进行高斯滤波,(21, 21)表示高斯矩阵的长与宽都是21,标准差取valueelif self.effect[self.index]=="blur":frame = cv.GaussianBlur(frame, (21, 21), np.interp(self.value, [0, 255], [0, 11]))# 色彩空间的转化,HSV转换为BGRelif self.effect[self.index]=="hue":frame = cv.cvtColor(frame, cv.COLOR_BGR2HSV)frame[:, :, 0] += int(self.value)frame = cv.cvtColor(frame, cv.COLOR_HSV2BGR)# 调节对比度elif self.effect[self.index]=="enhance":enh_val = self.value / 40clahe = cv.createCLAHE(clipLimit=enh_val, tileGridSize=(8, 8))lab = cv.cvtColor(frame, cv.COLOR_BGR2LAB)lab[:, :, 0] = clahe.apply(lab[:, :, 0])frame = cv.cvtColor(lab, cv.COLOR_LAB2BGR)if action == ord('f'):self.index += 1if self.index >= len(self.effect): self.index = 0end = time.time()fps = 1 / ((end - start)+self.fps_seconds)text = "FPS : " + str(int(fps))cv.putText(frame, text, (20, 30), cv.FONT_HERSHEY_SIMPLEX, 0.9, (0, 0, 255), 1)cv.rectangle(img, (50, 150), (85, 400), (255, 0, 0), 3)cv.rectangle(img, (50, int(self.volBar)), (85, 400), (0, 255, 0), cv.FILLED)cv.putText(img, f'{int(self.volPer)}%', (40, 450), cv.FONT_HERSHEY_COMPLEX, 1, (0, 255, 0), 3)dst = self.hand_detector.frame_combine(frame, img)cv.imshow('dst', dst)def main():print("start it")rclpy.init()esp_img = MY_Picture("My_Picture")try:rclpy.spin(esp_img)except KeyboardInterrupt:passfinally:esp_img.destroy_node()rclpy.shutdown()

订阅esp32传出来的图像后,通过MediaPipe去做相关的识别后,再通过记录手指的点坐标,计算角4-0-8之间度数。本节与之前不同,增加了opencv输出的格式,"color", "thresh", "blur", "hue", "enhance"。默认是color,还有阈值化输出,高斯模糊等其他效果。按F键切换

构建后运行:

ros2 run yahboom_esp32_mediapipe HandCtrl

效果如下:

手势识别

src/yahboom_esp32_mediapipe/yahboom_esp32_mediapipe/目录下新建文件11_GestureRecognition.py,代码如下

#!/usr/bin/env python3
# encoding: utf-8
import math
import time
import cv2 as cv
import numpy as np
import mediapipe as mp
import rclpy
from rclpy.node import Node
from cv_bridge import CvBridge
from sensor_msgs.msg import Image, CompressedImagefrom rclpy.time import Time
import datetimeclass handDetector:def __init__(self, mode=False, maxHands=2, detectorCon=0.5, trackCon=0.5):self.tipIds = [4, 8, 12, 16, 20]self.mpHand = mp.solutions.handsself.mpDraw = mp.solutions.drawing_utilsself.hands = self.mpHand.Hands(static_image_mode=mode,max_num_hands=maxHands,min_detection_confidence=detectorCon,min_tracking_confidence=trackCon)self.lmList = []self.lmDrawSpec = mp.solutions.drawing_utils.DrawingSpec(color=(0, 0, 255), thickness=-1, circle_radius=6)self.drawSpec = mp.solutions.drawing_utils.DrawingSpec(color=(0, 255, 0), thickness=2, circle_radius=2)def get_dist(self, point1, point2):x1, y1 = point1x2, y2 = point2return abs(math.sqrt(math.pow(abs(y1 - y2), 2) + math.pow(abs(x1 - x2), 2)))def calc_angle(self, pt1, pt2, pt3):point1 = self.lmList[pt1][1], self.lmList[pt1][2]point2 = self.lmList[pt2][1], self.lmList[pt2][2]point3 = self.lmList[pt3][1], self.lmList[pt3][2]a = self.get_dist(point1, point2)b = self.get_dist(point2, point3)c = self.get_dist(point1, point3)try:radian = math.acos((math.pow(a, 2) + math.pow(b, 2) - math.pow(c, 2)) / (2 * a * b))angle = radian / math.pi * 180except:angle = 0return abs(angle)def findHands(self, frame, draw=True):self.lmList = []img = np.zeros(frame.shape, np.uint8)img_RGB = cv.cvtColor(frame, cv.COLOR_BGR2RGB)self.results = self.hands.process(img_RGB)if self.results.multi_hand_landmarks:for i in range(len(self.results.multi_hand_landmarks)):if draw: self.mpDraw.draw_landmarks(frame, self.results.multi_hand_landmarks[i], self.mpHand.HAND_CONNECTIONS, self.lmDrawSpec, self.drawSpec)self.mpDraw.draw_landmarks(img, self.results.multi_hand_landmarks[i], self.mpHand.HAND_CONNECTIONS, self.lmDrawSpec, self.drawSpec)for id, lm in enumerate(self.results.multi_hand_landmarks[i].landmark):h, w, c = frame.shapecx, cy = int(lm.x * w), int(lm.y * h)self.lmList.append([id, cx, cy])return frame, imgdef frame_combine(slef,frame, src):if len(frame.shape) == 3:frameH, frameW = frame.shape[:2]srcH, srcW = src.shape[:2]dst = np.zeros((max(frameH, srcH), frameW + srcW, 3), np.uint8)dst[:, :frameW] = frame[:, :]dst[:, frameW:] = src[:, :]else:src = cv.cvtColor(src, cv.COLOR_BGR2GRAY)frameH, frameW = frame.shape[:2]imgH, imgW = src.shape[:2]dst = np.zeros((frameH, frameW + imgW), np.uint8)dst[:, :frameW] = frame[:, :]dst[:, frameW:] = src[:, :]return dstdef fingersUp(self):fingers=[]# Thumbif (self.calc_angle(self.tipIds[0],self.tipIds[0] - 1,self.tipIds[0] - 2) > 150.0) and (self.calc_angle(self.tipIds[0] - 1,self.tipIds[0] - 2,self.tipIds[0] - 3) > 150.0): fingers.append(1)else:fingers.append(0)# 4 fingerfor id in range(1, 5):if self.lmList[self.tipIds[id]][2] < self.lmList[self.tipIds[id] - 2][2]:fingers.append(1)else:fingers.append(0)return fingersdef get_gesture(self):gesture = ""fingers = self.fingersUp()if self.lmList[self.tipIds[0]][2] > self.lmList[self.tipIds[1]][2] and \self.lmList[self.tipIds[0]][2] > self.lmList[self.tipIds[2]][2] and \self.lmList[self.tipIds[0]][2] > self.lmList[self.tipIds[3]][2] and \self.lmList[self.tipIds[0]][2] > self.lmList[self.tipIds[4]][2] : gesture = "Thumb_down"elif self.lmList[self.tipIds[0]][2] < self.lmList[self.tipIds[1]][2] and \self.lmList[self.tipIds[0]][2] < self.lmList[self.tipIds[2]][2] and \self.lmList[self.tipIds[0]][2] < self.lmList[self.tipIds[3]][2] and \self.lmList[self.tipIds[0]][2] < self.lmList[self.tipIds[4]][2] and \self.calc_angle(self.tipIds[1] - 1, self.tipIds[1] - 2, self.tipIds[1] - 3) < 150.0 : gesture = "Thumb_up"if fingers.count(1) == 3 or fingers.count(1) == 4:if fingers[0] == 1 and (self.get_dist(self.lmList[4][1:], self.lmList[8][1:])<self.get_dist(self.lmList[4][1:], self.lmList[5][1:])): gesture = "OK"elif fingers[2] == fingers[3] == 0: gesture = "Rock"elif fingers.count(1) == 3: gesture = "Three"else: gesture = "Four"elif fingers.count(1) == 0: gesture = "Zero"elif fingers.count(1) == 1: gesture = "One"elif fingers.count(1) == 2:if fingers[0] == 1 and fingers[4] == 1: gesture = "Six"elif fingers[0] == 1 and self.calc_angle(4, 5, 8) > 90: gesture = "Eight"elif fingers[0] == fingers[1] == 1 and self.get_dist(self.lmList[4][1:], self.lmList[8][1:]) < 50: gesture = "Heart_single"else: gesture = "Two"elif fingers.count(1)==5:gesture = "Five"if self.get_dist(self.lmList[4][1:], self.lmList[8][1:]) < 60 and \self.get_dist(self.lmList[4][1:], self.lmList[12][1:]) < 60 and \self.get_dist(self.lmList[4][1:], self.lmList[16][1:]) < 60 and \self.get_dist(self.lmList[4][1:], self.lmList[20][1:]) < 60 : gesture = "Seven"if self.lmList[self.tipIds[0]][2] < self.lmList[self.tipIds[1]][2] and \self.lmList[self.tipIds[0]][2] < self.lmList[self.tipIds[2]][2] and \self.lmList[self.tipIds[0]][2] < self.lmList[self.tipIds[3]][2] and \self.lmList[self.tipIds[0]][2] < self.lmList[self.tipIds[4]][2] and \self.calc_angle(self.tipIds[1] - 1, self.tipIds[1] - 2, self.tipIds[1] - 3) > 150.0 : gesture = "Eight"return gestureclass MY_Picture(Node):def __init__(self, name):super().__init__(name)self.bridge = CvBridge()self.sub_img = self.create_subscription(CompressedImage, '/espRos/esp32camera', self.handleTopic, 1) #获取esp32传来的图像self.hand_detector = handDetector(detectorCon=0.75)self.last_stamp = Noneself.new_seconds = 0self.fps_seconds = 1def handleTopic(self, msg):self.last_stamp = msg.header.stamp  if self.last_stamp:total_secs = Time(nanoseconds=self.last_stamp.nanosec, seconds=self.last_stamp.sec).nanosecondsdelta = datetime.timedelta(seconds=total_secs * 1e-9)seconds = delta.total_seconds()*100if self.new_seconds != 0:self.fps_seconds = seconds - self.new_secondsself.new_seconds = seconds#保留这次的值start = time.time()frame = self.bridge.compressed_imgmsg_to_cv2(msg)frame = cv.resize(frame, (640, 480))cv.waitKey(1) frame, img = self.hand_detector.findHands(frame, draw=False)if len(self.hand_detector.lmList) != 0:totalFingers = self.hand_detector.get_gesture()cv.rectangle(frame, (0, 430), (230, 480), (0, 255, 0), cv.FILLED)cv.putText(frame, str(totalFingers), (10, 470), cv.FONT_HERSHEY_PLAIN, 2, (255, 0, 0), 2)end = time.time()fps = 1 / ((end - start)+self.fps_seconds)text = "FPS : " + str(int(fps))cv.putText(frame, text, (20, 30), cv.FONT_HERSHEY_SIMPLEX, 0.9, (0, 0, 255), 1)dist = self.hand_detector.frame_combine(frame, img)cv.imshow('dist', dist)'''
Zero One Two Three Four Five Six Seven Eight
Ok: OK
Rock: rock
Thumb_up : 点赞
Thumb_down: 拇指向下
Heart_single: 单手比心
'''def main():print("start it")rclpy.init()esp_img = MY_Picture("My_Picture")try:rclpy.spin(esp_img)except KeyboardInterrupt:passfinally:esp_img.destroy_node()rclpy.shutdown()

网上有不少这个例子,差异点可能在手势识别哪里,前面的hand模型都是一样的。

根据你预计的指点判断角度或者漏出的手指组合判断含义。有的也不太准确,大部分能识别。

构建后运行:ros2 run yahboom_esp32_mediapipe GestureRecognition

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

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

相关文章

LabVIEW太阳能照明监控系统

在公共照明领域&#xff0c;传统的电力照明系统存在高能耗和维护不便等问题。利用LabVIEW开发太阳能照明监控系统&#xff0c;通过智能控制和实时监测&#xff0c;提高能源利用效率&#xff0c;降低维护成本&#xff0c;实现照明系统的可持续发展。 ​ 项目背景 随着能源危机…

Linux的权限和一些shell原理

目录 shell的原理 Linux权限 sudo命令提权 权限 文件的属性 ⽂件类型&#xff1a; 基本权限&#xff1a; chmod改权限 umask chown 该拥有者 chgrp 改所属组 最后&#xff1a; 目录权限 粘滞位 shell的原理 我们广义上的Linux系统 Linux内核Linux外壳 Linux严格…

Redis - 数据类型与编码方式

Redis中常用的5种数据类型 包括字符串、哈希、列表、集合、有序集合 字符串&#xff0c;相当于Java中的String哈希&#xff0c;相当于Java中的HashMap列表&#xff0c;相当于Java中的List集合&#xff0c;相当于Java中的Set有序集合&#xff0c;多存储了一个权重 Redis承诺使…

git Bash通过SSH key 登录github的详细步骤

1 问题 通过在windows 终端中的通过git登录github 不再是通过密码登录了&#xff0c;需要本地生成一个密钥&#xff0c;配置到gihub中才能使用 2 步骤 &#xff08;1&#xff09;首先配置用户名和邮箱 git config --global user.name "用户名"git config --global…

如何为64位LabVIEW配置正确的驱动程序

在安装 64位 LabVIEW 后&#xff0c;确保驱动程序正确配置是关键。如果您首先安装了 32位 LabVIEW 和相关驱动&#xff0c;然后安装了 64位 LabVIEW&#xff0c;需要确保为 64位 LabVIEW 安装和配置适当的驱动程序&#xff0c;才能正常访问硬件设备。以下是详细步骤&#xff1a…

BGP边界网关协议(Border Gateway Protocol)路由聚合详解

一、路由聚合 1、意义 在大规模的网络中&#xff0c;BGP路由表十分庞大&#xff0c;给设备造成了很大的负担&#xff0c;同时使发生路由振荡的几率也大大增加&#xff0c;影响网络的稳定性。 路由聚合是将多条路由合并的机制&#xff0c;它通过只向对等体发送聚合后的路由而…

戴尔电脑用u盘重装系统_戴尔电脑用u盘重装win10系统教程

戴尔电脑用u盘重装系统&#xff1f;戴尔电脑这几年默认预装win10家庭版和win11家庭版。有的用户用上了预装win11家庭版的戴尔电脑&#xff0c;使用一段时间依然不习惯&#xff0c;于是想退回win10。但不知道怎么重装win10&#xff0c;这几年的戴尔电脑建议采用U盘方式安装系统比…

QT TLS initialization failed

qt使用QNetworkAccessManager下载文件&#xff08;给出的链接可以在浏览器里面下载文件&#xff09;&#xff0c;下载失败&#xff0c; 提示“TLS initialization failed”通常是由于Qt在使用HTTPS进行文件下载时&#xff0c;未能正确初始化TLS&#xff08;安全传输层协议&…

【图文详解】lnmp架构搭建Discuz论坛

安装部署LNMP 系统及软件版本信息 软件名称版本nginx1.24.0mysql5.7.41php5.6.27安装nginx 我们对Markdown编辑器进行了一些功能拓展与语法支持,除了标准的Markdown编辑器功能,我们增加了如下几点新功能,帮助你用它写博客: 关闭防火墙 systemctl stop firewalld &&a…

06、Redis相关概念:缓存击穿、雪崩、穿透、预热、降级、一致性等

Redis相关概念&#xff1a;缓存击穿、雪崩、穿透、预热、降级、一致性等 Redis缓存雪崩、缓存击穿、缓存预热热点key、缓存降级、短链接、分布式锁秒杀、预减库存、 堆外缓存Redis架构设计、Redis动态刷新、Redis和DB双写一致性、过期删除策略、集群数据倾斜等一、缓存雪崩 缓…

【记录自开发的SQL工具】工具字符拼接、Excel转sql、生成编码、生成测试数据

记录自己开发的一个SQL聚合工具 功能介绍&#xff1a; 文本加引号 给多行文本前后添加引号&#xff0c;并用逗号连接&#xff0c;直接复制到 sql 中的 in 条件中 Excel转SQL 适用于将Excel表格的数据&#xff0c;批量导入到数据库的场景 此工具能快速将excel表格转换为i…

2024年工作总结

一、2024年个人成长、工作总结 1.博客文章 在这一年的创作中&#xff0c;共发布95篇文章&#xff0c;其中&#xff1a; Scrum敏捷项目管理&#xff1a; Scrum敏捷项目管理 前端技术vue jquery&#xff1a; jQuery&#xff08;一&#xff09;jQuery基本语法 分布式事务&…

【技术洞察】2024科技绘卷:浪潮、突破、未来

涌动与突破 2024年&#xff0c;科技的浪潮汹涌澎湃&#xff0c;人工智能、量子计算、脑机接口等前沿技术如同璀璨星辰&#xff0c;方便了大家的日常生活&#xff0c;也照亮了人类未来的道路。这一年&#xff0c;科技的突破与创新不断刷新着人们对未来的想象。那么回顾2024年的科…

Python 之 Excel 表格常用操作

示例文件 test.xlsx 将各个表单拆分成单独的 Excel 文件 import os.pathimport openpyxl import pandasdef handle_excel(file_path):dirname os.path.dirname(file_path)basename os.path.basename(file_path).split(".")[0]wb openpyxl.load_workbook(file_pat…

激活版,快速安装

每天开机都要等待很长时间&#xff0c;玩游戏或看视频时频繁卡顿&#xff0c;甚至偶尔还会莫名其妙地崩溃。这种情况几乎每个人都遇到过&#xff0c;真是让人头疼不已。 别担心&#xff0c;其实有一种方法可以让你的电脑恢复如新&#xff0c;让我们一起看看如何解决这些烦恼吧…

Kimi 1.5解读:国产AI大模型的创新突破与多模态推理能力(内含论文地址)

文章目录 一、Kimi 1.5的核心技术创新&#xff08;一&#xff09;长上下文扩展&#xff08;Long Context Scaling&#xff09;&#xff08;二&#xff09;改进的策略优化&#xff08;Improved Policy Optimization&#xff09;&#xff08;三&#xff09;简化框架&#xff08;S…

uniapp——App 监听下载文件状态,打开文件(三)

5 实现下载文件并打开 这里演示&#xff0c;导出Excel 表格 文章目录 5 实现下载文件并打开DEMO监听下载进度效果图为什么 totalSize 一直为0&#xff1f; 相关Api&#xff1a; downloader DEMO 提示&#xff1a; 请求方式支持&#xff1a;GET、POST&#xff1b;POST 方式需要…

MyBatis进阶

1. 动态SQL 1.1 <if>标签的使用(xml版本) 动态 SQL 是Mybatis的强⼤特性之⼀&#xff0c;能够完成不同条件下不同的 sql 拼接。 现在有一个需求.注册分为两种字段&#xff1a;必填字段和⾮必填字段&#xff0c;那如果在添加用户的时候有不确定的字段传⼊&#xff0c;程…

粒子群算法 笔记 数学建模

引入: 如何找到全局最大值&#xff1a;如果只是贪心的话&#xff0c;容易被局部最大解锁定 方法有&#xff1a;盲目搜索&#xff0c;启发式搜索 盲目搜索&#xff1a;枚举法和蒙特卡洛模拟&#xff0c;但是样例太多花费巨量时间 所以启发式算法就来了&#xff0c;通过经验和规…

【Unity3D】《跳舞的线》游戏的方块单方向拉伸实现案例

通过网盘分享的文件&#xff1a;CubeMoveMusic.unitypackage 链接: https://pan.baidu.com/s/1Rq-HH4H9qzVNtpQ84WXyUA?pwda7xn 提取码: a7xn 运行游戏点击空格动态创建拉伸的方块&#xff0c;由Speed控制速度&#xff0c;新方向是随机上下左右生成。 using System.Collect…