Exemplo n.º 1
0
 def test_drawresult(self):
     self.image_with_person = ImageFile('./images/person.jpg')
     yoloc = YoloClassifier()
     yoloResult = yoloc.findEntitiesInPicture(self.image_with_person)
     img = self.image_with_person.getImage()
     newImg = yoloc.draw_result(img, yoloResult)
     self.assertTrue(newImg.shape[0] == 424)
     self.assertTrue(newImg.shape[1] == 640)
     self.assertTrue(newImg.shape[2] == 3)
def main():
    logging.info('************* BEGIN check_false_alarms.py ************')
    mailManager = EmailManager()
    #Count number of emails

    numMails = mailManager.checkMailbox(MailboxSettings())
    logging.info('Found %s emails', str(numMails))
    if (numMails > 0):
        yolo = YoloClassifier()
    #For every email
    if (numMails > 5):
        numMails = 5
        logging.info('Only 5 emails will be checked in this execution.')
    for i in range(numMails):
        #Get the pictures
        logging.info('**** Checking email with ID %i ****', i)
        eMailInfo = mailManager.getInfoFromEmail(i, MailboxSettings())
        images = eMailInfo.getAttachments()
        if (len(images) == 0):
            logging.info('No images found in the email with ID %i', i + 1)
        else:
            #For every image, call Yolo try to detect a person
            for oneImage in images:
                logging.info('Checking image %s', oneImage)
                if (yolo.findPersonInPictureWithCandidates(
                        ImageFile(oneImage)) == True):
                    logging.info('Found person in picture %s', oneImage)
                    #Send email to notify there is a real alert
                    #Prepare the contents of the alert
                    eMailContentAlert = mailManager.prepareAlert(eMailInfo)
                    #Send the email
                    mailManager.sendEmail(eMailContentAlert, SmtpSettings())
                    break
                else:
                    logging.info('No person found in picture %s', oneImage)
    #Remove the emails once they have been processed
    #mailManager.multipleDeleteEmail(range(numMails),MailboxSettings())
    logging.info('************* END check_false_alarms.py ************')
Exemplo n.º 3
0
 def test_findPersonInPictureWithCandidates(self):
     self.image_with_person = ImageFile('./images/image_with_person.jpg')
     res = YoloClassifier().findPersonInPictureWithCandidates(
         self.image_with_person)
     self.assertTrue(res)
Exemplo n.º 4
0
 def test_findEntitiesInPicture(self):
     self.image_with_person = ImageFile('./images/person.jpg')
     res = YoloClassifier().findEntitiesInPicture(self.image_with_person)
     self.assertTrue(res[0][0], 'person')
Exemplo n.º 5
0
 def test_findPersonInPicture_with_PersonEasy2(self):
     self.image_with_person = ImageFile('./images/image_with_person9.jpg')
     self.assertTrue(YoloClassifier().findPersonInPicture(
         self.image_with_person))
Exemplo n.º 6
0
 def test_findPersonInPicture_with_PersonDifficult(self):
     self.image_with_person = ImageFile(
         'image_with_person_difficult.jpg',
         './images/image_with_person_difficult.jpg')
     self.assertTrue(YoloClassifier().findPersonInPicture(
         self.image_with_person))
Exemplo n.º 7
0
 def test_findPersonInPicture_without_Person(self):
     self.image_without_person = ImageFile(
         './images/image_without_person.jpg')
     self.assertFalse(YoloClassifier().findPersonInPicture(
         self.image_without_person))