Skip to content

Commit a09d999

Browse files
Add files via upload
1 parent f137d94 commit a09d999

28 files changed

Lines changed: 1137 additions & 0 deletions
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"email": "your_email@outlook_or_gmail.com",
3+
"password": "Password for the email chosen goes here",
4+
"domain": "Either 'gmail' or 'outlook' depending on which email you chose, or else it will fail"
5+
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import smtplib
2+
from email.mime.text import MIMEText
3+
import json
4+
5+
6+
class Auto:
7+
def __init__(self, port=587):
8+
"""
9+
Initialize the EmailAutomator with SMTP server details and credentials.
10+
11+
:param port: The port number used by the SMTP server (e.g., 587).
12+
"""
13+
14+
def __read_email_credentials():
15+
"""
16+
Reads email and password from a JSON file.
17+
18+
:return: Dictionary with email and password.
19+
"""
20+
try:
21+
with open("Credentials.json", "r") as file:
22+
data = json.load(file)
23+
return {
24+
"email": data.get("email"),
25+
"password": data.get("password"),
26+
"domain": data.get("domain"),
27+
}
28+
except FileNotFoundError:
29+
print(f"The JSON file does not exist.")
30+
except json.JSONDecodeError:
31+
print(f"There was an error decoding the JSON file.")
32+
33+
credentials = __read_email_credentials()
34+
if not credentials:
35+
raise FileNotFoundError("Credentials.json does not exist.")
36+
elif len(credentials["email"]) == 0 or len(credentials["password"]) == 0:
37+
raise ValueError("Email and password are required.")
38+
if credentials["domain"] == "outlook":
39+
self.smtp_server = "smtp.office365.com"
40+
elif credentials["domain"] == "gmail":
41+
self.smtp_server = "smtp.gmail.com"
42+
else:
43+
raise ValueError(f"Invalid domain given: {credentials['domain']}")
44+
self.port = port
45+
self.username = credentials["email"]
46+
self.password = credentials["password"]
47+
48+
def send_email(self, recipient, subject, body):
49+
"""
50+
Send an email with the specified recipient, subject, and body.
51+
52+
:param recipient: The recipient's email address.
53+
:param subject: The subject of the email.
54+
:param body: The body of the email.
55+
"""
56+
# Create the email message
57+
msg = MIMEText(body)
58+
msg["Subject"] = subject
59+
msg["From"] = self.username
60+
msg["To"] = recipient
61+
62+
# Connect to the SMTP server
63+
server = smtplib.SMTP(self.smtp_server, self.port)
64+
server.starttls()
65+
server.login(self.username, self.password)
66+
67+
# Send the email
68+
text = msg.as_string()
69+
server.sendmail(self.username, recipient, text)
70+
server.quit()
71+
72+
73+
"""
74+
# This is a full example usage of the EmailAutomator class in another file
75+
# Specify the recipient, subject, and body of the email
76+
from EmailAutomator import Auto
77+
auto = Auto()
78+
recipient = 'Nirt_12023@outlook.com'
79+
subject = 'Test Email'
80+
body = 'This is a test email sent using automation.'
81+
auto.send_email(recipient, subject, body)
82+
"""

