Beispiel #1
0
    def jiance(self):
        face_fieldname = self.ui.comboBox.currentText()
        print(face_fieldname)
        facecodename = self.facename(face_fieldname)

        au = auth()
        cilent = au.detect(images(imgName), "BASE64", options(facecodename))
        print(len(cilent["result"]))

        #print(facecodename)
        jcxi = cilent['result']['face_list'][0][facecodename]
        print(type(jcxi))
        self.ui.textEdit.setText(str(jcxi))
Beispiel #2
0
    def face_field(self):
        face_field_list = []
        try:

            cilent = auth()
            if self.ui.checkBox.isChecked() == True:
                face_field_list.append("age")
            else:
                pass

            if self.ui.checkBox_2.isChecked() == True:
                face_field_list.append("beauty")
            else:
                pass

            if self.ui.checkBox_3.isChecked():
                face_field_list.append("expression")
            else:
                pass

            if self.ui.checkBox_4.isChecked():
                face_field_list.append('face_shape')
            else:
                pass

            if self.ui.checkBox_5.isChecked():
                face_field_list.append("emotion")
            else:
                pass

            if self.ui.checkBox_6.isChecked():
                face_field_list.append('gender')
            else:
                pass
        except:
            pass

        return face_field_list
Beispiel #3
0
def face():
    client = auth()
    face_date = client.detect(images('8.jpg'), "BASE64", options())
    print(face_date)
    with open("facedate.txt", 'a') as f:
        f.write(str(face_date))
Beispiel #4
0
    def facetest(self):
        facedate = {}
        face_list = self.face_field()
        print(face_list)
        facetest = auth()
        self.ui.textBrowser.append("检测中,请稍等...")

        for face in face_list:

            facexins = facetest.detect(images(imgName), "BASE64",
                                       options(face))
            print(facexins)
            facefield = facexins['result']["face_list"][0][face]
            print(facefield)
            facedate[face] = facefield
            time.sleep(1)
        for name in facedate.keys():
            try:
                if name == "age":

                    age = "图片种检测到的人脸的年龄 {}".format(facedate["age"])
                    self.ui.textBrowser.append(age)

                if name == 'beauty':
                    beauty = "图片中检测到的人脸的颜值 {}".format(facedate["beauty"])
                    self.ui.textBrowser.append(beauty)
                if name == "expression":
                    if facedate["expression"]["type"] == "none":
                        expression = "图片中检测到的人脸的表情为 不笑"
                    elif facedate["expression"]["type"] == "smile":
                        expression = "图片中检测到的人脸的表情为 微笑"
                    elif facedate["expression"]["type"] == "laugh":
                        expression = "图片中检测到的人脸的表情为 大笑"
                    self.ui.textBrowser.append(expression)
                else:
                    pass
                if name == "face_shape":
                    if facedate['face_shape']["type"] == "square":
                        face_shape = "图片中检测到人脸的脸型为 正方形"
                    elif facedate['face_shape']["type"] == "triangle":
                        face_shape = "图片中检测到人脸的脸型为 三角形"
                    elif facedate['face_shape']["type"] == "oval":
                        face_shape = "图片中检测到人脸的脸型为 椭圆形"
                    elif facedate['face_shape']["type"] == "heart":
                        face_shape = "图片中检测到人脸的脸型为 心形"
                    elif facedate['face_shape']["type"] == "round":
                        face_shape = "图片中检测到人脸的脸型为 圆形"
                    self.ui.textBrowser.append(face_shape)
                else:
                    pass

                if name == "gender":
                    if facedate['gender']['type'] == "male":
                        gender = "图片中检测到的人脸的性别为 男性"
                    elif facedate['gender']['type'] == "female":
                        gender = "图片中检测到的人脸的性别为 女性"
                    self.ui.textBrowser.append(gender)
                else:
                    pass

                if name == "emotion":
                    if facedate['emotion']['type'] == "angry":
                        emotion = "图片中检测到人脸的情绪为 愤怒"
                    elif facedate['emotion']['type'] == "disgust":
                        emotion = "图片中检测到人脸的情绪为 厌恶"
                    elif facedate['emotion']['type'] == "fear":
                        emotion = "图片中检测到人脸的情绪为 恐惧"
                    elif facedate['emotion']['type'] == "happy":
                        emotion = "图片中检测到人脸的情绪为 高兴"
                    elif facedate['emotion']['type'] == "sad":
                        emotion = "图片中检测到人脸的情绪为 伤心"
                    elif facedate['emotion']['type'] == "surprise":
                        emotion = "图片中检测到人脸的情绪为 惊讶"
                    elif facedate['emotion']['type'] == "neutral":
                        emotion = "图片中检测到人脸的情绪为 无情绪"
                    self.ui.textBrowser.append(emotion)
                else:
                    pass
            except:
                pass
        self.ui.textBrowser.append("检测完成")
Beispiel #5
0
def cilent():
    cilent = auth()

    cilent.detect(images(imgName))