基于关键点检测的摔倒识别

P粉084495128
发布: 2025-07-21 15:42:55
原创
721人浏览过
该工程基于PaddleDetection实现人员摔倒识别。先通过特定命令预测视频关键点,得到json结果文件和可视化视频;再用source.py中代码判断摔倒,输出摔倒帧对应时间,还会在视频检测框左上角标注结果并保存为output.mp4,示例中检测到78帧摔倒。

☞☞☞AI 智能聊天, 问答助手, AI 智能搜索, 免费无限量使用 DeepSeek R1 模型☜☜☜

基于关键点检测的摔倒识别 - php中文网

基于PaddleDetection的人员摔倒识别

本工程是基于PaddleDetection人员关键点预测的摔倒识别案例

关于PaddleDetection的使用详情请参考github链接 PaddleDetection

1 获取视频关键点预测结果

在PaddleDetection下使用如下命令预测视频结果(相关模型可以从github中model_zoo获取):

python deploy/python/det_keypoint_unite_infer.py --det_model_dir=output_inference/ppyolo_r50vd_dcn_2x_coco/ --keypoint_model_dir=output_inference/hrnet_w32_256x192/ --video_file=./pose_demo/test.mp4  --device=gpu --save_res=True
登录后复制

       

造点AI
造点AI

夸克 · 造点AI

造点AI 325
查看详情 造点AI
  • 预测完成后会在当前目录下得到预测结果json文件:det_keypoint_unite_video_results.json, 即此处使用的kpts_results.json文件.

  • 在output目录下得到预测结果可视化文件:test.mp4, 即此处的video.mp4文件.

2 根据关键点结果判断是否摔倒

执行最下面命令行的命令,对关键点预测结果kpts_results.json做摔倒逻辑的判断,摔倒帧对应时间会打印显示。同时会在视频上对应时间的检测框左上角打印fall_down结果,结果视频保存为output.mp4。

  • 逻辑判断代码在source.py文件中
In [1]
import osimport sysimport cv2import numpy as npimport jsonimport collectionsfrom source import check_fall_down, videovis
登录后复制
   
In [3]
#1)脚本第一个参数为关键点预测结果json文件jsonf = "kpts_results.json"with open(jsonf, "r") as rf:
    kpts_data = json.load(rf)print("all data length: {}".format(len(kpts_data)))#2)如果需要视频打印摔倒文字,关键点可视化结果文件放在同路径videof = "video.mp4"#3)读取关键点结果后放入判断文件fallframes = check_fall_down(kpts_data)#4)根据检测的摔倒帧在视频显示videovis(videof, kpts_data, fallframes)
登录后复制
       
all data length: 468
fall_down frames: 78
time: 5.5s, fall down detected
time: 6.0s, fall down detected
time: 6.5s, fall down detected
time: 7.0s, fall down detected
time: 7.5s, fall down detected
time: 8.0s, fall down detected
time: 8.5s, fall down detected
time: 9.0s, fall down detected
time: 9.5s, fall down detected
time: 10.0s, fall down detected
time: 10.5s, fall down detected
time: 11.0s, fall down detected
time: 11.5s, fall down detected
time: 12.0s, fall down detected
time: 12.5s, fall down detected
time: 18.0s, fall down detected
time: 18.5s, fall down detected
time: 19.5s, fall down detected
time: 20.5s, fall down detected
time: 21.0s, fall down detected
time: 21.5s, fall down detected
time: 23.5s, fall down detected
time: 25.5s, fall down detected
time: 26.0s, fall down detected
time: 29.5s, fall down detected
time: 30.0s, fall down detected
time: 32.0s, fall down detected
time: 32.5s, fall down detected
time: 33.0s, fall down detected
time: 35.0s, fall down detected
time: 35.5s, fall down detected
time: 36.0s, fall down detected
time: 38.0s, fall down detected
time: 38.5s, fall down detected
print fall down result in video: video.mp4
fps: 12, frame_count: 468
登录后复制
       

以上就是基于关键点检测的摔倒识别的详细内容,更多请关注php中文网其它相关文章!

相关标签:
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号