当前位置: 首页 > news >正文

C# OpenVino Yolov8 Pose 姿态识别

效果

项目

代码

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using OpenCvSharp;namespace OpenVino_Yolov8_Demo
{public partial class Form1 : Form{public Form1(){InitializeComponent();}string fileFilter = "*.*|*.bmp;*.jpg;*.jpeg;*.tiff;*.tiff;*.png";string image_path = "";String startupPath;DateTime dt1 = DateTime.Now;DateTime dt2 = DateTime.Now;String model_path;StringBuilder sb = new StringBuilder();Core core;Mat image;PoseResult result_pro;private void button1_Click(object sender, EventArgs e){OpenFileDialog ofd = new OpenFileDialog();ofd.Filter = fileFilter;if (ofd.ShowDialog() != DialogResult.OK) return;pictureBox1.Image = null;image_path = ofd.FileName;pictureBox1.Image = new Bitmap(image_path);textBox1.Text = "";image = new Mat(image_path);}private void button2_Click(object sender, EventArgs e){if (image_path == ""){return;}// 配置图片数据Mat image = new Mat(image_path);int max_image_length = image.Cols > image.Rows ? image.Cols : image.Rows;Mat max_image = Mat.Zeros(new OpenCvSharp.Size(max_image_length, max_image_length), MatType.CV_8UC3);Rect roi = new Rect(0, 0, image.Cols, image.Rows);image.CopyTo(new Mat(max_image, roi));float[] result_array = new float[8400 * 56];float[] factors = new float[2];factors[0] = factors[1] = (float)(max_image_length / 640.0);byte[] image_data = max_image.ImEncode(".bmp");//存储byte的长度ulong image_size = Convert.ToUInt64(image_data.Length);// 加载推理图片数据core.load_input_data("images", image_data, image_size, 1);dt1 = DateTime.Now;// 模型推理core.infer();dt2 = DateTime.Now;// 读取推理结果result_array = core.read_infer_result<float>("output0", 8400 * 56);result_pro = new PoseResult(factors);Mat result_image = result_pro.draw_result(result_pro.process_result(result_array), image.Clone());pictureBox2.Image = new Bitmap(result_image.ToMemoryStream());textBox1.Text = "耗时:" + (dt2 - dt1).TotalMilliseconds + "ms";}private void Form1_Load(object sender, EventArgs e){startupPath = System.Windows.Forms.Application.StartupPath;model_path = startupPath + "\\yolov8n-pose.onnx";core = new Core(model_path, "CPU");}private void Form1_FormClosing(object sender, FormClosingEventArgs e){core.delet();}}
}

Demo下载

http://www.lryc.cn/news/167869.html

相关文章:

  • 北邮22级信通院数电:Verilog-FPGA(1)实验一“跑通第一个例程” 过程中遇到的常见问题与解决方案汇总(持续更新中)
  • CSS - 鼠标移入整行高亮显示,适用于会员套餐各参数对比页面(display: table,div 转表格形式)
  • 无涯教程-JavaScript - ATAN2函数
  • Tomcat 下部署 jFinal
  • 【Spatial-Temporal Action Localization(二)】论文阅读2017年
  • 二维码智慧门牌管理系统:数据现势性,满足应用需求的根本保证
  • BF算法(C++)简单讲解
  • JVM 虚拟机 ----> Java 类加载机制
  • 《protobuf》基础语法2
  • 利用 SOAR 加快事件响应并加强网络安全
  • uni-app:通过ECharts实现数据可视化-如何引入项目
  • string 模拟与用法
  • [NLP] LLM---<训练中文LLama2(一)>训练一个中文LLama2的步骤
  • 华为云云耀云服务器L实例使用教学 | 利用华为云服务器搭建--> 基于Spring Boot+WebSocket+WebRtc实现的多人自习室
  • Postman应用——接口请求(Get和Post请求)
  • k8s pod概念、分类及策略
  • C++系列-左移运算符重载
  • 【Vue】vue中v-if的用法
  • 企业架构LNMP学习笔记54
  • C【函数】
  • 【简单教程】利用Net2FTP构建免费个人网盘,实现便捷的文件管理
  • 05-Flask-Flask查询路由方式
  • lua环境搭建数据类型
  • c++11的一些新特性
  • K8S名称空间和资源配额
  • 鼠标拖拽拖动盒子时,与盒子内某些点击事件冲突问题解决
  • PMP项目管理证书是什么?有什么用?
  • iframe的父子通讯
  • 使用docker创建minio镜像并上传文件,提供demo
  • 02 java ---- Android 基础app开发