news 2026/4/18 14:08:52

C# winform部署yolo26-pose姿态估计关键点的onnx模型演示源码+模型+说明

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
C# winform部署yolo26-pose姿态估计关键点的onnx模型演示源码+模型+说明

yolo26已经正式发布了,因此使用C#代码实现YOLO26-pose姿态估计的onnx模型部署,首先看yolo11n-pose网络结构,发现输出shape是1x56x8400

再来看看yolo26n-pose网络结构输出,输出shape是1x300x57

可见yolo11和yolo26输出是不一样的是不能共用代码。

模型使用官方yolo26n-pose.pt转换成的onnx,转换命令
yolo export model=yolo26n-pose.pt format=onnx opset=12
如果你是自己训练的模型可以替换即可,但是需要yolo26-pose框架才行
测试环境:
vs2019
CPU推理,无需安装cuda+cudnn
onnxruntime==1.22.1
opecvsharp==4.11.0
.net framework4.8.0
ultralytics==8.4.0

实现界面代码和调用代码:

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using OpenCvSharp; namespace FIRC { public partial class Form1 : Form { OpenCvSharp.Mat src = new OpenCvSharp.Mat(); Yolo26PoseManager ym = new Yolo26PoseManager(); public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "图文件(*.*)|*.jpg;*.png;*.jpeg;*.bmp"; openFileDialog.RestoreDirectory = true; openFileDialog.Multiselect = false; if (openFileDialog.ShowDialog() == DialogResult.OK) { src = Cv2.ImRead(openFileDialog.FileName); pictureBox1.Image = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(src); } } private void button2_Click(object sender, EventArgs e) { if(pictureBox1.Image==null) { return; } Stopwatch sw = new Stopwatch(); sw.Start(); var result = ym.Inference(src); sw.Stop(); this.Text = "耗时" + sw.Elapsed.TotalSeconds + "秒"; var resultMat = ym.DrawImage(src,result); pictureBox2.Image= OpenCvSharp.Extensions.BitmapConverter.ToBitmap(resultMat); //Mat转Bitmap } private void Form1_Load(object sender, EventArgs e) { ym.LoadWeights(Application.StartupPath+ "\\weights\\yolo26n-pose.onnx"); } private void btn_video_Click(object sender, EventArgs e) { var detector = new Yolo26PoseManager(); detector.LoadWeights(Application.StartupPath + "\\weights\\yolo26n-pose.onnx"); VideoCapture capture = new VideoCapture(0); if (!capture.IsOpened()) { Console.WriteLine("video not open!"); return; } Mat frame = new Mat(); var sw = new Stopwatch(); int fps = 0; while (true) { capture.Read(frame); if (frame.Empty()) { Console.WriteLine("data is empty!"); break; } sw.Start(); var result = detector.Inference(frame); var resultImg = detector.DrawImage(frame,result); sw.Stop(); fps = Convert.ToInt32(1 / sw.Elapsed.TotalSeconds); sw.Reset(); Cv2.PutText(resultImg, "FPS=" + fps, new OpenCvSharp.Point(30, 30), HersheyFonts.HersheyComplex, 1.0, new Scalar(255, 0, 0), 3); //显示结果 Cv2.ImShow("Result", resultImg); int key = Cv2.WaitKey(10); if (key == 27) break; } capture.Release(); } } }

最后测试效果:

版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/18 12:59:03

day131—链表—反转链表Ⅱ(区域反转)(LeetCode-92)

题目描述给你单链表的头指针 head 和两个整数 left 和 right &#xff0c;其中 left < right 。请你反转从位置 left 到位置 right 的链表节点&#xff0c;返回 反转后的链表 。示例 1&#xff1a;输入&#xff1a;head [1,2,3,4,5], left 2, right 4 输出&#xff1a;[1…

作者头像 李华
网站建设 2026/4/18 8:19:30

大模型预蒸馏技术原理总结

一、什么是大模型蒸馏&#xff1f;核心目标是什么&#xff1f; 首先&#xff0c;我们得明确“蒸馏”的本质&#xff1a;它是一种模型压缩与知识迁移技术&#xff0c;核心逻辑是“用大模型教小模型”。这里的“知识”&#xff0c;不只是模型在训练数据上学到的“硬标签”&#x…

作者头像 李华
网站建设 2026/4/18 9:44:44

告别AI agent“金鱼脑“!CaveAgent框架让你的AI过目不忘,效率翻倍

CaveAgent采用"双流架构"解决AI记忆力问题&#xff1a;语义流作为轻量大脑负责推理&#xff0c;运行流作为持久记忆存储数据。这种设计使AI能长期保存数据&#xff0c;避免上下文限制&#xff0c;高效处理大数据&#xff0c;减少28.4%的Token消耗&#xff0c;提升任务…

作者头像 李华
网站建设 2026/4/18 8:56:12

AIGNE框架:基于文件系统抽象的大模型上下文工程解决方案

本文提出借鉴Unix"一切皆文件"理念的文件系统抽象架构&#xff0c;解决GenAI和智能体系统上下文工程问题。架构包括持久化上下文仓库和上下文工程流水线&#xff08;构造器、更新器、评估器&#xff09;&#xff0c;通过AIGNE框架实现&#xff0c;满足令牌窗口、无状…

作者头像 李华
网站建设 2026/4/18 8:50:48

学姐私藏:6款免费降AI工具推荐,最后一个用过都说好

学姐私藏&#xff1a;6款免费降AI工具推荐&#xff0c;最后一个用过都说好 TL;DR&#xff1a;毕业季预算紧张但又需要降AI怎么办&#xff1f;本文分享6款降AI工具&#xff0c;从完全免费到低价高效都有覆盖。重点推荐嘎嘎降AI&#xff08;4.8元/次&#xff0c;达标率99.26%&…

作者头像 李华