2024年树莓派4B Python3,2024年最新物联网嵌入式开发面试资料集合

img
img

既有适合小白学习的零基础资料,也有适合3年以上经验的小伙伴深入学习提升的进阶课程,涵盖了95%以上物联网嵌入式知识点,真正体系化!

由于文件比较多,这里只是将部分目录截图出来,全套包含大厂面经、学习笔记、源码讲义、实战项目、大纲路线、电子书籍、讲解视频,并且后续会持续更新

如果你需要这些资料,可以戳这里获取

手指方向检测(食指, 可以修改其他手指) 可以直接运行,这里的hands_module是单独检测左手或者右手,test_time检测时间就是超时返回0,last_dire是我项目里需要的参数,这应该是最快速的检测手指指向的方案了,包含了手指的方向以及手指是否直指,(食指一二三关节关键点夹角)这里是手指关节必须大于140度
效果图:

手指指向判断时候,cvzone手势识别有,手掌21个关键点的三维坐标,所以这里利用的是三维向量判断和对应角度夹角,这里三维向量∠ABC需要满足需求才表示指向某个方向。

检测最大的那只手,指向判断,完成功能。

# -*- coding: utf-8 -*-
import cv2
import time
import numpy as np
import cvzone.HandTrackingModule
import cvzone.FaceDetectionModule
from collections import Counter

face_detector = cvzone.FaceDetectionModule.FaceDetector(minDetectionCon=0.5)
hand_direction_detector = cvzone.HandTrackingModule.HandDetector(mode=False,  # 视频流图像
                                                                 maxHands=4,  # 最多检测两只手
                                                                 detectionCon=0.5,  # 最小检测置信度
                                                                 minTrackCon=0.7)  # 最小跟踪置信度