Arcade/Email_Automator/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# Email Automator
2+
3+
## Table of Contents
4+
5+
- [Introduction](#introduction)
6+
- [Installation](#installation)
7+
- [Usage](#usage)
8+
- [Configuration](#configuration)
9+
- [Troubleshooting and Support](#troubleshooting-and-support)
10+
- [Contributing](#contributing)
11+
12+
## Introduction
13+
14+
### Overview
15+
16+
This project is an email automation tool that allows users to automate the process of sending emails.
17+
18+
### Purpose
19+
20+
The primary aim of this project is to simplify the process of sending emails by automating the process.
21+
22+
## Installation
23+
24+
### Prerequisites
25+
26+
- Python 3.8 or higher
27+
- pip package manager
28+
29+
### Steps to install
30+
31+
1. Clone the repository.
32+
2. Navigate to the project directory.
33+
3. Run `pip install -r requirements.txt` to install the necessary dependencies.
34+
35+
## Usage
36+
37+
Import the `Auto` class from the `EmailAutomator` module and create an instance of the class.
38+
Call the `send_email` method with the recipient, subject, and body of the email.

Arcade/Face_detector/Face_Init.py

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
import os
2+
import cv2
3+
import dlib
4+
from imutils import face_utils
5+
import colorlog
6+
7+
# Configure colorlog for logging messages with colors
8+
logger = colorlog.getLogger()
9+
# Change to INFO if needed
10+
logger.setLevel(colorlog.DEBUG)
11+
12+
handler = colorlog.StreamHandler()
13+
formatter = colorlog.ColoredFormatter(
14+
"%(log_color)s%(levelname)-8s%(reset)s %(blue)s%(message)s",
15+
datefmt=None,
16+
reset=True,
17+
log_colors={
18+
"DEBUG": "cyan",
19+
"INFO": "green",
20+
"WARNING": "yellow",
21+
"ERROR": "red",
22+
"CRITICAL": "red",
23+
},
24+
)
25+
handler.setFormatter(formatter)
26+
logger.addHandler(handler)
27+
28+
# Load the detector and predictor
29+
detector = dlib.get_frontal_face_detector()
30+
predictor = dlib.shape_predictor("sp68fl.dat")
31+
32+
33+
def detect_and_draw_landmarks(image, loop):
34+
colorlog.debug(f"Starting loop {loop}...")
35+
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
36+
colorlog.debug("Converted image to grayscale")
37+
rects = detector(gray, 1)
38+
colorlog.debug(f"Detected {len(rects)} faces")
39+
40+
try:
41+
for i, rect in enumerate(rects):
42+
colorlog.debug(f"Processing face {i + 1}")
43+
shape = predictor(gray, rect)
44+
shape = face_utils.shape_to_np(shape)
45+
colorlog.debug("Extracted facial landmarks")
46+
47+
# Calculate the size of the face region as a proxy for certainty
48+
face_size = max(rect.width(), rect.height())
49+
colorlog.debug(f"Face size: {face_size}")
50+
51+
# Arbitrary threshold for high certainty
52+
if face_size > 300:
53+
# Green for high certainty
54+
color = (0, 255, 0)
55+
colorlog.debug("High certainty with plotting")
56+
# Arbitrary threshold for medium certainty
57+
elif 180 < face_size <= 300:
58+
# Yellow for medium certainty
59+
color = (0, 255, 255)
60+
colorlog.debug("Medium certainty with plotting")
61+
else:
62+
# Red for low certainty
63+
color = (0, 0, 255)
64+
colorlog.debug("Low certainty with plotting")
65+
66+
# Extract facial landmarks
67+
colorlog.debug("Extracting facial landmarks")
68+
left_eye = shape[36:42]
69+
right_eye = shape[42:48]
70+
nose = shape[30:36]
71+
mouth = shape[48:68]
72+
73+
# Draw dots on facial landmarks for display
74+
colorlog.debug("Plotting dots onto facial landmarks")
75+
for point in left_eye:
76+
cv2.circle(image, tuple(point), 2, color, -1)
77+
for point in right_eye:
78+
cv2.circle(image, tuple(point), 2, color, -1)
79+
for point in nose:
80+
cv2.circle(image, tuple(point), 2, color, -1)
81+
for point in mouth:
82+
cv2.circle(image, tuple(point), 2, color, -1)
83+
except Exception as err:
84+
colorlog.error(f"Error processing face: {err}")
85+
86+
colorlog.debug(f"Finished detection and plotting - LOOP {loop}")
87+
return image.copy()
88+
89+
90+
def capture():
91+
loop = 0
92+
colorlog.info("Starting video capture...")
93+
try:
94+
while True:
95+
loop += 1
96+
ret, frame = cap.read()
97+
if not ret:
98+
colorlog.error("Can't receive frame (stream end?). Exiting ...")
99+
break
100+
101+
# Create a copy of the frame for displaying with dots
102+
display_frame = detect_and_draw_landmarks(frame.copy(), loop)
103+
104+
# Display the frame with dots
105+
cv2.imshow("Face Detection", display_frame)
106+
107+
key = cv2.waitKey(1) & 0xFF
108+
colorlog.info("Press 'c' to save the image.")
109+
if key == ord("c"): # Press 'c' to continue/save the image
110+
files = os.listdir("known_faces")
111+
number = sum(
112+
[1 for f in files if os.path.isfile(os.path.join("known_faces", f))]
113+
)
114+
# Save the original frame without modifications
115+
cv2.imwrite(f"known_faces/face_{number}.jpg", frame)
116+
colorlog.info("Image saved.")
117+
118+
break
119+
120+
# Add debug print statements for easy debugging
121+
colorlog.info("Video capture completed.")
122+
colorlog.debug(f"Loop number: {loop}")
123+
colorlog.debug(f"Key pressed: {chr(key)}")
124+
except Exception as e:
125+
colorlog.error(f"An error occurred: {e}")
126+
127+
128+
# Initialize the camera
129+
try:
130+
if not os.path.exists("known_faces"):
131+
os.makedirs("known_faces")
132+
cap = cv2.VideoCapture(0)
133+
capture()
134+
cap.release()
135+
cv2.destroyAllWindows()
136+
colorlog.info("Program completed.")
137+
except Exception as e:
138+
colorlog.error(f"An error occurred: {e}")

0 commit comments

Comments
 (0)