story
story

Developed Laser-Based Security System: Capturing Images of Intruders and Sending Email Alerts

Developed Laser-Based Security System: Capturing Images of Intruders and Sending Email Alerts

Developed Laser-Based Security System: Capturing Images of Intruders and Sending Email Alerts

At the age of 15, I created a security device designed to protect areas using laser technology. I presented this project at the student project exhibition in Tetouan, held at Sidi Talha Middle School. When the laser beam is interrupted, the system activates a camera to capture images of the area, specifically focusing on identifying faces. Simultaneously, an alarm is triggered on the computer, and an email notification is sent to my email address. This is achieved by integrating various programming techniques with Python and the Arduino microcontroller.

Using the cvzone library in Python and the C programming language, the Arduino is connected to Python. A simple C program sends signals to the Python script running on the computer or Raspberry Pi. Then, the smtplib library in Python sends an email alert with the captured images. Additionally, the OpenCV technology processes the images to identify the intruder's face, and an alert is displayed on the computer.

This combination of technologies results in a high-level security system capable of providing real-time alerts and visual evidence of any unauthorized access attempts.

information about the project :

python code :
					
#made by oussama taliuan

from cvzone.SerialModule import SerialObject
import cv2
import smtplib

#xml face
faceXML=cv2.CascadeClassifier("resources/haarcascade_frontalface_default.xml")

#define arduino
arduino = SerialObject("COM3")

#define
i=0
ii=0

#images
img=cv2.imread("images/warning.jpg") #warning image
imgResize = cv2.resize(img,(500,500))

#vedio capture
cap = cv2.VideoCapture(0)
cap.set(3,640)
cap.set(4,480)
cap.set(10,100)

#email
server = smtplib.SMTP("smtp.gmail.com",587)
server.starttls()
server.login('mysucirity@gmail.com' , 'mypasword')

arduino.sendData([0, 1, 0])  # led blue
while True:
    # data
    data =arduino.getData()

    print(data[0])

    x=int(1019)

    if (int(data[0]) <= x ):

        arduino.sendData([1,0,1]) # led red & buzzer
        # send email
        server.sendmail('mysucirity@gmail.com', 'myemail@gmail.com',
                        'warning warningwarning warning warning warning warning warning warning warning warning warning warning warning warning il y a danger ')
        print("send")

        # img show
        cv2.imshow("warning",img)
        cv2.waitKey(0)


        while True:
            #cap run
           success, imgC = cap.read()

# cap img to gray
           capGray = cv2.cvtColor(imgC, cv2.COLOR_BGR2GRAY)

# face
           faces = faceXML.detectMultiScale(capGray, 1.1, 4)

# rectangle detection
           for (x, y, w, h) in faces:
               cv2.rectangle(imgC, (x, y), (x + w, y + h), (255, 0, 0), 2)

               cv2.imwrite('opencv'+ '.png', imgC)


             # video stop
           cv2.imshow("video", imgC)
           if cv2.waitKey(1) & 0xFF == ord("q"):
               break

    else:
        arduino.sendData([0,1,0]) # led blue



					
					

arduino code :
					
// made by oussama taliuan

 #include < cvzone.h >

SerialData serialData(3,1);

int sendVals[2];
int valsRec[3];

int son=13;
int ledB= 12;
int ledR = 8;

void setup() {
serialData.begin(9600);
pinMode(son,OUTPUT);
pinMode(ledR,OUTPUT);
pinMode(ledB,OUTPUT);
}

void loop() {
  int potVal = analogRead(A0);
  sendVals[0] = potVal;
  serialData.Send(sendVals);
  serialData.Get(valsRec);
  digitalWrite(son,valsRec[0]);
  digitalWrite(ledB,valsRec[1]);
  digitalWrite(ledR,valsRec[2]);
}