def run(self):
        print("FrameService类.GrayThread已打开")
        # 等待事件触发
        try:
            while True:
                # 等待灰度图
                self.channel.threadEvent[1].wait()

                # 先获得灰度图
                gray = self.channel.frame[1]
                # 获得人脸位置
                faceLocation = getFaceLocations(gray)
                # 获得人脸位置
                if len(faceLocation) == 0:
                    print("没有人脸")
                    self.channel.threadEvent[1].clear()
                    continue
                else:
                    # 获得人脸编码 # .repeat(3, 2)
                    faceEncoding = getFaceEncode(gray,faceLocation)
                    print("人脸编码为:{0}".format(faceEncoding))

                    pass




                # 通知水印。。
                self.channel.threadEvent[1].clear()
        except:
            error = traceback.fromat_exc()
            raise Exception(error)
Esempio n. 2
0
    def run(self):
        print("InputDevice类.VideoOrgThread已打开")
        try:
            while True:
                # 输入原图
                ret, org = self.cap.read()

                if ret:
                    # 通知获取原图
                    # 优先Label输出
                    self.channel.channelDict[self.channel.channelID]["frame"][0] = org
                    self.channel.channelDict[self.channel.channelID]["RefreshThreadEvent"].set()


                    # 通知灰度处理
                    self.channel.frame[0] = org
                    self.channel.threadEvent[0].set()

                    # 等待前台获取优先图
                    self.channel.channelDict[self.channel.channelID]["RefreshThreadEvent"].wait()
                else:
                    # 重新播放
                    self.cap.set(cv2.CAP_PROP_POS_FRAMES,0)
                # 等待优先图输出
                # self.channel.threadEvent[2].wait()
        except:
            error = traceback.fromat_exc()
            raise Exception(error)
Esempio n. 3
0
    def run(self):
        print("{0}通道的RefreshThread已经打开!".format(self.channelID))
        time.sleep(3)
        start = None
        end = None

        try:
            last_time = time.time()
            while True:

                # 等待唤醒
                self.channelDict[self.channelID]["RefreshThreadEvent"].wait()

                cur_time = time.time()
                print("距离上次唤醒时间:{0}".format(cur_time - last_time))
                last_time = cur_time

                start = time.time()

                self.org2Image()
                # 添加水印 -》有的话
                # 延时
                time.sleep(0.01)
                # 发送信号
                self.signal.emit()

                end = time.time()
                print("本次图像处理共耗时{0}".format(end - start))

        except:
            error = traceback.fromat_exc()
            print(error)
            return error
    def refreshCommon(self):

        try:

            self.setPixmap(QPixmap().fromImage(self.image))
        except:
            error = traceback.fromat_exc()
            print(error)
            return error
Esempio n. 5
0
    def run(self):
        print("InputDevice类.GrayThread已打开")
        time.sleep(2)
        try:
            while True:
                # 等待原图输入
                self.channel.threadEvent[0].wait()
                # 获取原图
                org = self.channel.frame[0]
                self.channel.threadEvent[0].clear()

                # 写入灰度图
                self.channel.frame[1] = cv2.cvtColor(org, cv2.COLOR_BGR2RGB)


                # 灰度图已处理完,通知相关线程
                self.channel.threadEvent[1].set()
        except:
            error = traceback.fromat_exc()
            raise Exception(error)
 def run(self):
     print("{0}通道的ChannelCtlThread一打开!".format(self.channel.channelID))
     try:
         while True:
             # 等待通道控制命令
             self.channel.channelDict[
                 self.channel.channelID]["ChannelCtrThreadEvent"].wait()
             # 获取命令
             order = self.channel.channelDict[
                 self.channel.channelID]["ChannelCtrThreadContent"][0]
             # 清空命令
             self.channel.channelDict[
                 self.channel.channelID]["ChannelCtrThreadContent"][0] = ""
             print("{0}通道接受到{1}命令".format(self.channel.channelID, order))
             if order == "open":
                 self.channel.open()
             # self.channel.testE.set()
             self.channel.channelDict[
                 self.channel.channelID]["ChannelCtrThreadEvent"].clear()
     except:
         error = traceback.fromat_exc()
         raise Exception(error)
Esempio n. 7
0
    def run(self):
        print("InputDevice类.CameraOrgThread已打开")
        try:
            while True:

                # 输入原图
                ret, org = self.cap.read()
                # 通知获取原图

                # 通知Label输出
                self.channel.channelDict[self.channel.channelID]["frame"][0] = org
                self.channel.channelDict[self.channel.channelID]["RefreshThreadEvent"].set()

                # 通知灰度处理
                self.channel.frame[0] = org
                self.channel.threadEvent[0].set()

                # 等待前台获取优先图
                self.channel.channelDict[self.channel.channelID]["RefreshThreadEvent"].wait()
        except:
            error = traceback.fromat_exc()
            raise Exception(error)
Esempio n. 8
0
"""
本文件用于删除目录下所有 *.pyc的文件
__create_time__ = '13-10-18'
__author__ = 'Madre'
"""
import os
import fnmatch

MAX_DEPTH = 4  # 遍历4层目录


def delete_pyc(path, depth):
    if MAX_DEPTH == depth:
        print depth
        return
    for it in os.listdir(path):
        if os.path.isdir(path + '/' + it):
            delete_pyc(path + '/' + it, depth + 1)
        else:
            if fnmatch.fnmatch(' ' * depth + it, '*.pyc'):
                os.remove(path + '/' + it)


if __name__ == "__main__":
    file_path = os.path.split(os.path.realpath(__file__))[0]
    try:
        delete_pyc(file_path, 1)
    except:
        import traceback
        print traceback.fromat_exc()
Esempio n. 9
0
"""
本文件用于删除目录下所有 *.pyc的文件
__create_time__ = '13-10-18'
__author__ = 'Madre'
"""
import os
import fnmatch

MAX_DEPTH = 4  # 遍历4层目录


def delete_pyc(path, depth):
    if MAX_DEPTH == depth:
        print depth
        return
    for it in os.listdir(path):
        if os.path.isdir(path+'/'+it):
            delete_pyc(path+'/'+it, depth+1)
        else:
            if fnmatch.fnmatch(' '*depth + it, '*.pyc'):
                os.remove(path+'/'+it)


if __name__ == "__main__":
    file_path = os.path.split(os.path.realpath(__file__))[0]
    try:
        delete_pyc(file_path, 1)
    except:
        import traceback
        print traceback.fromat_exc()