0
点赞
收藏
分享

微信扫一扫

pyqt手势识别界面建立

时光已翩然轻擦 2022-03-15 阅读 77

pyqt手势识别界面建立


第一次弄可视化界面.

安装pyqt模块

pip install pyside2 -i https://pypi.douban.com/simple/

导入所需API

from PySide2.QtWidgets import QApplication, QMainWindow, QPushButton,  QPlainTextEdit,QMessageBox,QTextEdit

绘制主界面

app=QApplication([])
window=QMainWindow()
window.resize(500,400)
window.move(300,300)
window.setWindowTitle('手势识别')

读取图片界面

因为找了很久没找到如何拖拽图片的教程,只找到了读取图片地址的教程,为了快就直接使用了

把图片拖拽到界面直接转化成为了地址

textEdit=QTextEdit(window)
textEdit.setPlaceholderText('请拖拽图片到此')
textEdit.move(10,255)
textEdit.move(300,350)

#添加预测按钮
    button = QPushButton('预测', window)
    button.move(380, 80)
    button.clicked.connect(handleCalc)
    window.show()
    app.exec_()

button执行的函数

def handleCalc():
    info = textEdit.toMarkdown()#获取图片的链接
    filepath=info[8:]
    filepath=filepath.strip()#去除路径的前后空格
    figure = gesture()
    model = figure.refine_model()
    figure.freeze()
    index=figure.predict(model=model,filepath=filepath)
    QMessageBox.about(window,
                '预测结果',f'{index}')

在这里插入图片描述
在这里插入图片描述

举报

相关推荐

0 条评论