Thief Identification using face recognition by sending alert
Data science projects in pondicherry
Create New

Thief Identification using face recognition by sending alert

Project period

08/10/2020 - 08/24/2020




Project Category

Computer Science

Thief Identification using face recognition by sending alert
Thief Identification using face recognition by sending alert

Since the beginning, security has become a significant concern. The criminal activities have inflated exponentially over the last 3 decades. The motivation for developing this project is to spot the criminal roaming publically places with the assistance of face recognition technology and send mail to the authority persons.

Facial recognition may be an approach to recognizing the face. An automatic face recognition system can acknowledge a face from a photograph or video. It compares the information(criminal face) with info of  faces to search out a match. Once the criminal face is known, associate alert mail is sent to the individual authority.

The face of a personality's conveying a great deal of data regarding the identity and emotion of the person. Our analysis work mainly consists of 3 elements, particularly face illustration, feature extraction, and classification. Face illustration represents the way to model a face and determines the sequence algorithms of detection and recognition. The foremost helpful and distinctive options of the face image area unit extracted within the feature extraction part. within the classification, the face image is compared with the pictures from the info. In our analysis work, we have a tendency to buy trial and error judge face recognition that considers each form and texture info to represent face pictures supported native Binary Patterns for a person- freelance face recognition. The face space is 1st divided into tiny regions from that native Binary Patterns (LBP), histograms area unit extracted and concatenated into one feature vector. This feature vector forms associate economical illustration of the face and is employed to live similarities between pictures.

Why: Problem statement

In my final year of college, I witnessed the robbery but I wasnt able to do anything. Actually, when I was standing with my friend on the bus stand, our money was stolen by someone. There was a crowd in the bus stand. So, we could not find who had stolen our money. We have informed the police also, but they cant find him. But they said that some known criminals have more chances to do that. 

That movement motivated me to build this project. In this project, we train the images of the criminal using face recognition algorithms with the help of python language. We can keep the algorithm fixed  CCTV Camera in public places like temples, bus stands, and public places, etc. The CCTV camera will capture all the person’s faces and compare them with the trained faces. Once the trained face was identified, the notification will be sent to the authorized person through the mail.

How: Solution description

To overcome the issue mentioned in the problem statement this project has been developed. Using the face recognition library in python language we can identify the criminals in public places with the help of CCTV Cameras.

To identify the criminal faces first we have to undergo the three modules in python language. 

This project has three modules as follows: 

  • Data collection 
  • Training 
  • DNN algorithm 
  • Mail alert

Data Collection:

We have to collect the data(photos) from the authorized person(Police) regarding criminals. The data is in the form of images. Here, the dataset consists of criminal photos. 

DNN Algorithm:

We use the DNN algorithm to train the data. We give person names for all the images. A deep neural network (DNN) is an artificial neural network (ANN) with multiple layers between the input and output layers. The DNN finds the correct mathematical manipulation to turn the input into the output, whether it be a linear relationship or a non-linear relationship. During testing, we have to turn on the webcam on our system. Our faces will be captured through the webcam. The DNN model will compare the face detected through the web with the trained faces. If the face matched with any one of the trained faces, it will display the person’s name else it won’t display anything.

Mail Alert:

We set up an SMTP protocol for sending emails. If the criminal face was recognized with the help of the DNN algorithm, the email will be sent to the respective authority automatically.



How is it different from competition

In this Theft Identification project, we implemented alert systems. With the help of the Deep neural network algorithm, we can recognize the face of a person. The alert system immediately sends an email to the authorized person once the thief was caught in the camera. This is the uniqueness of this project. Various face gesture systems have been captured around the world but they are neither flexible nor cost-efficient for the end-users. But from the no. of captured face gestures, we can accurately identify the user’s face with the help of face DNN algorithm.

Who are your customers

Higher authorities in the police stations, public commissions are our customers. We help them identify thieves in the easiest way. They need to roam places and take more effort to find the thief. They usually spend more time and take efforts to search for the thief. Using this project, they can identify the thieves from the place where they are. Some thieves have many chances to wander in public places. So, we can also use this system in malls, shops, theatres, and public places. Using this system, we can reduce the number of thieves that leads to a peaceful nation. 

Project Phases and Schedule

Tool Installation:

