首页 > 编程语言 >C# OpenVinoSharp PP-TinyPose 人体姿态识别

C# OpenVinoSharp PP-TinyPose 人体姿态识别

时间:2023-10-02 12:07:24浏览次数:34  
标签:PP using C# image pose det System path TinyPose


效果

C# OpenVinoSharp PP-TinyPose 人体姿态识别_C#人体姿态识别

C# OpenVinoSharp PP-TinyPose 人体姿态识别_System_02

项目

C# OpenVinoSharp PP-TinyPose 人体姿态识别_OpenVino_03

部分代码

using OpenCvSharp;
using OpenCvSharp.Extensions;
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;

namespace OpenVinoSharp_PP_TinyPose人体姿态识别
{
    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 mode_path_det;
        // 关键点检测模型
        string mode_path_pose;
        // 设备名称
        string device_name;
        //行人区域检测
        PicoDet pico_det;
        //人体姿势检测
        PPTinyPose tiny_pose;
        Mat image;

        private void button2_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 = "";
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            startupPath = Application.StartupPath;

            //推理模型路径中不能不含中文,否则会报错
            mode_path_det = Application.StartupPath + @"\TinyPoseModel\picodet_v2_s_320_pedestrian\ir\picodet_s_320_lcnet_pedestrian.xml";
            mode_path_pose = Application.StartupPath + @"\TinyPoseModel\tinypose_256_192\tinypose_256_192.onnx";

            // 设备名称
            device_name = "CPU";
            //行人区域检测
            pico_det = new PicoDet(mode_path_det, device_name);
            //人体姿势检测
            tiny_pose = new PPTinyPose(mode_path_pose, device_name);
        }


        private void button1_Click(object sender, EventArgs e)
        {
            tiny_pose_image();
        }


        public void tiny_pose_image()
        {
            if (image_path == "")
            {
                return;
            }

            image = Cv2.ImRead(image_path);

            OpenCvSharp.Size size_det = new OpenCvSharp.Size(320, 320);
            pico_det.set_shape(size_det, 2125);

            dt1 = DateTime.Now;
            List<Rect> result_rect = pico_det.predict(image);

            //人体姿势检测
            OpenCvSharp.Size size_pose = new OpenCvSharp.Size(256, 192);
            tiny_pose.set_shape(size_pose);

            List<Rect> point_rects;
            List<Mat> person_rois = tiny_pose.get_point_roi(image, result_rect, out point_rects);

            for (int p = 0; p < person_rois.Count; p++)
            {
                // 关键点识别
                float[,] person_point = tiny_pose.predict(person_rois[p]);
                tiny_pose.draw_poses(person_point, point_rects[p], ref image);
            }
            dt2 = DateTime.Now;

            for (int i = 0; i < result_rect.Count; i++)
            {
                Cv2.Rectangle(image, result_rect[i], new Scalar(255, 0, 0), 2);
            }
            pictureBox2.Image = BitmapConverter.ToBitmap(image);
            textBox1.Text = "耗时:" + (dt2 - dt1).TotalMilliseconds + "ms";
        }
    }
}

exe程序下载

完整Demo下载

标签:PP,using,C#,image,pose,det,System,path,TinyPose
From: https://blog.51cto.com/u_2617730/7682509

相关文章

  • C# OpenVino Yolov8 Detect 目标检测
    效果项目 代码usingOpenCvSharp;usingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Windows.Forms;usingstaticSystem.Net.Mime.MediaTypeName......
  • 【TypeScript】一直提示 :无法重新声明块范围变量
    【TypeScript】一直提示:无法重新声明块范围变量问题描述:在VSCode中编写ts代码时,编写保存完之后,通过tsc文件名.ts编译就会看到变量名下面出现了红色的波浪线,提示的内容是无法重新声明块范围变量。解决方法:在终端只需要使用tsc--init生成tsconfig.json文件就可以解决了。或者在当......
  • 【C++】函数重载 ③ ( 为函数指针赋值重载函数 )
    文章目录一、函数指针回顾1、函数指针概念2、函数指针语法3、代码示例-函数指针示例二、为函数指针赋值重载函数1、为函数指针赋值重载函数2、代码示例-为函数指针赋值重载函数博客总结:重载函数:使用相同的函数名,定义不同的函数参数列表;判定标准:只有函数......
  • 主流常见关系数据库分页sql语句写法。MySQL、PostgreSQL、SQLite、Oracle、DB2、SQL S
    前言1.分页sql逻辑:每页10条,取第3页。即取第21~30条数据1.1.MySQL/SQLite/PostgreSQLselect*fromdemolimit10offset20;select*fromdemolimit20,10;--PostgreSQL不支持该写法1.2.Oracle12C+Oracle11g之前很难用,Oracle12C+与MySQL用法格式一样了,只是语法关......
  • Gromacs模拟体系构建----进阶版
    Gromacs是目前广泛使用的分子模拟软件,其在生物、材料等领域的模拟表现出较为突出的优势。之前,本公众号介绍过一系列体系的模拟以及gromacs的使用办法和教程。本次,将为大家介绍一种进阶版的模型构建方法。在之前的介绍中,我们了解到可以通过insert-molecules和editconf等命令构建模拟......
  • DC电源模块过压保护功能介绍
    BOSHIDADC电源模块过压保护功能介绍DC电源模块(也叫直流电源模块)是一种常见的设备,它可以将交流电转换为直流电,用于供电给各种电子设备。DC电源模块通常具有多种保护功能,其中过压保护是其中一项重要的保护功能。过压保护是指当DC电源模块输出电压高于预设值时,系统会自动进行保护操作......
  • Final Cut Pro最新中文版下载-FCPX软件下载 安装包下载方式
    FinalCutProX 是mac客户端最专业的视频剪辑软件,拥有最完善的视频处理功能,可以编辑不同分辨率的视频,搭配本站的FCPX插件使用效果更佳。新版的FinalCutProXforMac新增模糊、光晕等360°效果让后期制作的速度得以提升,帮助用户创作出令人赞叹的作品。本站提供 Final......
  • Python爬虫源码,Behance 作品图片及内容 selenium 采集爬虫
    前面有分享过requests采集Behance作品信息的爬虫,这篇带来另一个版本供参考,使用的是无头浏览器selenium采集,主要的不同方式是使用selenium驱动浏览器获取到页面源码,后面获取信息的话与前篇一致。Python爬虫源码,Behance作品图片及内容采集爬虫附工具脚本!理论上,几乎所有的页面内......
  • FCPX最新中文版下载 支持M1/M2 安装包下载方式
    fcpx全称FinalCutProX是一款由Macromedia(现已被Adobe收购)推出,之后由苹果公司接手研发、销售的非线性视频剪辑软件。能在装载英特尔处理器和macOSMojave10.14.6以后版本的Mac电脑上运行。本软件能让用户将视频记录和传输至硬盘上(内置或外接),之后进行编辑、剪辑、处理和输......
  • ACDSee官方版_ACDSee官方版下载 安装包下载方式
    ACDSee官方版是目前acdsee看图软件最经典的版本,ACDSee官方版能够便捷的查找、组织和预览超过50种常用多媒体格式,同时可以流畅地获取图像,均衡元数据,无损处理,像素级图像编辑以及管理备份,是查看和管理图片最好的帮手。虽然ACDSee官方版有一点低,但贵在实用,对于经常查看图片和管理图片的......