Professional Documents
Culture Documents
INTRODUCTION
1.1 DOMAIN INTRODUCTION
Pattern analysis and Machine intelligence
Pattern analysis techniques began in the late 1960s and early 1970s used in
medical imaging and astronomy. An image is may defined as a two-dimensional
f(x,y), where x and y are co-ordinate, and amplitude of function f at any x and y
co-ordinates is intensity or gray scaled of image at that point i.e x and y. when x
and y of function f are all finite and discrete we say the image is a digital image.
The field of digital image processing refers to processing of digital images. Now
days, Detection of suspicious activity by video surveillances is very common. In
previous decade monitoring of video by humans those are sited in front of screen
of videos captured by either CCTV or any other cameras. Now we are going to
automate this type of monitoring the best techniques which is used by most cases
is image processing.
Pattern-of-life analysis is a method of surveillance specifically used for
documenting or understanding a subject's (or many subjects') habits. This
information can then be potentially used to predict future actions by the subject(s)
being observed. This form of observation can, and is, generally done without the
consent of the subject, with motives including but not limited to security, profit,
scientific research, regular censuses, and traffic analysis.
Unlike these specific areas of surveillance, pattern-of-life analysis is not
limited to one medium and can encompass anything in an individual's life from
their internet browsing habits, to a record of instances of choices made in order to
determine a statistical 'favorite'.
1
1.2 PROBLEM DEFINITION
Video surveillance has been an energetic study area in pattern analysis and
machine intelligence, due to its vital position in helping surveillance intelligence
and law enforcement agencies to battle alongside offense and crime actions. The
objective of a visual surveillance system is to identify irregular object behaviors
and to lift alarms when such behaviors are detected. After moving objects are
detected, it is necessary to categorize them into predefined categories, so that their
movements behaviors can be suitably interpret in the background of their
identities and their connections with the surface. Therefore, object categorization
is a very important part in a complete visual surveillance system.
CHAPTER 2
2
LITERATURE SURYEY
PAPER 1 : Smart Surveillance Based on Video Summarization
Authors : Sinnu Susan Thomas, Sumana Gupta and Venkatesh
K. Subramanian
Year : 2017
In recent years, video surveillance technology hasbecome ubiquitous in
very sphere of our life. But automated video surveillance generates huge
quantities of data, which ultimately does rely upon manual inspection at some
stage. The present work aims to address this ever increasing gap between the
volumes of actual data generated and the volume that can be reasonably inspected
manually.
It is laborious and time consuming to scrutinize the salient events from the
large video databases. We introduce smart surveillance by using video
summarization for various applications. Techniques like video summarization
epitomizes the vast content of a video in a succinct manner.
They gave an overview how to use an optimal summarization framework
for surveillance videos. In addition to reduce the search time we propose to
convert content based video retrieval problem into a content based image retrieval
problem.
In addition, to reduce the search time we perform content based video
retrieval using the summarized frame that is essentially converting a video
retrieval problem to a image retrieval one. They proposed a single query by image
based video retrieval that reduces the storage space and time complexity. The
experiments on various data sets show that it is a promising approach towards the
problem of monitoring huge data. This work can be extended with the multi
camera scenario and for 3-D videos.[1]
3
Nemtanu and Iulian Bădescu Department of Telematics and
Electronics for Transport, University Politehnica of Bucharest,
Romania
Year : 2017
It presents an architecture for a perimeter security system dedicated to
ritical transport infrastructures protection, such as the airport. To counteract
human errors and low capacity of the existing security systems to provide
redundancy at certain functional levels and high availability, an innovative
security system concept was designed, able to provide redundancy at analysis and
image processing level.
By joining the latest technologies available for CCTV, perimeter
protection, virtualization and networking, the security system that underpins the
conceptual architecture, detailed further, enhances the security of the site by using
adaptive algorithms for processing data.
Motion detection is the simplest out of the three operations related to
movement, namely: detection, estimation and segmentation. Its purpose is to
identify points of image or general image regions that have moved. In this context,
being a simple operation, it means that it can be implemented smoothly
in the proposed CCTV system applications of the innovative architecture
proposed in this scientific paper.
The principle of motion estimation is to determine the movement of a pixel,
or a block of pixels between two successive images of the sequence based on
minimizing its intensity variation, called DFD or "Displaced Frame Difference".
The proposed system is highly redundant providing hardware redundancy and
software redundancy at the analysis and video processing level[2]
5
Year : 2014
Recently introduced cost-effective depth sensors coupled with the real-time
skeleton estimation algorithm of Shotton have generated a renewed interest in
skeleton-based human action recognition. Most of the existing skeleton-based
approaches use either the joint locations or the joint angles to represent a human
skeleton. In this paper, we propose a new skeletal representation that explicitly
models the 3D geometric relationships between various body parts using rotations
and translations in 3D space.
Since 3D rigid body motions are members of the special Euclidean group
SE(3), the proposed skeletal representation lies in the Lie group SE(3)×. . .×SE(3),
which is a curved manifold. Using the proposed representation, human actions can
be modelled as curves in this Lie group. Since classification of curves in this Lie
group is not an easy task, we map the action curves from the Lie group to its Lie
algebra, which is a vector space. We then perform classification using a
combination of dynamic time warping, Fourier temporal pyramid representation
and linear SVM.
Experimental results on three action datasets show that the proposed
representation performs better than many existing skeletal representations. The
proposed approach also outperforms various state-of-the-art skeleton-based
human action recognition approaches. The relative geometry between all pairs of
body parts is implemented. But, each action is usually characterized by the
interactions of a specific set of body parts. Hence, we are planning to explore
various strategies to automatically identify the set of body parts that differentiates
a given action from the rest[4].
7
Recently released depth cameras provide effective estimation of 3D
positions of skeletal joints in temporal sequences of depth maps. In this work, we
propose an efficient yet effective method to recognize human actions based on the
positions of joints. First, the body skeleton is decomposed in a set of kinematic
chains, and the position of each joint is expressed in a locally defined reference
system which makes the coordinates invariant to body translations and rotations.
A multi-part bag-of-poses approach is then defined, which permits the
separate alignment of body parts through a nearest-neighbor classification.
Experiments conducted on the Florence 3D Action dataset and the MSR Daily
Activity dataset show promising results. This method has been evaluated on two
datasets: the Florence 3D Action Dataset and the Microsoft (MSR) Daily Activity
3D data set. Results scored by our approach on these datasets were also compared
against those obtained by state of the art solutions. This approach has been also
evaluated through a comparative analysis.
The first investigation aims to evidence accuracies obtained by using the
different variants of our solution. In particular, in the Table we indicate our base
solution with “NBNN”, its variants adding separately time and parts as,
respectively, “NBNN+ parts” and “NBNN+ time,” and the solution which
accounts for time and parts together as “NBNN+ parts+ time”. Results obtained
on both the Florence 3D and the DailyActivity3D datasets show that the “time”
feature is as relevant as the part based modeling in improving the performance of
the NBNN base approach; both cues combined together yield state of the art
results[6].
PAPER 7 : Surveillance Videos Suspicious Human Activity Detection from
Surveillance videos
10
background images, per-pixel adaptive thresholds and a region grouping
algorithm, named quasi-connected components (QCC). The tracking
algorithm determines the overlap
between detected regions in consecutive frames, in order to link them,
when no ambiguity exists.
The linking of an active region in consecutive frames originates a
stroke, which describes the evolution of the mass centre over time. The
classification task is performed each frame for all active regions detected,
and the classification of a stroke is performed by determining the most
voted class. To cope with tracking ambiguities, a colour-based recognition
module is also integrated in the system
The problem of remote surveillance has received growing attention in
recent years, especially in the context of public infrastructure monitoring for
transport applications, safety of quality control in industrial applications, and
improved public security. The development of a surveillance system requires
multidisciplinary expertise, including knowledge of signal and image processing,
computer vision, communications and networking pattern recognition and sensor
development and fusion[9].
The task of labeling videos containing human motion with action classes.
The interest in the topic is motivated by the promise of many applications, both
offline and online. Automatic annotation of video enables more efficient
11
searching, for example finding tackles in soccer matches, handshakes in news
footage or typical dance moves in music videos. Online processing allows for
automatic surveillance, for example in shopping malls, but also in smart homes
for the elderly to support aging in place. Interactive applications, for example in
human–computer interaction or games, also benefit from the advances in
automatic human action recognition.
Related is the issue of labeling data. For increasingly large and complex
datasets, manual labeling will become prohibitive. Automatic labeling using video
subtitles and movie scripts is possible in some domains, but still requires manual
verification. When using an incremental approach to image harvesting such as in,
the initial set will largely affect the final variety of action performances. We
discussed vision-based human action recognition in this survey but a multi-modal
approach could improve recognition in some domains, for example in movie
analysis. Also, context such as background, camera motion, interaction between
persons and person identity provides informative cues. Given the current state of
the art and motivated by the broad range of applications that can benefit from
robust human action recognition, it is expected that many of these challenges will
be addressed in the near future.
This would be a big step towards the fulfillment of the longstanding
promise to achieve robust automatic recognition and interpretation of human
action[10].
CHAPTER 3
SYSTEM ANALYSIS
The problem of detecting the face and recognizing them was studied by
many researchers working in the field of Computer vision and assistive
12
technologies for blind people. Most of the previous proposal uses image
processing to detect the presence of different faces in the camera frame and
perform image processing to match the detected faces against the face database to
recognize it.
The major limitations of some of the previously proposed approaches is
their capability on a low-portability computation device for the necessary image
processing which requires at least a computer with good amount of speed and yet
some others are lacking the universal design principle by limiting their training
data to a specific set and not able to add new datasets making it a static application
which could recognize only the existing faces.
These approaches also require the user to take a picture or make a video
recording at the faces and then process it to recognize them, although the picture
taken by user may not be able to capture the image with any device.
14
detect those activities classified in it.
Then, few videos are collected where persons are acted those selected
activities of interest. The video collected is limited at the rate of 5 frames per
second (fps) due to less memory. Other researchers suggested video with 1fps has
the advantage in effectively human movement due to errant movement of human
locomotion
Advanced Motion Detection (AMD) achieves complete detection of
moving objects. A camera is been connected inside the monitoring room which
produces alert messages on the account of any suspicious activity.
Technical Feasibility
15
expected needs of the proposed system. It is an evaluation of the hardware and
software and how it meets the need of the proposed system.
Operational Feasibility
Economic Feasibility
CHAPTER 4
SYSTEM DESIGN
16
Fig 4.1 Architecture Diagram
17
Fig 4.2 Use case Diagram
18
horizontal lines. The top compartment holds the class name and middle
compartment holds the attribute and bottom compartment holds list of operations.
20
in time sequence. Vertical dimension represent time and horizontal dimension
represent object.
CHAPTER 5
SYSTEM REQUIREMENTS
5.1 INTRODUCTION
21
5.2 HARDWARE REQUIREMENTS
The hardware requirements may serve as the basis for a contract for the
implementation of the system and should therefore be a complete and consistent
specification of the whole system. They are used by software engineers as the
starting point for the system design. It shows what the systems do and not how it
should be implemented.
CHAPTER 6
SYSTEM IMPLEMENTATION
6.1.1 JAVA
22
Java is a programming language originally developed by James Gosling at
Sun Microsystems and released in 1995 as a core component of Sun
Microsystems' Java platform. The language derives much of its syntax from C and
C++ but has a simpler object model and fewer low-level facilities. Java
applications are typically compiled to byte code that can run on any Java Virtual
Machine (JVM) regardless of computer architecture. Java is general-purpose,
concurrent, class-based, and object-oriented, and is specifically designed to have
as few implementation dependencies as possible. It is intended to let application
developers "write once, run anywhere".
Java is considered by many as one of the most influential programming
languages of the 20th century, and is widely used from application software to
web applications. The java framework is a new platform independent that
simplifies application development internet. Java technology's versatility,
efficiency, platform portability, and security make it the ideal technology for
network computing. From laptops to datacenters, game consoles to scientific
supercomputers, cell phones to the Internet, Java is everywhere!
23
The Java API is grouped into libraries of related classes and interfaces; these
libraries are known as packages. The following figure depicts a program that’s
running on the Java platform.
MySQL is a fast, easy-to-use RDBMS being used for many small and big
businesses. MySQL is developed, marketed, and supported by MySQL AB, which
is a Swedish company.
MySQL is offered fewer than two different editions: the open source
MySQL Community Server and the proprietary Enterprise Server. MySQL
Enterprise Server is differentiated by a series of proprietary extensions which
install as server plug-in, but otherwise shares the version numbering system and
is built from the same code base.
24
6.2 MODULES
1. Background modeling(BM)
2. Frame sequence
3. Object extraction (OE)
4. Action recognition
5. Constraints satisfaction
6. Human identification
7. Alarm trigger module (AT)
Input videos
Ignore
background
25
2. Frame Sequence
Background subtracted
video
Scene segmentation.
The frame extraction play the vital role in many video processing
applications like content based video retrieval, shot detection, segmentation, CC
cameras , etc the work search us concentrate on the CC Cameras which is kept in
the ON state for though out the day for recording purpose. Instead of keep it for
on state for more all the time we can place the sensor near the door and the sensor
will sense the human being who comes near the door for that movement cameras
will be on but this is not an efficient method compare to the video shot detection
techniques, here we are applying the video shot detection technique to the camera
which is associated to the indoor.
26
3. Object Extraction
Sequence.
frames
27
4.Action Recognition
Then, these objects of interest are used to model events. Finally, the events
are recognized. The abstraction stage determines which modeling techniques can
be applied.The output of the group tracker, which is having properties (such as
the intra-objects distance) and composed of detected physical objects at each
frame.
5. Constraints Satisfaction
28
The techniques used in constraint satisfaction depends on the kind of
constraints being considered to achieve the desired solution. Often used are
constraints on a finite domain, to the point that constraint satisfaction problems
are identified with problems based on constraints on a finite domain. Such
problems are usually solved via search, in particular a form of backtracking or
local search.
6. Human Identification
29
The face recognition problem can be divided into two main stages: face
verification (or authentication), and face identification (or recognition). The
detection stage is the first stage; it includes identifying and locating a face in an
image.
The recognition stage is the second stage; it includes feature extraction,
where important information for discrimination is saved, and the matching, where
the recognition result is given with the aid of a face database.
face recognition methods have been proposed. In the vast literature on the topic,
there are different classifications of the existing techniques. The following is one
possible high-level classification:
Holistic Methods: The whole face image is used as the raw input to the
recognition system. An example is the well-known PCA-based technique
introduced by Kirby and Sirovich, followed by Turk and Pentland.
Local Feature-based Methods: Local features are extracted, such as eyes, nose
and mouth. Their locations and local statistics (appearance) are the input to the
recognition stage. An example of this method is Elastic Bunch Graph Matching
(EBGM).
Although progress in face recognition has been encouraging, the task has
also turned out to be a difficult endeavor. In the following sections, we give a
brief review on technical advances and analyze technical challenges.
30
The Alarm Trigger is primarily the alert message that is given to the
authorized users based on the situation identified in the system.When the
suspicious activity of any human is identified in the monitoring area ,based on
certain circumstances, the system produces the alert messages.
The alert message for the particular actions will be sent to the authorized
user as the mail at the real- time. These alert messages can be sent on the basis of
representation of the organization authority at the system level
CHAPTER 7
31
SYSTEM TESTING
Type of Testing
Unconventional Testing
Conventional Testing
32
Conventional Testing is a process of finding the bugs and validating the
project. Testing team involves in this testing process and validating that
developed project is according to client requirement or not. This process is a
correction technique where testing team find bugs and reporting to the
development team for correction on developed project built.
Unit testing involves the design of test cases that validate that the internal
program logic is functioning properly, and that program input produce valid
outputs. All decision branches and internal code flow should be validated. It is
the testing of individual software units of the application .it is done after the
completion of an individual unit before integration. This is a structural testing,
that relies on knowledge of its construction and is invasive. Unit tests perform
basic tests at component level and test a specific business process, application,
and/or system configuration. Unit tests ensure that each unique path of a business
process performs accurately to the documented specifications and contains
clearly defined inputs and expected results.
7.2.2 Functional Testing
Functional tests provide systematic demonstrations that functions tested
are available as specified by the business and technical requirements, system
documentation, and user manuals. Functional testing is centered on the following
items:
Valid Input : identified classes of valid input must be accepted.
Invalid Input : identified classes of invalid input must be rejected.
Functions : identified functions must be exercised.
Output : identified classes of application outputs must be
exercised.
7.2.3 System Testing
33
System testing ensures that the entire integrated software system meets
requirements. It tests a configuration to ensure known and predictable results. An
example of system testing is the configuration oriented system integration test.
System testing is based on process descriptions and flows, emphasizing pre-
driven process links and integration points.
34
TC_ID Test Case Test Case Expected Actual Result Status
Description Result
TC-01 Register user Save the image of the It should allow It allows the user Pass
regular users and the user to to proceed
enter the valid user proceed
name
TC-02 Register user Take picture of any Error message Error message is Pass
other object than should display displayed as " No
human as "No Human Human Found "
Found"
TC-03 User Name Enter valid User It should allow It allows the user Pass
name ,it must contain the user to to proceed
only alphabets(A-Z & proceed
a-z)
TC-04 User Name Enter invalid User Error message Error message is Pass
name such as should display displayed as
alphabets with as "Please enter "Please enter valid
numbers & special valid User User name"
character name"
TC-05 Video Use the CCTV It should allow It allows the user Pass
coverage Camera for covering the user to to proceed
the area to be proceed
monitored
35
TC-08 Human Entry of unauthorized Alert message Alert message will Pass
Identification users will be sent to be sent to the
the authorized authorized user
user
TC-9 Email Enter valid email id It should allow It allows the user Pass
the user to to proceed
proceed
TC-10 Email Enter invalid email Error message Error message is Pass
id should display displayed as
as "Please enter "Please enter valid
valid email id" email id"
36
CHAPTER 8
RESULTS AND DISCUSSION
37
CHAPTER 9
CONCLUSION AND FUTURE ENHANCEMENT
9.1 CONCLUSION
38
A.SAMPLE CODE
EigenObjectRecognizer.cs
using System;
using System.Diagnostics;
using Emgu.CV.Structure;
namespace Emgu.cv
{
public class EigenObjectRecognizer
{
private Image<Gray, Single>[] _eigenImages;
private Image<Gray, Single> _avgImage;
private Matrix<float>[] _eigenValues;
private string[] _labels;
private double _eigenDistanceThreshold;
public Image<Gray, Single>[] EigenImages
{
get { return _eigenImages; }
set { _eigenImages = value; }
}
public String[] Labels
{
get { return _labels; }
set { _labels = value; }
}
public double EigenDistanceThreshold
{
get { return _eigenDistanceThreshold; }
set { _eigenDistanceThreshold = value; }
}
public Image<Gray, Single> AverageImage
{
get { return _avgImage; }
set { _avgImage = value; }
}
public Matrix<float>[] EigenValues
{
get { return _eigenValues; }
set { _eigenValues = value; }
}
public static void CalcEigenObjects(Image<Gray, Byte>[] trainingImages, ref
MCvTermCriteria termCrit, out Image<Gray, Single>[] eigenImages, out Image<Gray,
Single> avg)
{
int width = trainingImages[0].Width;
int height = trainingImages[0].Height;
IntPtr[] inObjs = Array.ConvertAll<Image<Gray, Byte>, IntPtr>(trainingImages,
delegate(Image<Gray, Byte> img) { return img.Ptr; });
if (termCrit.max_iter <= 0 || termCrit.max_iter > trainingImages.Length)
termCrit.max_iter = trainingImages.Length;
39
int maxEigenObjs = termCrit.max_iter;
eigenImages = new Image<Gray, float>[maxEigenObjs];
for (int i = 0; i < eigenImages.Length; i++)
eigenImages[i] = new Image<Gray, float>(width, height);
IntPtr[] eigObjs = Array.ConvertAll<Image<Gray, Single>, IntPtr>(eigenImages,
delegate(Image<Gray, Single> img) { return img.Ptr; });
avg = new Image<Gray, Single>(width, height);
CvInvoke.cvCalcEigenObjects(
inObjs,
ref termCrit,
eigObjs,
null,
avg.Ptr);
}
public static float[] EigenDecomposite(Image<Gray, Byte> src, Image<Gray, Single>[]
eigenImages, Image<Gray, Single> avg)
{
return CvInvoke.cvEigenDecomposite(
src.Ptr,
Array.ConvertAll<Image<Gray, Single>, IntPtr>(eigenImages,
delegate(Image<Gray, Single> img) { return img.Ptr; }),
avg.Ptr);
}
public Image<Gray, Byte> EigenProjection(float[] eigenValue)
{
Image<Gray, Byte> res = new Image<Gray, byte>(_avgImage.Width,
_avgImage.Height);
CvInvoke.cvEigenProjection(
Array.ConvertAll<Image<Gray, Single>, IntPtr>(_eigenImages,
delegate(Image<Gray, Single> img) { return img.Ptr; }),
eigenValue,
_avgImage.Ptr,
res.Ptr);
return res;
}
public float[] GetEigenDistances(Image<Gray, Byte> image)
{
using (Matrix<float> eigenValue = new Matrix<float>(EigenDecomposite(image,
_eigenImages, _avgImage)))
return Array.ConvertAll<Matrix<float>, float>(_eigenValues,
delegate(Matrix<float> eigenValueI)
{
return (float)CvInvoke.cvNorm(eigenValue.Ptr, eigenValueI.Ptr,
Emgu.CV.CvEnum.NORM_TYPE.CV_L2, IntPtr.Zero);
});
}
public void FindMostSimilarObject(Image<Gray, Byte> image, out int index, out float
eigenDistance, out String label)
{
float[] dist = GetEigenDistances(image);
40
index = 0;
eigenDistance = dist[0];
for (int i = 1; i < dist.Length; i++)
{
if (dist[i] < eigenDistance)
{
index = i;
eigenDistance = dist[i];
}
}
label = Labels[index];
}
public String Recognize(Image<Gray, Byte> image)
{
int index;
float eigenDistance;
String label;
FindMostSimilarObject(image, out index, out eigenDistance, out label);
return (_eigenDistanceThreshold <= 0 || eigenDistance < _eigenDistanceThreshold ) ?
_labels[index] : String.Empty;
}
}
}
MainForm.cs
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Emgu.CV;
using Emgu.CV.Structure;
using Emgu.CV.CvEnum;
using System.IO;
using System.Diagnostics;
namespace MultiFaceRec
{
public partial class FrmPrincipal : Form
{
Image<Bgr, Byte> currentFrame;
Capture grabber;
HaarCascade face;
HaarCascade eye;
MCvFont font = new MCvFont(FONT.CV_FONT_HERSHEY_TRIPLEX, 0.5d, 0.5d);
Image<Gray, byte> result, TrainedFace = null;
Image<Gray, byte> gray = null;
List<Image<Gray, byte>> trainingImages = new List<Image<Gray, byte>>();
List<string> labels= new List<string>();
List<string> NamePersons = new List<string>();
int ContTrain, NumLabels, t;
string name, names = null;
41
public FrmPrincipal()
{
InitializeComponent();
face = new HaarCascade("haarcascade_frontalface_default.xml");
try
{
string Labelsinfo = File.ReadAllText(Application.StartupPath +
"/TrainedFaces/TrainedLabels.txt");
string[] Labels = Labelsinfo.Split('%');
NumLabels = Convert.ToInt16(Labels[0]);
ContTrain = NumLabels;
string LoadFaces;
for (int tf = 1; tf < NumLabels+1; tf++)
{
LoadFaces = "face" + tf + ".bmp";
trainingImages.Add(new Image<Gray, byte>(Application.StartupPath +
"/TrainedFaces/" + LoadFaces));
labels.Add(Labels[tf]);
}
}
catch(Exception e)
{
MessageBox.Show("Nothing in binary database, please add at least a face(Simply
train the prototype with the Add Face Button).", "Triained faces load",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
private void button1_Click(object sender, EventArgs e)
{
grabber = new Capture();
grabber.QueryFrame();
Application.Idle += new EventHandler(FrameGrabber);
button1.Enabled = false;
}
private void button2_Click(object sender, System.EventArgs e)
{
try
{
ContTrain = ContTrain + 1;
gray = grabber.QueryGrayFrame().Resize(320, 240,
Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
MCvAvgComp[][] facesDetected = gray.DetectHaarCascade(
face,
1.2,
10,
mgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
new Size(20, 20));
foreach (MCvAvgComp f in facesDetected[0])
{
TrainedFace = currentFrame.Copy(f.rect).Convert<Gray, byte>();
42
break;
}
TrainedFace = result.Resize(100, 100,
Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
trainingImages.Add(TrainedFace);
labels.Add(textBox1.Text);
imageBox1.Image = TrainedFace;
File.WriteAllText(Application.StartupPath + "/TrainedFaces/TrainedLabels.txt",
trainingImages.ToArray().Length.ToString() + "%");
for (int i = 1; i < trainingImages.ToArray().Length + 1; i++)
{
trainingImages.ToArray()[i - 1].Save(Application.StartupPath +
"/TrainedFaces/face" + i + ".bmp");
File.AppendAllText(Application.StartupPath +
"/TrainedFaces/TrainedLabels.txt", labels.ToArray()[i - 1] + "%");
}
MessageBox.Show(textBox1.Text + "´s face detected and added :)", "Training
OK", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch
{
MessageBox.Show("Enable the face detection first", "Training Fail",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
} void FrameGrabber(object sender, EventArgs e)
{
label3.Text = "0";
NamePersons.Add("");
currentFrame = grabber.QueryFrame().Resize(320, 240,
Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
gray = currentFrame.Convert<Gray, Byte>();
MCvAvgComp[][] facesDetected = gray.DetectHaarCascade(
face,
1.2,
10,
Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
new Size(20, 20));
foreach (MCvAvgComp f in facesDetected[0])
{
t = t + 1;
result = currentFrame.Copy(f.rect).Convert<Gray, byte>().Resize(100, 100,
Emgu.CV.CvEnum.INTER.CV_INTER_CUBIC);
currentFrame.Draw(f.rect, new Bgr(Color.Red), 2);
if (trainingImages.ToArray().Length != 0)
{
MCvTermCriteria termCrit = new MCvTermCriteria(ContTrain, 0.001);
EigenObjectRecognizer recognizer = new EigenObjectRecognizer(
trainingImages.ToArray(),
labels.ToArray(),
3000,
43
ref termCrit);
name = recognizer.Recognize(result);
currentFrame.Draw(name, ref font, new Point(f.rect.X - 2, f.rect.Y - 2), new
Bgr(Color.LightGreen));
}
NamePersons[t-1] = name;
NamePersons.Add("");
label3.Text = facesDetected[0].Length.ToString();
gray.ROI = f.rect;
MCvAvgComp[][] eyesDetected = gray.DetectHaarCascade(
eye,
1.1,
10,
Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
new Size(20, 20));
gray.ROI = Rectangle.Empty;
foreach (MCvAvgComp ey in eyesDetected[0])
{
Rectangle eyeRect = ey.rect;
eyeRect.Offset(f.rect.X, f.rect.Y);
currentFrame.Draw(eyeRect, new Bgr(Color.Blue), 2);
}
}
t = 0;
for (int nnn = 0; nnn < facesDetected[0].Length; nnn++)
{
names = names + NamePersons[nnn] + ", ";
}
imageBoxFrameGrabber.Image = currentFrame;
label4.Text = names;
names = "";
NamePersons.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
Process.Start("Donate.html");
}
}
}
MainForm.Designer.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
namespace MultiFaceRec
{
static class Program
{
44
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmPrincipal());
}
}
}
package face_recog;
/**
*
* @author java
*/
import java.awt.AlphaComposite;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;
import org.bytedeco.javacpp.opencv_core.IplImage;
import static org.bytedeco.javacpp.opencv_core.IplImage;
import static org.bytedeco.javacpp.opencv_core.cvFlip;
import static org.bytedeco.javacpp.opencv_imgcodecs.cvSaveImage;
import static org.bytedeco.javacpp.opencv_imgcodecs.cvSaveImage;
import static org.bytedeco.javacpp.opencv_imgcodecs.cvSaveImage;
import static org.bytedeco.javacpp.opencv_imgcodecs.cvSaveImage;
import static org.bytedeco.javacpp.opencv_imgcodecs.cvSaveImage;
import static org.bytedeco.javacpp.opencv_imgcodecs.cvSaveImage;
import static org.bytedeco.javacpp.opencv_imgcodecs.cvSaveImage;
import static org.bytedeco.javacpp.opencv_imgcodecs.cvSaveImage;
import static org.bytedeco.javacpp.opencv_imgcodecs.cvSaveImage;
import static org.bytedeco.javacpp.opencv_imgcodecs.cvSaveImage;
import org.bytedeco.javacv.*;
import persistence.DatabaseConnection;
45
/**
* Created by gtiwari on 1/3/2017.
*/
img = converter.convert(frame);
//save
cvSaveImage((i++) + "aa.jpg", img);
//imgcom q=new imgcom();
// float
d=q.com("C:\\Users\\java\\Documents\\NetBeansProjects\\try\\0aa.jpg","E:\\sample\\2.jpg");
// if(d<=20){
// System.out.println("aaaaaaaaaaaaaaaaaaaa");
// }
canvas.showImage(converter.convert(img));
Main m=new Main();
// }
// No.2
// In case the buffered image supports transparency
/* g2d = bimage.createGraphics();
46
// Transparency is created on all the filled pixels
Color transparent = new Color(0, 0, 0, 0);
g2d.setColor(transparent);
g2d.setComposite(AlphaComposite.Src);
g2d.fill(new Rectangle2D.Float(20, 20, 100, 20));
g2d.dispose();*/
canvas.showImage(converter.convert(img));
m.main("D:\\Face_Recog\\"+h+"aa.jpg");
Thread.sleep(INTERVAL);
if(h>1){
FaceDetector1 f=new FaceDetector1();
boolean val= f.image("D:\\Face_Recog\\"+h+"aa.jpg");
if(val==true){
imgcom q=new imgcom();
File f1=new File("D://trained");
int j1=numberOfFiles(f1);
int cnt=0;
for(int j=1;j<=j1;j++){
if(cnt==0){
float d=q.com("file:///D:\\trained\\"+j+".jpg","file:///D:\\buff\\1.jpg");
System.out.println(d);
if(d<=6){
/* if(j==1){
JOptionPane.showMessageDialog(null, "Divya");
}*/
/* cnt++;
strQuery="UPDATE regst SET chck='1' WHERE img='"+j+"'";
System.out.println(strQuery);
st = DatabaseConnection.getConnection().createStatement();
st.executeUpdate(strQuery);
comport c=new comport();
c.main();*/
}else{
// Test t=new Test();
// t.read("unknown");
email e=new email();
e.Send("foreview.java", "foreview334", "divya17.1179@gmail.com", "alert",
"unknown user");
}
}
}
}
}
47
h++;
kk++;
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static int countFilesInDirectory(File directory) {
int count = 0;
for (File file : directory.listFiles()) {
if (file.isFile()) {
count++;
}
if (file.isDirectory()) {
count += countFilesInDirectory(file);
}
}
return count;
}
48
BufferedImage image=new BufferedImage(canvas.getWidth(),
canvas.getHeight(),BufferedImage.TYPE_INT_RGB);
Graphics2D g2=(Graphics2D)image.getGraphics();
canvas.paint(g2);
try {
ImageIO.write(image, "png", new File("D://canvas.png"));
} catch (Exception e) {
}
}
}
REFERENCES
49
[1] “Smart Surveillance Based on Video Summarization”, Sinnu Susan
Bucharest, Romania,2017.
[3] “Super Normal Vector for Human Activity Recognition with Depth
Member, IEEE
Vinaayagan
Data, 2013.
50
[7] “Surveillance Videos Suspicious Human Activity Detection from
Chennai, Tamilnadu,2012.
[11] https://www.sciencedirect.com/science/article/pii/S1665642314716323
[12] https://ieeexplore.ieee.org/document/7732378/?reload=true
[13] https://www.videosurveillance.com/apps/
[14] https://www.biorxiv.org/content/early/2017/07/18/165266
[15] https://www.springer.com/in/book/9780792379744
51