Install anaconda tool and python packages like NumPy, OpenCV. Make sure that we have installed current versions for all the libraries. 

Data Collection: We collected five thieves' pictures and trained them using the Deep Neural Network algorithm.

Training: The language we used for programming in Python. The DNN algorithm detects the face first. It will detect eyes, nose, mouth, and cheeks based on the given parameter range. And it will train all the given faces based on the hyperparameters like batch size, epochs, and learning rate. Once the training is done, we have to test it by giving some real faces. We tested the model, it shows the name of the thief once the thief’s face was found. If some other faces were captured, it didn’t show their name.

Sending Alert: We set up email alerts using SMTP protocol. Once the thief’s face is found, it automatically sends an email alert to the authorized person. If the face was not found, the system will not send any messages.

Resources Required

Anaconda tool: Anaconda may be a free and open-source distribution of the Python and R programming languages for scientific computing (data science, machine learning applications, large-scale processing, prediction analysis, etc.), that aims to clarify package management and implementation. The distribution includes data-science packages appropriate for Windows, Linux, and macOS. You can download anaconda tool for Python by clicking this link

Python version 3.7: Underneath the Python Releases for Windows find Latest Python 3 Release – Python 3.7. 4 (latest stable release as of now is Python 3.7. The advantages of Python 3.7 are Easier access to debuggers through a new breakpoint() built-in, Simple class creation using data classes, Customized access to module attributes, Improved support for type hinting and Higher precision timing functions. 

Libraries: OpenCV 2.4.8, had been working with OpenCV, an open-source computer vision library, and I needed an engineer a solution that would grab an image from the screen, then resize and transform the image, that my model could understand.

Deep learning: Deep learning is an AI function that mimics the workings of the human brain in processing data for use in detecting objects, recognizing speech, translating languages, and making decisions. Deep learning AI is able to learn without human supervision, drawing from data that is both unstructured and unlabeled.

Web Browser: A web browser (commonly referred to as a browser) is a software application for accessing the information on the World Wide Web. When a user requests a web page from a particular website, the web browser retrieves the necessary content from a web server and then displays the page on the user's device.

Project Code Code copy
/* Your file Name : Face recognition with mail sending feature.ipynb */
/* Your coding Language : python */
/* Your code snippet start here */
 "cells": [
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
     "ename": "SMTPAuthenticationError",
     "evalue": "(535, b'5.7.8 Username and Password not accepted. Learn more at\\n5.7.8 f18sm7660517pga.75 - gsmtp')",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31mSMTPAuthenticationError\u001b[0m                   Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-3-6f299552873b>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m     43\u001b[0m             \u001b[0ms\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msmtplib\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mSMTP\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m''\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m587\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     44\u001b[0m             \u001b[0ms\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstarttls\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 45\u001b[0;31m             \u001b[0ms\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mlogin\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m''\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'ZXCv123!@#'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     46\u001b[0m             \u001b[0mdatetime\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     47\u001b[0m             \u001b[0mmessage\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m\"Person detected in the camera\"\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/opt/anaconda3/lib/python3.7/\u001b[0m in \u001b[0;36mlogin\u001b[0;34m(self, user, password, initial_response_ok)\u001b[0m\n\u001b[1;32m    728\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    729\u001b[0m         \u001b[0;31m# We could not login successfully.  Return result of last attempt.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 730\u001b[0;31m         \u001b[0;32mraise\u001b[0m \u001b[0mlast_exception\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    731\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    732\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0mstarttls\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mkeyfile\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcertfile\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcontext\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/opt/anaconda3/lib/python3.7/\u001b[0m in \u001b[0;36mlogin\u001b[0;34m(self, user, password, initial_response_ok)\u001b[0m\n\u001b[1;32m    719\u001b[0m                 (code, resp) = self.auth(\n\u001b[1;32m    720\u001b[0m                     \u001b[0mauthmethod\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mgetattr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmethod_name\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 721\u001b[0;31m                     initial_response_ok=initial_response_ok)\n\u001b[0m\u001b[1;32m    722\u001b[0m                 \u001b[0;31m# 235 == 'Authentication successful'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    723\u001b[0m                 \u001b[0;31m# 503 == 'Error: already authenticated'\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m~/opt/anaconda3/lib/python3.7/\u001b[0m in \u001b[0;36mauth\u001b[0;34m(self, mechanism, authobject, initial_response_ok)\u001b[0m\n\u001b[1;32m    640\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0mcode\u001b[0m \u001b[0;32min\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0;36m235\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m503\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    641\u001b[0m             \u001b[0;32mreturn\u001b[0m \u001b[0;34m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mresp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 642\u001b[0;31m         \u001b[0;32mraise\u001b[0m \u001b[0mSMTPAuthenticationError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcode\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mresp\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    643\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    644\u001b[0m     \u001b[0;32mdef\u001b[0m \u001b[0mauth_cram_md5\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mchallenge\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mNone\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mSMTPAuthenticationError\u001b[0m: (535, b'5.7.8 Username and Password not accepted. Learn more at\\n5.7.8 f18sm7660517pga.75 - gsmtp')"
   "source": [
    "import face_recognition\n",
    "import cv2\n",
    "import numpy as np\n",
    "video_capture = cv2.VideoCapture(0)\n",
    "obama_image = face_recognition.load_image_file(\"obama.jpg\")\n",
    "obama_face_encoding = face_recognition.face_encodings(obama_image)[0]\n",
    "geeva_image = face_recognition.load_image_file(\"photo3.jpeg\")\n",
    "geeva_face_encoding = face_recognition.face_encodings(geeva_image)[0]\n",
    "known_face_encodings = [\n",
    "    obama_face_encoding,\n",
    "    geeva_face_encoding\n",
    "known_face_names = [\n",
    "    \"Obama\",\n",
    "    \"Geeva\"\n",
    "face_locations = []\n",
    "face_encodings = []\n",
    "face_names = []\n",
    "process_this_frame = True\n",
    "while True:\n",
    "    ret, frame =\n",
    "    small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)\n",
    "    rgb_small_frame = small_frame[:, :, ::-1]\n",
    "    if process_this_frame:\n",
    "        face_locations = face_recognition.face_locations(rgb_small_frame)\n",
    "        face_encodings = face_recognition.face_encodings(rgb_small_frame, face_locations)\n",
    "        face_names = []\n",
    "        for face_encoding in face_encodings:\n",
    "            matches = face_recognition.compare_faces(known_face_encodings, face_encoding)\n",
    "            name = \"Unknown\"\n",
    "        \n",
    "            face_distances = face_recognition.face_distance(known_face_encodings, face_encoding)\n",
    "            best_match_index = np.argmin(face_distances)\n",
    "            if matches[best_match_index]:\n",
    "                name = known_face_names[best_match_index]\n",
    "            face_names.append(name)\n",
    "            \n",
    "            import smtplib \n",
    "            s = smtplib.SMTP('', 587) \n",
    "            s.starttls()\n",
    "            s.login('', 'Password') \n",
    "            datetime = \"\"\n",
    "            message = \"Person detected in the camera\"\n",
    "            s.sendmail(\"\", \"\", message, datetime) \n",
    "            import requests\n",
    "            res = requests.get('')\n",
    "            data = res.json()\n",
    "            city = data['city']\n",
    "            location = data['loc'].split(',')\n",
    "            latitude = location[0]\n",
    "            longitude = location[1]\n",
    "            print(\"Latitude : \", latitude)\n",
    "            print(\"Longitude : \", longitude)\n",
    "            print(\"City : \", city)\n",
    "            s.quit() \n",
    "    process_this_frame = not process_this_frame\n",
    "    for (top, right, bottom, left), name in zip(face_locations, face_names):\n",
    "        top *= 4\n",
    "        right *= 4\n",
    "        bottom *= 4\n",
    "        left *= 4\n",
    "        cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)\n",
    "        cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)\n",
    "        font = cv2.FONT_HERSHEY_DUPLEX\n",
    "        cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)\n",
    "    cv2.imshow('Video', frame)\n",
    "    if cv2.waitKey(1) & 0xFF == ord('q'):\n",
    "        break\n",
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.4"
 "nbformat": 4,
 "nbformat_minor": 4
View on Github
Theif identification using face recognition with mail alert


Leave a Comment

Post a Comment

Are you Interested in this project?

Do you need help with a similar project? We can guide you. Please Click the Contact Us button.

Contact Us

Social Sharing