Exemplo n.º 1
0
 def match_from_submitted(self):
     output = match()
     if output['status']:
         result = output['result']
         self.view_cases(result)
     else:
         QMessageBox.about(self, "Error", output['message'])
    def match_from_submitted(self):
        """
        This method will be called when match faces button is pressed.
        It download all data from firebase which has been submitted by user
        and runs KNN classifier on it in prediction mode. Any match above 50%
        threshold is shown here.
        """
        result = match_faces.match()
        if result == []:
            QMessageBox.about(self, "No Match Till Now", "Please Pray")
        else:
            list = QListView(self)
            list.setIconSize(QSize(72, 72))
            list.setMinimumSize(400, 380)
            model = QStandardItemModel(list)
            item = QStandardItem("Found")
            model.appendRow(item)

            for person in result:
                label, image, location = person
                label_ = str(label[0][0]).split('@')
                name = label_[0]
                mobile = label_[1]
                father_name = label_[2]
                age = label_[3]

                self.confirm(label, location, image)

                if len(name.split('*')) == 2:
                    name = name.split('*')[0] + " " + name.split('*')[1]
                if len(father_name.split('*')) == 2:
                    father_name = father_name.split('*')[0] + " " + father_name.split('*')[1]  # nopep8

                item = QStandardItem("  Name                   : " + name +
                                     "\n  Father's Name    : " + father_name +
                                     "\n  Age                      : " + age +
                                     "\n  Mobile                 : " + mobile +
                                     "\n  Location             : " + location)
                image = QtGui.QImage(image,
                                     image.shape[1],
                                     image.shape[0],
                                     image.shape[1] * 3,
                                     QtGui.QImage.Format_RGB888)
                icon = QPixmap(image)

                item.setIcon(QIcon(icon))
                model.appendRow(item)
            list.setModel(model)
            list.show()
    def match_from_submitted(self):
        result = match_faces.match()
        if result == []:
            QMessageBox.about(self, "No Match Till Now", "Please Pray")
        else:
            list = QListView(self)
            list.setIconSize(QSize(72, 72))
            list.setMinimumSize(400, 380)
            model = QStandardItemModel(list)
            item = QStandardItem("Found")
            model.appendRow(item)

            for person in result:
                label, image, location = person
                label_ = str(label[0][0]).split('@')
                name = label_[0]
                mobile = label_[1]
                father_name = label_[2]
                age = label_[3]

                self.confirm(label, location, image)

                if len(name.split('*')) == 2:
                    name = name.split('*')[0] + " " + name.split('*')[1]
                if len(father_name.split('*')) == 2:
                    father_name = father_name.split(
                        '*')[0] + " " + father_name.split('*')[1]  # nopep8

                item = QStandardItem("  Name                   : " + name +
                                     "\n  Father's Name    : " + father_name +
                                     "\n  Age                      : " + age +
                                     "\n  Mobile                 : " + mobile +
                                     "\n  Location             : " + location)
                image = QtGui.QImage(image, image.shape[1], image.shape[0],
                                     image.shape[1] * 3,
                                     QtGui.QImage.Format_RGB888)
                icon = QPixmap(image)

                item.setIcon(QIcon(icon))
                model.appendRow(item)
            list.setModel(model)
            list.show()
Exemplo n.º 4
0
    def match_from_submitted(self):
        """
        This method will be called when match faces button is pressed.
        It download all data from firebase which has been submitted by user
        and runs KNN classifier on it in prediction mode. Any match above 50%
        threshold is shown here.
        """
        result = match_faces.match()
        #print(result)
        if result == []:
            QMessageBox.about(self, "Message",
                              "No Match Till Now, Please Pray")
        elif result == "None":
            QMessageBox.about(self, "Message", "No New Case Registered")
        else:
            list = QListView(self)
            list.setIconSize(QSize(72, 72))
            list.setMinimumSize(400, 380)
            model = QStandardItemModel(list)
            item = QStandardItem("Found")
            model.appendRow(item)
            for person in result:
                label, image, location = person
                label_ = str(label[0][0])
                result = fetch_pending_cases_by_unique_id(label_)
                if result is not None:
                    caseId = result.get('caseId')
                    name = str(result.get('name'))
                    mobile = str(result.get('mobile'))
                    father_name = str(result.get('father_name'))
                    age = str(result.get('age'))
                    email = str(result.get('email'))

                    self.confirm(label_, caseId, name, father_name, age,
                                 mobile, email, location, image)

                    sendFoundSMS(caseId, father_name, mobile, location)

                    item = QStandardItem("  Name                   : " + name +
                                         "\n  Father's Name    : " +
                                         father_name +
                                         "\n  Age                      : " +
                                         age +
                                         "\n  Mobile                 : " +
                                         mobile +
                                         "\n  Location             : " +
                                         location)
                    image = QtGui.QImage(image, image.shape[1], image.shape[0],
                                         image.shape[1] * 3,
                                         QtGui.QImage.Format_RGB888)
                    icon = QPixmap(image)

                    imagePath = "FoundImages/" + caseId + mobile + ".jpeg"

                    sendFoundMail(imagePath, caseId, father_name, email,
                                  location)

                    item.setIcon(QIcon(icon))
                    model.appendRow(item)
            list.setModel(model)
            list.show()