GuardMyPi
Protecting your berries from unauthorised tampering!
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Unlock Class Reference

Contains various methods to unlock the system. More...

#include <guardmypi.h>

Public Member Functions

int loadcascade ()
 Loads the hand and face cascades used to unlock the system during daytime hours (7am-8pm) More...
 
int face (Mat ReferenceFrame, clock_t startTime)
 This method takes the input frame from the camera if the time is between 8am and 9pm. More...
 
int QRUnlock (Mat frame, clock_t startTime)
 This method is the alternative unlocking method once it is night time. More...
 
int QRLock (Mat frame)
 This method looks for another QR code whilst the system is in its unlocked state. More...
 
int Deactivate (Mat frame)
 This method searches for the user to reset the system when it's detected an intruder. More...
 

Public Attributes

int faceflag = 0
 Flag set by facial recognition.
 
int intruderflag = 0
 Intruder flag set by motion detector & face recognition.
 
int lockflag = 0
 Lock flag set by QR Lock method.
 
int QRunlockflag = 0
 Flag set by the QR Unlock method.
 
int resetflag = 0
 Reset flag set when intruder flag is high and by QR Unlock method.
 
int ID = -1
 Initial LBPH ID.
 
double secondsPassed = 0.0
 Number of seconds passed since the current timestamp.
 

Protected Attributes

Mat gray
 
Mat thresh
 
Mat new_avg
 
Mat diff
 
Mat GrayFrame
 Various members to contain a grayscale, threshold, running average and difference frame.
 
CascadeClassifier hand_cascade
 Instance of the HAAR cascade object.
 
Scalar color = Scalar(255, 0, 0)
 
CascadeClassifier face_cascade
 Instance of the HAAR classifier for facial detection.
 
Ptr< LBPHFaceRecognizer > recogniser = LBPHFaceRecognizer::create(1,8,8,8,123)
 Instance of LBPH algorithm.
 
double confidence = 0.0
 Confidence level is altered by the LBPH algorithm of the chances it is the correct face.
 
string name
 Name of the recognised resident.
 
QRCodeDetector qrDecoder
 Instance of the QR Code detection object.
 
Mat bbox
 
Mat rectifiedImage
 Holds the rectified QR Code and position of the QR Code.
 

Detailed Description

Contains various methods to unlock the system.

Facial recognition utiises a LBPH algorithm to preict a detected face. QR detection is also implemented using the QRCodeDetector object.

Member Function Documentation

◆ Deactivate()

int Unlock::Deactivate ( Mat  frame)

This method searches for the user to reset the system when it's detected an intruder.

By essentially setting the intruder flag to 0 and all unlock method flags to high the system enters it's disarmed state

Parameters
frameInput frame from the camera feed
Returns
1 to escape function once QR code is detected
0 to escape function if the incorrect/no QR code is detected

◆ face()

int Unlock::face ( Mat  ReferenceFrame,
clock_t  startTime 
)

This method takes the input frame from the camera if the time is between 8am and 9pm.

It additionally takes the time stamp called immediately before the function. The method looks for a particularly trained face depending on the trained algorithm (*.yml file), which if not detected in less than 10s return 0 and set the intruder flag high alerting the user.

See also
Unlock::loadcascade()
Parameters
ReferenceFrameInput frame from the video frame capture
startTimeTime stamp initially called prior to the methd
Returns
camerafeed with or without "Motion Detected" text to signify code functioning

◆ loadcascade()

int Unlock::loadcascade ( )

Loads the hand and face cascades used to unlock the system during daytime hours (7am-8pm)

See also
Unlock::face

◆ QRLock()

int Unlock::QRLock ( Mat  frame)

This method looks for another QR code whilst the system is in its unlocked state.

Until the camera detects a QR code with a key called "lock" then nothing happens.

Parameters
frameInput frame from the camera feed
startTimeTime stamp initially called prior to the methd
Returns
1 to escape function once QR code is detected
0 to escape function if the incorrect/no QR code is detected

Condition looking for a QR Code

◆ QRUnlock()

int Unlock::QRUnlock ( Mat  frame,
clock_t  startTime 
)

This method is the alternative unlocking method once it is night time.

See also
Unlock::loadcascade() Unlock::face()
Parameters
frameInput frame from the video frame capture
startTimeTime stamp initially called prior to the methd
Returns
1 to escape function once QR code is detected
0 to escape function if the incorrect/no QR code is detected