[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
ps:为之后的opencv项目做准备
代码显示及注释
import cv2 import mediapipe as mp import time cap = cv2.VideoCapture(0) #
调用摄像头 mpHands = mp.solutions.hands # 调用手部模型 hands = mpHands.Hands() # 使用默认的函式 #
设置样式 mpDraw = mp.solutions.drawing_utils # 点的样式 red 粗度 5px handLmsStyle =
mpDraw.DrawingSpec(color=(0, 0, 255), thickness=5) # 线的样式 green cudu 5px
handConStyle = mpDraw.DrawingSpec(color=(0, 255, 0), thickness=5) pTime = 0
cTime = 0 while True: ret, img = cap.read() # 查看摄像头读取的图像 if ret: imgRGB =
cv2.cvtColor(img, cv2.COLOR_BGR2RGB) # 将图片转为灰度图 result = hands.process(imgRGB)
# 图片预测出来的一个结果 #print(result.multi_hand_landmarks) imgHeight = img.shape[0]
imgWidth = img.shape[1] if result.multi_hand_landmarks: # 如果检测到手 for handLms in
result.multi_hand_landmarks: # 将手的图片在整个检测到的手的位置列表中一一遍历 # 参数:图片 点 线 点的样式 线的样式
mpDraw.draw_landmarks(img, handLms, mpHands.HAND_CONNECTIONS, handLmsStyle,
handConStyle) cTime = time.time() fps = 1/(cTime-pTime) # 1秒/一张图片的显示时间=1秒显示多少帧
pTime = cTime # 将fps输出到图片上 cv2.putText(img, f"FPS :{int(fps)}", (30, 50),
cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 0, 0), 3) # 显示图片 cv2.imshow('img', img) #
当输入英文字符q退出循环 if cv2.waitKey(1) == ord('q'): break
效果展示