def detect_hand_direction(cap_hand_direction, hands_module=1, last_dire=5, test_time=5):
    print("开始指向检测")
    reference_vectors = [np.array([0, -1, 0]), np.array([1, 0, 0]),
                         np.array([-1, 0, 0]), np.array([0, 1, 0])]  # 3D坐标单位向量
    angles = []
    add_count = [1, 1, 1, 1]
    left_hand_direction = [0, 0, 0, 0]
    right_hand_direction = [0, 0, 0, 0]
    video_model = 1  # 是否显示视频
    if 0 < last_dire < 5:  # 平常是5 不作数, 如果对应了某一个方向,那就让对应方向检测次数更多
        add_count[last_dire-1] = 1/3
    # 清除之前的视频流数据
    frames_to_skip = 2  # 要丢弃的帧数
    for _ in range(frames_to_skip):
        _, _ = cap_hand_direction.read()
        atime = time.time()
    while True:
        success, frame = cap_hand_direction.read()
        if success is not True:
            break
        hands = hand_direction_detector.findHands(frame, draw=False, flipType=False)
        if hands:
            left_hand_max_area = 0  # 初始化最大面积为0
            right_hand_max_area = 0  # 初始化最大面积为0
            left_hand_max_index = -1  # 初始化最大面积对应的遍历序号为-1
            right_hand_max_index = -1  # 初始化最大面积对应的遍历序号为-1
            left_region_status = 0  # 初始化左手是否在范围内
            right_region_status = 0  # 初始化右手是否在范围内
            for index, hand in enumerate(hands):
                if hand["type"] == "Left":  # 左手
                    _, _, w_left, h_left = hand["bbox"]
                    left_hand_area = w_left * h_left  # 计算面积
                    if left_hand_area > left_hand_max_area:
                        left_hand_max_area = left_hand_area
                        left_hand_max_index = index
                if hand["type"] == "Right":  # 右手
                    _, _, w_right, h_right = hand["bbox"]
                    right_hand_area = w_right * h_right  # 计算面积
                    if right_hand_area > right_hand_max_index:
                        right_hand_max_index = right_hand_area
                        right_hand_max_index = index
            if hands_module == 2 and left_hand_max_index != -1:
                # 模式2 只检测左手

                # # 采用食指的第一关节[7]第二关节[6]第三关节即指根[5]来求出 食指第二关节的角度 计算食指弯曲角度
                # # 将夹角余弦值转换为角度制并输出夹角
                ab = np.array(hands[left_hand_max_index]["lmList"][6]) - np.array(
                    hands[left_hand_max_index]["lmList"][7])
                bc = np.array(hands[left_hand_max_index]["lmList"][5]) - np.array(
                    hands[left_hand_max_index]["lmList"][6])
                cos_angle = np.dot(ab, bc) / (np.linalg.norm(ab) * np.linalg.norm(bc))
                angle = 180 - np.arccos(cos_angle) * 180 / np.pi
                if angle > 140:

                direction = np.array(hands[left_hand_max_index]["lmList"][5]) - np.array(
                    hands[left_hand_max_index]["lmList"][8])
                angles.clear()
                for reference_vector in reference_vectors:
                    cos_angle = np.dot(direction, reference_vector) / (
                                np.linalg.norm(direction) * np.linalg.norm(reference_vector))
                    angle = np.arccos(cos_angle) * 180 / np.pi
                    angles.append(angle)
                # 判断手指朝向是否符合四个方向中的至少一个
                if angles[0] < 45 <= max(angles):  # 下
                    left_hand_direction.append(1)
                elif angles[1] < 45 <= max(angles):  # 左
                    left_hand_direction.append(2)
                elif angles[2] < 45 <= max(angles):  # 右
                    left_hand_direction.append(3)
                elif angles[3] < 45 <= max(angles):  # 上
                    left_hand_direction.append(4)
                if len(left_hand_direction) >= 10:
                    counter = Counter(left_hand_direction)  # 使用Counter计算每个数字的出现次数
                    most_common_digit = counter.most_common(1)[0][0]  # 找到出现次数最多的数字
                    print("Most common digit:", most_common_digit)
                    return most_common_digit
            if hands_module == 1 and right_hand_max_index != -1:
                # 模式1 只检测右手

                # 采用食指的第一关节[7]第二关节[6]第三关节即指根[5]来求出 食指第二关节的角度 计算食指弯曲角度
                # # 将夹角余弦值转换为角度制并输出夹角
                ab = np.array(hands[right_hand_max_index]["lmList"][6]) - np.array(
                    hands[right_hand_max_index]["lmList"][7])
                bc = np.array(hands[right_hand_max_index]["lmList"][5]) - np.array(
                    hands[right_hand_max_index]["lmList"][6])
                cos_angle = np.dot(ab, bc) / (np.linalg.norm(ab) * np.linalg.norm(bc))
                angle = 180 - np.arccos(cos_angle) * 180 / np.pi
                if angle > 140:

                direction = np.array(hands[right_hand_max_index]["lmList"][5]) - np.array(
                    hands[right_hand_max_index]["lmList"][8])
                angles.clear()
                for reference_vector in reference_vectors:
                    cos_angle = np.dot(direction, reference_vector) / (
                                np.linalg.norm(direction) * np.linalg.norm(reference_vector))
                    angle = np.arccos(cos_angle) * 180 / np.pi
                    angles.append(angle)
                # 判断手指朝向是否符合四个方向中的至少一个
                if angles[0] < 45 <= max(angles):  # 下
                    right_hand_direction.append(1)
                elif angles[1] < 45 <= max(angles):  # 左
                    right_hand_direction.append(2)
                elif angles[2] < 45 <= max(angles):  # 右
                    right_hand_direction.append(3)
                elif angles[3] < 45 <= max(angles):  # 上


**收集整理了一份《2024年最新物联网嵌入式全套学习资料》,初衷也很简单,就是希望能够帮助到想自学提升的朋友。**
![img](https://img-blog.csdnimg.cn/img_convert/ed4e6435f9296024471fb92951c6ba20.png)
![img](https://img-blog.csdnimg.cn/img_convert/9303b873db9a8bad7ac9a9ee082613e1.png)

**[如果你需要这些资料,可以戳这里获取](https://bbs.csdn.net/topics/618679757)**

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人**

**都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

资料,可以戳这里获取](https://bbs.csdn.net/topics/618679757)**

**一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人**

**都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!**

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值