oranges98 2023-04-11 21:45 采纳率: 62.5%
浏览 19
已结题

关于#python#的问题:求将上述代码编为pyqt中的槽函数

def hist(img):
    [m,n]=img.shape
    out=[]
    a = 0
    for i in range(m):
        temp=0
        for j in range(n):
            temp=temp+img[i,j]
        out.append(temp)
    for i in range(m):
        if out[i]!=0:
            a=a+1

    return a


img = cv2.imread("")

求将上述代码编为pyqt中的槽函数,并且最后点击pushbutton能够输出的a在可视化窗口中输出显示出来。谢谢

  • 写回答

2条回答 默认 最新

  • CQ.abc 2023-04-12 00:15
    关注
    import cv2
    from PyQt5.QtCore import pyqtSlot, QObject
    
    
    class MyObject(QObject):
    
        @pyqtSlot(str)
        def hist(self, img_path):
            img = cv2.imread(img_path)
            [m, n] = img.shape
            out = []
            a = 0
            for i in range(m):
                temp = 0
                for j in range(n):
                    temp = temp + img[i, j]
                out.append(temp)
            for i in range(m):
                if out[i] != 0:
                    a = a + 1
            return a
    
    评论

报告相同问题?

问题事件

  • 系统已结题 4月20日
  • 赞助了问题酬金15元 4月12日
  • 修改了问题 4月12日
  • 创建了问题 4月11日

悬赏问题

  • ¥30 要求把带有文件的上级文件夹改成文件的名字。要求BAT
  • ¥30 不会,学习,有偿解答
  • ¥15 SQL查询语句报错(检查)
  • ¥15 此表中公式应该怎么写
  • ¥15 求HI-TECH PICC 9.50 PL3安装包
  • ¥15 下载ctorch报错,求解
  • ¥15 如何入门学习c语言,单片机
  • ¥15 idea 编辑语言的选择
  • ¥15 Windows下部署Asmjit
  • ¥15 请问双层规划模型的上下层目标函数不一致,是如何保证迭代收敛性的