Final Report
Final Report
PROJECT REPORT
submited by:
to
of
Bachelor of Technology
in
Computer Science and Engineering
PROF. SANGEETHA A
CERTIFICATE
This is to certify that the report entitled AN INTRUSION DETECTION SYSTEM sub-
mitted by JOEL LALU (ADR22CS037), JOSHUA JAMES (ADR22CS039), SHAMBHU
S(ADR22CS059), UBAID D A (LADR22CS068) to the APJ Abdul Kalam Technological
University in partial fulfillment of the requirements for the award of the Degree of Bachelor
of Technology in Computer Science and Engineering is a bonafide record of the project work
carried out by them under my guidance and supervision. This report in any form has not been
submitted to any other University or Institute for any purpose.
Countersigned by:
Dr VINOD P R
Head of Department External Examiner
DECLARATION
We undersigned hereby declare that the project report AN INTRUSION DETECTION
SYSTEM submitted for partial fulfillment of the requirements for the award of the degree of
Bachelor of Technology of the APJ Abdul Kalam Technological University, Kerala is a bonafide
work done by us under supervision of Prof SANGEETHA A. This submission represents our
ideas in our own words and where ideas or words of others have been included, we have ade-
quately and accurately cited and referenced the original sources. We also declare that we have
adhered to the ethics of academic honesty and integrity and have not misrepresented or fabri-
cated any data or idea or fact or source in my submission. We understand that any violation
of the above will be a cause for disciplinary action by the institute and/or the University and
can also evoke penal action from the sources which have thus not been properly cited or from
whom proper permission has not been obtained. This report has not been previously formed as
the basis for the award of any degree, diploma, or similar title of any other University.
ACKNOWLEDGEMENT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . i
ABSTRACT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ii
LIST OF FIGURES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iii
ABBREVIATIONS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . iv
1 INTRODUCTION 1
1.1 MOTIVATION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 PROBLEM DESCRIPTION . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3 SCOPE OF PROPOSED SYSTEM . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.4 OBJECTIVES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.5 PROJECT SCHEDULE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 LITERATURE REVIEW 5
2.1 LITERATURE SURVEY OVERVIEW . . . . . . . . . . . . . . . . . . . . . . . . 9
3 SYSTEM DESIGN 11
3.1 DATA FLOW DIAGRAM LEVEL 0 . . . . . . . . . . . . . . . . . . . . . . . . . 11
3.2 DATA FLOW DIAGRAM LEVEL 1 . . . . . . . . . . . . . . . . . . . . . . . . . 11
4 SYSTEM ARCHITECTURE 15
4.1 ARCHITECTURAL DIAGRAM . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5 DESIGN 19
6 REQUIREMENT ANALYSIS 22
6.1 SOFTWARE REQUIREMENTS . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
6.2 HARDWARE REQUIREMENTS . . . . . . . . . . . . . . . . . . . . . . . . . . 23
7 METHODOLOGY 24
8 IMPLEMENTATION 25
10 CONCLUSION 38
References 39
ACKNOWLEDGEMENT
We extend our profound gratitude to God almighty for His blessings. Our heartfelt thanks
to Dr. K Sunilkumar, Principal, College of Engineering, Adoor, and Dr. Vinod P R , Head of
Department, for their exceptional support throughout our journey. We reserve special appreci-
ation for Prof. Sangeetha A whose mentorship has been invaluable. Our gratitude extends to
the dedicated faculty, supportive friends, and loving family members who stood by us. We also
acknowledge the invaluable contributions of researchers in Intrusion Detection System. Lastly,
we express our sincere thanks to everyone involved; your unwavering support has been the cor-
nerstone of our success. We earnestly hope that our endeavors in Intrusion Detection System
will contribute positively to the betterment of society.
i
ABSTRACT
An Intrusion Detection System (IDS) is a type of security system that monitors highly re-
stricted areas and alerts system administrators or security personnel when it detects suspicious
or unauthorized activity.Security systems often depend on human operators to monitor live
video feeds, which is prone to human errors.Traditional security cameras could only record
video but lacked real-time analysis or automated alerting capabilities.Older systems lacked ad-
vanced alerting mechanisms to immediately notify authorities or owners. These are some of
the problems of existing security systems.Security in restricted areas is essential for protecting
valuable assets, sensitive information, ensuring the safety of personnel from intruders.. Authen-
tication of the entered person can be done by face identification, through which a smart security
system can be developed. Creating and implementing a face recognition-based surveillance
system is the goal of this project. Real time Intrusion detection system provides surveillance for
restricted and confidential areas with help of face recognition and detection, when an intruder
or unauthorized person enters the restricted areas.
ii
LIST OF FIGURES
iii
ABBREVIATIONS
5 LR Logistic Regression
iv
Chapter 1
INTRODUCTION
An Intrusion Detection System (IDS) is a security solution designed to monitor highly restricted
areas and identify unauthorized or suspicious activity. It plays a crucial role in enhancing
surveillance by automatically detecting the presence of intruders and immediately notifying
system administrators or security personnel.
This system operates in real-time by analyzing camera feeds and detecting unauthorized indi-
viduals within a specified time frame. Upon detection, it triggers an alert, captures a snapshot
of the intruder, and sends it to the admin for further action.Administrators can securely log in to
a dedicated web application to view detailed reports, respond to alerts, and review the history
of all intrusion attempts.
This combination of automation and user control ensures efficient,timely,and accurate intru-
sion monitoring.This advanced system continuously monitors the protected zone, vigilantly
detecting any suspicious or unauthorized activity. Upon identifying an intruder,the IDS swiftly
triggers an alert, notifying system administrators or security personnel of the potential threat.
The IDS takes proactive measures to address the security breach, capturing a snapshot of the
unauthorized individual and sending it to the administrator for further action. This enables
the admin to visually verify the identity of the intruder and assess the severity of the situation.
Furthermore, the system prompts the administrator to decide on the course of action to be taken,
ensuring a swift and effective response to the security threat.
To provide a comprehensive security solution, the IDS is integrated with a web application that
allows administrators to access detailed reports and histories of previous intrusion attempts.
By logging into the web application, admins can review incident reports, analyze secu-
rity trends, and refine their response strategies to enhance the overall security posture of the
protected area. This centralized platform enables administrators to stay informed, respond
promptly, and maintain a secure environment.
1.1 MOTIVATION
In current fast growing world,We are in need to work with Different Application and Technolo-
gies. To ensure the Security of the Application we use and to overcome from Threats , Attacks
malicious activity that occurs in a network or a system, An Intrusion detection system is de-
signed and used.Intrusion Detection is software or a device that scans a system or a network for
a distrustful activity.intrusion detection becomes vital to perform network security using various
1
AN INTRUSION DETECTION SYSTEM 2
machine learning techniques to build different types of Intrusion Detection Systems to protect
the networks. Performance of an Intrusion Detection is mainly depends on accuracy level.. Ma-
chine learning techniques like Support Vector Machine (SVM) , Logistic Regression , Random
Forest , Random Projection and Decision Tree Algorithm are applied. These techniques are
well-known to solve the classification problems. For evaluation of intrusion detection system,
CSL- KDD knowledge discovery Dataset is taken. The outcomes show the best accuracy level.
1.4 OBJECTIVES
The objective of the Intrusion Detection System (IDS) is to provide real-time security mon-
itoring and alerting capabilities to detect and respond to unauthorized access attempts. This
enables prompt identification and notification of potential security breaches, allowing admin-
istrators to take swift action to prevent or mitigate damage.Another key objective of the IDS
is to provide visual evidence of unauthorized activity through snapshots of the intruder. This
visual evidence can be instrumental in identifying the perpetrator and taking subsequent action.
Furthermore, the system’s ability to trigger messages and alerts ensures that administrators are
notified promptly, enabling them to respond quickly and effectively.The IDS also aims to pro-
vide a comprehensive record of all intrusion attempts, allowing administrators to access reports
and historical data through a web-based platform. This enables informed decision-making,
facilitates the identification of patterns or trends in unauthorized activity, and supports the de-
velopment of more effective security strategies.
LITERATURE REVIEW
by Guruprasad.U , Bhavani M
It detects motion and capture image, sends out e-mail notification attached together with the
image file via SMTP server as alert, making it a real-time system. Further the admin can react
to any situation immediately, where as in other systems he will just know about the the heft
happening but could not react to it.By using this surveillance system, we can reduce the video
storage system for a huge extent since it will store the video only if it detects any motion and
also it reduces the cost of the entire system. It does not need any manpower to monitor the
entire video continuously and hence it also reduces the man power required for surveillance
system. It detects motion and capture image, sends out e-mail notification attached together
with the image file via SMTP server as alert, making it a real-time system. Further the admin
can react to any situation immediately, where as in other systems he will just know about the
theft happening but could not react to it.
In this Paper have presented the details of a new approach called outlier detection approach
to detect the approach to detect the instruction in the computer network.Our training model
consists of big datasets with distributed environment that improves the performance of Intrusion
detection system. The proposed approach is also been tested with the KDD datasets that are
received from real world. The machine learning approaches detect the intrusion in the computer
network with huge execution time and storage to predict the when compared to the proposed
IDS system which takes less execution time and storage to test the dataset .Here in this study, the
performance of proposed IDS is better than that of other existing machine learning approaches
and can significantly detect almost all anomaly data in the computer network. In future, the
proposed work can be possibly used for various distance computation function between the
trained model and testing data. Our research work can be considered to improve the efficiency
of IDS in a better manner.
5
AN INTRUSION DETECTION SYSTEM 6
by Patrick Vanin, Laban Laxmi Dhirani, John O’Connell, Donna O’Shea, Brian Lee
This paper provides a thorough study of Intrusion Detection Systems and how they could be
improved using machine learning.Firstly, the concept of Intrusion Detection Systems was pre-
sented. There are three main types of IDS: Network Intrusion Detection System, Host Intrusion
Detection System,and a Hybrid Intrusion Detection System. In addition, each type of IDS can
either detect attacks by using a recorded signature or by comparing the behavior of the net-
work with a baseline of the normal traffic or both. Then, the different metrics used to assess
Intrusion Detection System by various researchers are presented. The most important met-
rics are the Accuracy, the Detection Rate (Recall) and the F-Measure. A general overview of
what is machine learning, and a global taxonomy is also discussed. There are three types of
machine learning techniques: Supervised, Semi-supervised and Unsupervised. Most of the ma-
chine learning techniques studied fall into one of these categories. A comprehen-sive review
of recently published papers using machine learning for IDS was also dis-cussed. Based on
this study, the recent trends show that deep learning methods are more and more used to detect
attacks. However, this increases the complexity of the models which requires more computing
resources. In addition, it was shown that more and more solutions are using feature extraction
with Auto-Encoder as one of the techniques used.
This paper attempts to undergo comprehensive review on existing Intrusion Detection Systems
(IDS) and datasets. Different recent techniques such as data mining, machine learning and deep
learning are reviewed.In addition to this,the proposed work presents a comprehensive approach
in the field of cyber security and machine learning by using CNN algorithm and CSE-CIC-
IDS2018 dataset. The intended work shall include the calculation the different performance
matrix such as precision, recall, f1score and accuracy.
This paper critically demonstrates process to develop a basic intrusion detection system in
Python using both external and inbuilt modules, hence, drawing one of the most fundamen-
tal paradigms to explain the working and design of intrusion detection.As explained, this self-
designed basic intrusion detection system is an appropriate example to understand the basics
of cyber intrusions and their concerned preventive measures. The principle property of the
designed system lies in its very operation at the most fundamental and institutional level of op-
eration. And therefore, this concept can be heretofore used as a building block for researches in
the similar field of interest/expertise, as evident by the provided case studies, for both Gamma
testing and Beta testing. For future, we expect to thoroughly design an advanced neural network
based artificially intelligent intrusion detection and prevention system.
This study also examines four common evasion techniques to determine their ability to evade
the recent IDSs. An effective IDS should be able to detect different kinds of attacks accurately
including intrusions that incorporate evasion techniques.In the Internet, the outside attackers
may be amateur pranksters or organized criminals or international terrorists or even hostile
governments. A computer network consists of two components namely hardware and soft-
ware. Both of these components may have their own risks and vulnerabilities. In this paper,
we have surveyed various types of Intrusion Detection Model in different cases. This paper
presented intrusion detection systems (IDS) in several areas. It consist of Web Application,
Cloud Environment, Internet of Things (IoT), Mobile Ad-Hoc Network (MANET), Wireless
Sensor Network (WSN) and Voice over Internet Protocol (VOIP). We have found that IDS is a
significant part in security system of the networks.
An intrusion detection system is a software application or device that scans a network for abnor-
mal or malicious activities. Attackers can apply several different approaches when attempting
to infiltrate into a system. A sound intrusion detection system must understand the patterns
of different types of updated intrusions. While using machine learning techniques to detect
such skeptical approaches, the classifiers should be updated and trained with newly available
samples. The characteristic of an efficient IDS is to detect attacks accurately with a minimum
misclassification rate.This research work showed the experiments and results of different ap-
proaches to use intrusion data methodically for detecting intrusions using machine learning
techniques. The research goals mentioned in Section III-A have been achieved and answered
with the support of experimental results and discussions. However, we can deduce that this
research’s methodology and analysis can be deployed in a network intrusion detection system
to get better detection performance. Cost-sensitive learning is a type of learning that consid-
ersisclassification costs. The goal of this kind of learning is to minimize the total cost. In the
future, research can beconducted to reduce the misclassification rate and increase the perfor-
mance more by applying cost-sensitive learning on this methodology.
The necessity for IoT security has been highlighted by series of high-profile cases in which a
common IoT device was used to access and attack a larger network. It is crucial for assuring
the security of networks that have IoT devices attached to them. IoT security encompasses a
wide range of tactics, strategies, protocols, and actions aimed at mitigating modern enterprises’
growing IoT risks. By exploiting the generative adversarial network (Skip-GANomaly), this
paper proposes a specific IDS, called “EdgeIDS”, for IoT devices. This proposed “EdgeIDS”
outperforms quantitatively state-of-the-art methods. The experimental results in this study shed
light on the suggested method’s capacity to detect anomalies traffic thus attacks in an IoT en-
vironment. Because most IoT devices have limited capabilities, the proposed “EdgeIDS” will
be compelled to analyze only the network’s inbound data in real-time. In addition, another net-
work IDS “DL-NIDS” must be deployed on the fog node to strengthen security on a device with
higher processing power, ideally coupled to a lightweight hardware accelerator.
by Shadi Abudulla,Ekhlas S
In this work, we designed and implemented a Network Intrusion Detection System (NIDS) by
using machine learning. This presented system detects attack in real-time. The system de-
tects attack by using the model that was selected from different machine learning techniques.
The model was selected by evaluating five classification algorithms: Decision Tree (DT), Ran-
dom Forest (RF),Naive Base, Multi-Layer Perceptron (MLP) and Logistic Regression (LR).
We evaluated selected algorithms by finding the best accuracy. The models was trained by us-
ing CSE-CIC-IDS2018 dataset which contains different types of attacks. We also developeda
web application to make this system easy to use. The web application provides alerts when
attacks happen and generate a log file for reporting all intrusions.This work can be extended by
improving performance of the presented system. One of the improving directions is based on
employing more machine learning techniques for developing IDS. It is interested to evaluate
performance of applying semi-supervised classification to the used dataset. We can also expand
the system by enabling detection of attacks that affect host devices such as viruses, Trojan,
malware, etc. Moreover, extracting additional features from the used dataset may improve the
performance.
Sl No: Title of the Paper Authors Technologies Used Publication Year Observations
1 Advanced Gunaprasad Python, OpenCV, Journal of 2019 It Detects Motion
Surveillance Ujhari,Bhavani SMTP Emerging And Capture Image
Systems Using M.Kiran Technolo-
OpenCV Kumar K. gies and
Innovative
Research
(JETIR)
2 Intrusion Detection JABEZ, Artificial Neural ScienceDirect 2011 It Presented The
System (IDS) Dr Muthu Networks - ANN Details Of a New
Anomaly Approach
Detection using
Outlier Detection
Approach
3 A Study of .Patrick Artificial Intelli- MDPI 2022 This Provide How
Network Intrusion Varin,Thomas gence/Machine The System Could
Detection Systems Newe,Labinot Learning Be Improved Using
Using Artificial In- Lumi ML
telligence/Machine Duhan,Eoin
Learning O’Connell,Donna
O’Shea,Brian
Lee,Muzaffar
Rao
4 Analysis of 1.Chaitali CNN Model, SSRN 2024 It Attempts To
Intrusion Detection T. Dhumal Artificial Neural Undergo Compre-
Systems: 2.Dr. B. V. Network, Machine hensive Review On
Techniques, Pingale Learning Algo- Existing IDS
Datasets and rithms
Research
Opportunity
5 Intrusion Detection 1.Mrinal Client-server ICCCA 2018 It Critically
System in Python Walia 2.Dr. systems, Computer Demonstrate
Tanupriya hacking, Computer Process To De-
3.Manik networks, Network velop A Basic IDS
Arora security, NIDS In Python
6 Journal of Network 1.Hung-Jen Machine learning, ELSEVIER 2022 Here Introduced
and Computer Liao Artificial intelli- An Overview
Applications 2.Chun- gence Of Detection
Hung Methodolo-
Richard Lin gies,Approaches
3.Ying-Chin And Technologies
Lin For IDSs.
4.Kuang-
Yuan Tung
SYSTEM DESIGN
Role: End-user who interacts with the Intrusion Detection System. Action: Sends a request to
access a resource (e.g., login, view reports, check camera feed). Waits for a response from the
system.
This is the main system that encapsulates all internal functions: Login authentication,monitoring
and alerting,data storage and report generation
Role: Provides backend services and data storage. Action: Receives requests forwarded by the
system (e.g., database queries, video feed access, file storage).Returns responses to the Intrusion
Detection System, such as:Authentication Success/Failure,intrusion history data,Video/image
data,acknowledgment of saved reports.
The Admin is the only user interacting with the system.The admin performs key actions:Logs
in by entering a username and password.Receives feedback about login success or failure.Gets
alerted in case of any intrusion detected.Views the intrusion history and detailed reports.Acts as
both the input provider and the decision-maker based on system alerts.
11
AN INTRUSION DETECTION SYSTEM 12
2. Process :Login
This is the first point of interaction in the system.It accepts the username and password entered
by the admin.Sends the entered data to the Login Database to verify the credentials.
After checking: If correct, the login process is successful and proceeds further. If incorrect,
sends back a Login Failure message to the admin. On successful login.
3. Data Store:
Admin credentials (username password).When the login request is received:It checks the cre-
dentials sent by the Login process.Returns an authentication response (success or failure).It
plays a vital role in maintaining access control to the system.
Activated after successful login.It continuously monitors the system for any unusual or unau-
thorized activity.If an intrusion is detected: It alerts the admin immediately.Simultaneously, it
sends the detected data to the Intrusion Report Database to save the intrusion event for future
review.
Stores records of all detected intrusions. It receives this data from the Monitoring Alert System.
The database allows storage, retrieval, and reporting of past intrusion events.This data is used
by the Detected Intrusion History process when the admin wants to view past incidents.
This component enables the admin to view the history of previously detected intrusions.It
fetches this information from the Intrusion Report Database.The data shown can include:timestamp
of intrusion, type or nature of the event,possibly image or video evidence
SYSTEM ARCHITECTURE
This IDS system is built around a frontend (user interface) for interaction with the admin and a
backend (server-side) to handle the processing, data management, and notifications.
Frontend:
The frontend consists of the User Interface (UI) that admins interact with to manage and monitor
the intrusion detection system.
• Login Module: Allows admins to log into the system. This would include a login form
with fields for username and password.
• Detected Intrusion History: Displays a list of previously detected intrusions, allowing the
admin to review historical data and any related alerts.
• Reports Viewer: Displays detailed reports on the intrusion incidents, such as time, type
of intrusion, and images of the incident captured.
User Flow:
The admin accesses the web application (using a browser or client app).
After login, the admin can view past reports, history, and real-time alerts of any intrusions.
The frontend sends requests to the backend to fetch data and display the status of the intrusion
system.
15
AN INTRUSION DETECTION SYSTEM 16
Backend:
The backend is responsible for processing, storing, and managing all the data, as well as han-
dling the intrusion detection logic.
• Authentication Service: Verifies the login credentials provided by the admin against the
Login Database.Issues a response (usually a token or session data) after successful au-
thentication, allowing access to the dashboard.
• Detected Intrusion History: Displays a list of previously detected intrusions, allowing the
admin to review historical data and any related alerts.
• Intrusion Detection Module: This module receives the camera feed data from the cam-
era(s), processes the video using machine learning or computer vision techniques (like
OpenCV for face detection), and checks for signs of intrusion.Once an intrusion is de-
tected, it triggers an alert, stores the data in the Intrusion Report Database, and sends a
notification to the admin.
• Database Services: Login Database: Stores login credentials and user-related data. In-
trusion Report Database: Stores detailed records of each detected intrusion, including
timestamps, descriptions, image snapshots, and any alerts associated with that intrusion.
• API Layer:The API layer serves as the communication bridge between the frontend (ad-
min UI) and the backend (Intrusion Detection Module, databases, etc.). It enables the
frontend to request data, submit credentials, or fetch reports.
Backend Flow:
When an admin logs in, the Authentication Service verifies the credentials with the Login
Database.
Upon successful login, the Admin Dashboard fetches data about the intrusions from the Intru-
sion Report Database via the API.
The Intrusion Detection Module constantly analyzes the camera feed to detect intrusions, stor-
ing any detected incidents in the Intrusion Report Database
DESIGN
Intrusion Detection System (IDS) – Module Explanation An Intrusion Detection System (IDS)
monitors and detects unauthorized access or anomalies in a secured environment. Below is a
breakdown of each module in the IDS architecture:
This is the front-end where administrators interact with the IDS. It provides the following func-
tionalities:
• Admin Login Module: Allows administrators to securely log into the system.
• Detected Intrusion History Module: Displays past intrusion records with timestamps and
images.
• Reports Viewer Module: Provides reports on intrusion incidents, including detailed logs
and captured snapshots.
• Interaction: The admin accesses the web application, views alerts, and manages reports.
2. Login Module:
Handles user authentication and verification. It ensures that only authorized personnel can
access the IDS dashboard.
• Credential Verification: Cross-checks login details with stored credentials in the database.
• Interaction: The system queries the Login Database for authentication and responds ac-
cordingly.
The core module responsible for detecting intrusions through real-time surveillance.
• Camera Feed Processing (Using OpenCV): Captures live video feeds and processes them
in real time.
19
AN INTRUSION DETECTION SYSTEM 20
• Face Detection Algorithm: Uses machine learning-based face detection to identify unau-
thorized individuals.
• Interaction: This module continuously analyzes camera feeds and stores intrusion inci-
dents in the database while notifying the admin.
4. Data Storage
• Interaction: The system retrieves login credentials from the Login Database and logs
intrusion events in the Intrusion Report Database.
• The login module authenticates the credentials against the login database.
• The intrusion detection module monitors the camera feed using OpenCV and face detec-
tion.
• If an intruder is detected, an alert is generated, and the incident is logged in the database.
REQUIREMENT ANALYSIS
The requirement analysis for the proposed Real-Time Intrusion Detection System (IDS) based
on face recognition involves identifying the functional and non-functional requirements neces-
sary to ensure secure, efficient, and reliable surveillance in restricted areas. This section outlines
both hardware and software requirements along with user and system-level needs.
Operating System
Compatibility with common operating systems, including Windows, Linux, and macOS.
python,HTML,CSS,JAVASCRIPT
Web Framework
Django : Backend web framework for building the admin dashboard, database management,
and user authentication. Django.
Database
SQLite (default with Django);Stores admin credentials, known faces metadata, and intrusion
event logs.
OpenCV:Used for real-time image processing, face detection from live video feeds.
Pillow: Used for image manipulation, such as saving captured face images.
22
AN INTRUSION DETECTION SYSTEM 23
The following hardware components are essential for building and deploying a real-time intru-
sion detection system using face recognition. These components ensure smooth data capture,
processing, storage, and communication of alerts.
METHODOLOGY
The proposed system follows a structured approach, integrating real-time face recognition with
alert mechanisms. Below is the step-by-step methodology of the project:
1. System Initialization:
The system boots up and initializes all necessary modules: camera, face recognition model, and
alerting services.The face database of authorized personnel is loaded into memory from storage.
A live video stream is captured using a connected camera.Each frame of the video is processed
in real-time.
3. Face Detection
OpenCV is used to detect faces within each video frame.If no face is detected, the system
continues monitoring.If a face is detected, the region of interest is extracted for further analysis.
A secure web interface allows the admin to:View live stream or captured images
All events are stored in a database with details such as: Date and time,image of the detected
person,recognition status.
6. Alert Generation
24
Chapter 8
IMPLEMENTATION
opencv.py
1 import cv2
2 import time
3 import os
4 from datetime import datetime
5 import sys
6 import django
7 from django.conf import settings
8
9 # Set up Django environment
10 os.environ.setdefault(’DJANGO_SETTINGS_MODULE’, ’new_project.settings
’)
11 django.setup()
12
13 # Import Django models after setting up Django
14 from app1.models import IntrusionEvent
15
16 # Django media directory setup
17 BASE_DIR = "c:/Users/JOEL/webapp"
18 MEDIA_DIR = os.path.join(BASE_DIR, "new_project/media")
19 VIDEO_DIR = os.path.join(MEDIA_DIR, "videos")
20 IMAGE_DIR = os.path.join(MEDIA_DIR, "images")
21
22 # Create required directories
23 os.makedirs(VIDEO_DIR, exist_ok=True)
24 os.makedirs(IMAGE_DIR, exist_ok=True)
25
26 # Load Haar Cascade for face detection
27 cascade_path = os.path.join(os.path.dirname(__file__), "
haarcascade_frontalface_default.xml")
28 face_cascade = cv2.CascadeClassifier(cascade_path)
29
30 if face_cascade.empty():
31 print("Error: Could not load face cascade classifier xml file")
32 exit()
33
34 # Start video capture
25
AN INTRUSION DETECTION SYSTEM 26
35 video = cv2.VideoCapture(0)
36
37 if not video.isOpened():
38 print("Error: Could not open video camera.")
39 exit()
40
41 frame_width = int(video.get(3))
42 frame_height = int(video.get(4))
43
44 # Generate filenames with correct paths
45 timestamp = datetime.now().strftime(’%Y-%m-%d_%H-%M-%S’)
46 video_path = os.path.join(VIDEO_DIR, f"intrusion_{timestamp}.mp4")
47 video_writer = cv2.VideoWriter(video_path, cv2.VideoWriter_fourcc(*’
avc1’), 10, (frame_width, frame_height))
48 last_capture_time = time.time()
49
50 # clear screen of previous messages
51 os.system(’cls’)
52
53 # add a new welcome message
54 message = """
55 ___ ____ ____
56 |_ _| _ \/ ___|
57 | || | | \___ \\
58 | || |_| |___) |
59 |___|____/|____/
60
61 press ctrl + c to save event and exit
62
63 """
64 print(message)
65
66
67 try:
68 while True:
69 check, frame = video.read()
70 if not check or frame is None:
71 print("Error: Could not read frame.")
72 break
73
74 current_time = datetime.now().strftime(’%Y-%m-%d %H:%M:%S’)
75 cv2.putText(frame, current_time, (10, 30), cv2.
FONT_HERSHEY_SIMPLEX,
76 1, (0, 255, 255), 2, cv2.LINE_AA)
77
78 gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
79 faces = face_cascade.detectMultiScale(gray, scaleFactor=1.2,
minNeighbors=12, minSize=(50, 50))
80
81 for x, y, w, h in faces:
82 cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 3)
83
84 if time.time() - last_capture_time >= 5:
85 image_path = os.path.join(IMAGE_DIR, f"face_detected_{
timestamp}.jpg")
86 cv2.imwrite(image_path, frame)
87 print(f"Image saved: {image_path}")
88 last_capture_time = time.time()
89
90 video_writer.write(frame)
91 cv2.imshow("Face Detection Video", frame)
92
93 if cv2.waitKey(1) == ord(’q’):
94 break
95
96 except KeyboardInterrupt: # save videos on exit
97 video.release()
98 video_writer.release()
99 cv2.destroyAllWindows()
100 event = IntrusionEvent(
101 video=f"./media/videos/intrusion_{timestamp}.mp4",
102 image=f"./media/images/face_detected_{timestamp}.jpg"
103 )
104 event.save()
105 print(f"Event saved in database with video: {video_path}")
login.html
<!DOCTYPE html >
<h t m l l a n g =” en”>
<head>
<meta c h a r s e t =”UTF−8”>
<meta name =” v i e w p o r t ” c o n t e n t =” w i d t h = d e v i c e − w i d t h , i n i t i a l − s c a l e =1.0” >
< t i t l e >L o g i n Page </ t i t l e >
<s t y l e >
body {
display : flex ;
justify −content : center ;
align −items : center ;
h e i g h t : 100 vh ;
b a c k g r o u n d : l i n e a r − g r a d i e n t ( t o r i g h t , #4 f a c f e , #00 f 2 f e ) ;
font − family : Arial , sans − s e r i f ;
margin : 0;
}
. login − container {
background : white ;
p a d d i n g : 2 rem ;
b o r d e r − r a d i u s : 12 px ;
box −shadow : 0 4 px 10 px r g b a ( 0 , 0 , 0 , 0 . 1 ) ;
text −align : center ;
w i d t h : 100%;
max− w i d t h : 350 px ;
}
h2 {
c o l o r : #333;
}
p {
c o l o r : #666;
margin − b o t t o m : 1 rem ;
}
input {
w i d t h : 100%;
p a d d i n g : 10 px ;
m a r g i n : 8 px 0 ;
b o r d e r : 1 px s o l i d # c c c ;
b o r d e r − r a d i u s : 8 px ;
f o n t − s i z e : 1 rem ;
}
. btn {
w i d t h : 100%;
p a d d i n g : 10 px ;
b a c k g r o u n d : #00 bcd4 ;
color : white ;
b o r d e r : none ;
b o r d e r − r a d i u s : 8 px ;
f o n t − s i z e : 1 rem ;
cursor : pointer ;
t r a n s i t i o n : 0.3 s ;
}
. btn : hover {
b a c k g r o u n d : #0097 a7 ;
}
. signup {
margin − t o p : 1 rem ;
f o n t − s i z e : 0 . 9 rem ;
}
. signup a {
c o l o r : #00 bcd4 ;
t e x t − d e c o r a t i o n : none ;
}
. signup a : hover {
text −decoration : underline ;
}
</ s t y l e >
</ head>
<body>
<d i v c l a s s =” l o g i n − c o n t a i n e r ”>
<h2>Welcome Back ! </ h2>
<p>S i g n i n t o c o n t i n u e </p>
<form>
< i n p u t t y p e =” e m a i l ” p l a c e h o l d e r =” E n t e r y o u r e m a i l ” r e q u i r e d >
< i n p u t t y p e =” p a s s w o r d ” p l a c e h o l d e r =” E n t e r y o u r p a s s w o r d ” r e q u i r e d >
<b u t t o n t y p e =” s u b m i t ” c l a s s =” b t n ”> S i g n In </ b u t t o n >
</ form>
<p c l a s s =” s i g n u p ”>Don ’ t h a v e an a c c o u n t ? <a h r e f =”#”> S i g n up </ a ></p>
</ d i v >
</ body>
</ html >
dashboard.html
1
2 {% load static %}
3 <!DOCTYPE html>
4 <html lang="en">
5 <head>
6 <meta charset="UTF-8">
7 <meta name="viewport" content="width=device-width, initial-scale
=1.0">
8 <title>Intrusion Detection Dashboard</title>
9 <style>
10 * {
11 margin: 0;
12 padding: 0;
13 box-sizing: border-box;
14 }
15
16 body {
17 font-family: Arial, sans-serif;
18 background: #f0f2f5;
19 padding: 20px;
20 }
21
22 .dashboard-container {
23 max-width: 1200px;
24 margin: 0 auto;
25 }
26
27 .header {
28 background: #fff;
29 padding: 20px;
30 border-radius: 8px;
31 margin-bottom: 20px;
32 box-shadow: 0 2px 4px rgba(0,0,0,0.1);
33 }
34
35 .header h1 {
36 color: #1a73e8;
37 margin-bottom: 10px;
38 }
39
40 .event-grid {
41 display: grid;
42 grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
43 gap: 20px;
44 }
45
46 .event-card {
47 background: #fff;
48 border-radius: 8px;
49 padding: 15px;
50 box-shadow: 0 2px 4px rgba(0,0,0,0.1);
51 }
52
53 .event-card h3 {
54 color: #333;
55 margin-bottom: 15px;
56 }
57
58 .event-card video {
59 width: 100%;
60 border-radius: 4px;
61 margin-bottom: 10px;
62 }
63
64 .event-card img {
65 width: 100%;
66 border-radius: 4px;
67 margin: 10px 0;
68 }
69
70 .event-details {
71 margin-top: 15px;
72 padding-top: 15px;
73 border-top: 1px solid #eee;
74 }
75
76 .event-details p {
77 color: #666;
78 margin: 5px 0;
79 font-size: 14px;
80 }
81
82 .timestamp {
83 color: #1a73e8;
84 font-weight: bold;
85 }
86 </style>
87 </head>
88 <body>
89 <div class="dashboard-container">
90 <div class="header">
91 <h1>Intrusion Detection System</h1>
manage.py
1 import os
2 import sys
3
4
5 def main():
6 """Run administrative tasks."""
7 os.environ.setdefault(’DJANGO_SETTINGS_MODULE’, ’new_project.
settings’)
8 try:
9 from django.core.management import execute_from_command_line
10 except ImportError as exc:
11 raise ImportError(
12 "Couldn’t import Django. Are you sure it’s installed and "
13 "available on your PYTHONPATH environment variable? Did you
"
14 "forget to activate a virtual environment?"
15 ) from exc
16 execute_from_command_line(sys.argv)
17
18
19 if __name__ == ’__main__’:
20 main()
view.py
1 from django.shortcuts import render, redirect
2 from django.contrib.auth import authenticate, login, logout
3 from django.contrib.auth.models import User
4 from .models import IntrusionEvent
5
6 def display(request):
7 if request.method == "POST":
8 email = request.POST["email"]
9 password = request.POST["password"]
10 username = email.split("@")[0] # extract user name from email
11 user = authenticate(request, username=username, email=email,
password=password)
12 if user is not None:
13 login(request, user)
14 return redirect("/dash")
15 else:
16 return render(request,’login.html’, {’error’: "invalid user
credentials"})
17 return render(request,’login.html’)
18
19 def signout(request):
20 logout(request)
21 return redirect("/")
22
23 def dashboard(request):
24 if request.user.is_authenticated: # check if user is logged in
25 if request.method == ’POST’ and ’clear_events’ in request.POST:
26 IntrusionEvent.objects.all().delete()
27 return redirect(’/dash’)
28 intrusion_events = IntrusionEvent.objects.values(’id’, ’
The terminal shown in the image is a Windows PowerShell terminal being used to run and
monitor a Django web server for an Intrusion Detection System (IDS) project.
The terminal is a Windows PowerShell interface that serves as a command-line environment for
executing and monitoring a Python-based Intrusion Detection System (IDS) project.
It displays logs for face detection events, image and video storage, and the running of a Django
development server.
It is also used to manage virtual environments, run scripts, and display real-time feedback on
system activity, helping the developer track and debug events during intrusion monitoring.
34
AN INTRUSION DETECTION SYSTEM 35
Figure 9.2: Login page interface for the Intrusion Detection System’s admin panel.
A login page is a user interface screen that allows registered users to access a secure system or
application by entering their credentials—typically an email (or username) and a password.
It acts as a gatekeeper, ensuring that only authenticated users can proceed to the protected parts
of the system.
Figure 9.3 illustrates the user interface of a real-time intrusion detection system dashboard for
surveillance monitoring.
The image depicts the user interface of a real-time intrusion detection system designed for
surveillance monitoring. The dashboard visually represents intrusion events detected by a cam-
era system using face detection technology.
The top section of the dashboard includes system controls such as Logout and Clear All Events
buttons, allowing the administrator to manage sessions and event history.
Each detection event is presented in a card format containing:
• A timestamp showing the exact time the event occurred.
• A video clip recording the activity during the intrusion.
• A snapshot frame from the video with face detection boxes (highlighted in green) indi-
cating detected human faces.
By integrating OpenCV-based face detection, a web-based admin interface, and automated no-
tification mechanisms, the system effectively detects and logs unauthorized access events.
Manage and review historical intrusion data through a centralized web dashboard.
Through the combination of computer vision, web technologies, and database management,
the system offers a scalable and user-friendly tool for surveillance, particularly in sensitive or
restricted areas.
CONCLUSION
The scope of the Intrusion Detection System (IDS) encompasses the monitoring and detection of
unauthorized access attempts in highly restricted areas. This includes the ability to identify and
alert administrators to suspicious or anomalous activity, such as the presence of an unauthorized
person within a specific time interval.
The system’s scope extends to the detection of unauthorized persons, triggering alerts and mes-
sages to administrators, accompanied by visual evidence in the form of snapshots. This enables
administrators to verify the identity of the intruder and take necessary action.
The IDS also provides a web-based platform for administrators to access reports and historical
data on previous intrusion attempts. This enables administrators to track patterns and trends
in unauthorized activity, facilitating informed decision-making and the development of more
effective security strategies.
The scope of the IDS includes the ability for administrators to login and access the system
remotely, ensuring timely response to security incidents. This enables administrators to respond
promptly to alerts and messages, minimizing the risk of security breaches.
Furthermore, the IDS scope encompasses the provision of a comprehensive security solution for
highly restricted areas. This includes the integration of advanced monitoring and detection ca-
pabilities, ensuring that unauthorized access attempts are identified and responded to promptly.
Overall, the scope of the IDS is to provide a robust and effective security solution for highly
restricted areas, leveraging advanced technologies to detect and respond to unauthorized access
attempts. By providing real-time alerts, visual evidence, and historical data, the system supports
proactive security measures, minimizes the risk of security breaches, and enhances overall se-
curity posture.
38
References
39