基于深度学习的人体关键点检测与姿态识别

文章目录

源码下载地址:
源码地址在视频简介中

深度学习人体关键点检测,姿态识别

界面效果:

界面代码:

python 复制代码
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from untitled import Ui_Form
import sys
import cv2 as cv
from PyQt5.QtCore import QCoreApplication
import numpy as np
from PyQt5 import QtCore,QtGui
from PIL import Image
from predicts import pp
import time
from PyQt5 import QtWidgets
import cv2
class My(QMainWindow,Ui_Form):
    def __init__(self):
        super(My,self).__init__()
        self.setupUi(self)
        self.setWindowTitle('人体姿态识别')
        self.use_palette()

        self.pushButton.clicked.connect(self.pic)

        self.pushButton_2.clicked.connect(self.pre)
        self.pushButton_3.clicked.connect(self.video)

        self._timer = QTimer(self)
        self._timer.timeout.connect(self.play)

    def video(self):
        self._timer.stop()
        v, videoType = QFileDialog.getOpenFileName(self,
                                                   "打开视频",
                                                   "",
                                                   " *.mp4;;*.avi;;All Files (*)")

        if v=='':
            return
        self.ved = cv2.VideoCapture(v)
        qq = self.ved.isOpened()
        if qq == False:
            msg_box = QMessageBox(QMessageBox.Warning, 'Warning', '请选择视频!')
            msg_box.exec_()
            return
        self._timer.stop()
        self._timer.start(1)
    def play(self):
        try:
            r, frame = self.ved.read()
            orial=self.cv_qt(frame)
            self.label.setPixmap(
                QPixmap.fromImage(orial).scaled(self.label.width(), self.label.height(), QtCore.Qt.KeepAspectRatio))


            self.out, zt = pp(frame)
            out = self.cv_qt(self.out)
            self.label_2.setPixmap(
                QPixmap.fromImage(out).scaled(self.label.width(), self.label.height(), QtCore.Qt.KeepAspectRatio))
            self.label_4.setText(zt)
        except:
            self._timer.stop()


    def pre(self):
        self._timer.stop()

        self.out,zt=pp(self.img[...,::-1])
        out=self.cv_qt(self.out)
        self.label_2.setPixmap(QPixmap.fromImage(out).scaled(self.label.width(),self.label.height(),QtCore.Qt.KeepAspectRatio))
        self.label_4.setText(zt)
    def pic(self):
        self._timer.stop()
        imgName, imgType = QFileDialog.getOpenFileName(self,
                                                       "打开图片",
                                                       "",
                                                       " *.png;;*.jpg;;*.jpeg;;*.bmp;;All Files (*)")
        if imgName=='':
            return
        #KeepAspectRatio
        png = QtGui.QPixmap(imgName).scaled(self.label.width(),self.label.height(),QtCore.Qt.KeepAspectRatio)  # 适应设计label时的大小
        self.label.setPixmap(png)

        self.img=Image.open(imgName)
        self.img=np.array(self.img)[...,:3]
    def cv_qt(self, src):
        #src必须为bgr格式图像
        #src必须为bgr格式图像
        #src必须为bgr格式图像
        if len(src.shape)==2:
            src=np.expand_dims(src,axis=-1)
            src=np.tile(src,(1,1,3))
            h, w, d = src.shape
        else:h, w, d = src.shape



        bytesperline = d * w
        # self.src=cv.cvtColor(self.src,cv.COLOR_BGR2RGB)
        qt_image = QImage(src.data, w, h, bytesperline, QImage.Format_RGB888).rgbSwapped()
        return qt_image
    #设置背景图片函数
    def use_palette(self):
        self.setWindowTitle("人体姿态识别")
        window_pale = QtGui.QPalette()
        window_pale.setBrush(self.backgroundRole(),
                             QtGui.QBrush(QtGui.QPixmap(r"./back.jpg")))
        self.setPalette(window_pale)


if __name__ == '__main__':
    QCoreApplication.setAttribute(QtCore.Qt.AA_EnableHighDpiScaling)
    app=QApplication(sys.argv)
    my=My()
    my.show()
    sys.exit(app.exec_())
相关推荐
Cyltcc几秒前
如何安装和使用 Claude Code 教程 - Windows 用户篇
人工智能·claude·visual studio code
吹风看太阳33 分钟前
机器学习16-总体架构
人工智能·机器学习
moonsims1 小时前
全国产化行业自主无人机智能处理单元-AI飞控+通信一体化模块SkyCore-I
人工智能·无人机
MUTA️1 小时前
ELMo——Embeddings from Language Models原理速学
人工智能·语言模型·自然语言处理
海豚调度1 小时前
Linux 基金会报告解读:开源 AI 重塑经济格局,有人失业,有人涨薪!
大数据·人工智能·ai·开源
T__TIII2 小时前
Dify 插件非正式打包
人工智能
jerwey2 小时前
大语言模型(LLM)按架构分类
人工智能·语言模型·分类
微学AI2 小时前
遥感影像岩性分类:基于CNN与CNN-EL集成学习的深度学习方法
深度学习·分类·cnn
IT古董2 小时前
【第三章:神经网络原理详解与Pytorch入门】02.深度学习框架PyTorch入门-(5)PyTorch 实战——使用 RNN 进行人名分类
pytorch·深度学习·神经网络
令狐少侠20112 小时前
ai之RAG本地知识库--基于OCR和文本解析器的新一代RAG引擎:RAGFlow 认识和源码剖析
人工智能·ai