← All projects
Personal project

Dorm Security

A dorm room security system I built with computer vision, live video, and web plus iOS apps for remote monitoring and control.

Last updated October 2026

Overview

I wanted to monitor my dorm room while I was away and receive alerts about activity. I built a camera and sensor system with computer vision, a backend, and web and iOS clients for remote video and control. It supports motion detection, face recognition, and audio monitoring.

What it is

Cameras monitor the room for movement and can recognize faces, while sensors track audio levels. When activity is detected, the system sends an alert and makes a live camera feed available.

The web and iOS apps let me check the room remotely and control the system. The project connects cameras, sensors, backend services, and clients into one setup for a real dorm room.

Why I built it

I wanted hands-on experience with computer vision and streaming, not just read about them. A dorm room is a constrained, real environment with actual lighting, noise, and false-alarm problems that tutorials skip.

The project also let me practice building for multiple platforms from one backend—the same pattern I used in other full-stack work.

Computer vision and backend

The backend handles video processing, motion detection, face recognition, and sound monitoring. Getting OpenCV pipelines to run reliably—tuning sensitivity, handling bad frames, managing camera input—took iteration.

All of this is exposed through a REST API so clients can request streams, receive events, and trigger actions without caring how the vision pipeline works internally.

Room camera and microphone flows through local vision and audio detection to logs, email alerts, and Flask-powered web and iOS monitoring.
Take a closer look
Camera frames feed separate paths for local motion and face detection and the MJPEG live view. Microphone levels feed a threshold monitor; detections write logs and can trigger email alerts. Flask routes connect the web and iOS clients to stream and control features.

Monitoring from anywhere

The point of a security system is knowing what is happening when you are not there. I built web and iOS clients that connect to the backend for live video and remote control.

Latency, connection drops, and making the UI feel responsive over a stream were their own set of problems separate from the vision work.

Lessons learned

The biggest lesson was the gap between computer vision in a controlled setting and computer vision in a real room. Tutorials use clean footage and well-lit subjects; a dorm room has variable lighting, shadows, reflections, and movement patterns that trigger false positives constantly. Tuning the system for real conditions required more iteration than the initial implementation.

I also learned that streaming and real-time monitoring are their own engineering domain. Low-latency video delivery, handling connection drops gracefully, and keeping a mobile UI responsive over an unstable network are problems that sit outside traditional backend or frontend work. This project made me appreciate why media engineering is a specialization.

Highlights

  • Built an end-to-end security platform connecting camera input, computer vision processing, backend services, and client applications
  • Implemented motion detection, face recognition, and audio monitoring pipelines using OpenCV and Python
  • Designed a REST API abstracting hardware and vision logic so 2 client platforms (web and iOS) integrate through a stable interface
  • Delivered live video streaming and remote control accessible from both web and native iOS clients
  • Worked through real-world CV challenges—false positives, lighting variation, and latency—that textbook examples rarely cover

Code

Face Recognition Pipeline — Training to Real-Time Detection

python
def augment_image(image):
    """Generate 40+ variants per training image to handle
    variable lighting, angles, and sensor noise."""
    augmented = [image]

    # ±25° rotations, mirror flip
    for angle in range(-25, 26, 5):
        augmented.append(rotate(image, angle=angle,
                                 reshape=False))
    augmented.append(np.fliplr(image))

    # Gamma shifts for lighting variation
    for gamma in [0.5, 0.7, 0.85, 1.15, 1.3, 1.5]:
        augmented.append(
            exposure.adjust_gamma(image, gamma))

    # Perspective warp + sensor noise
    h, w = image.shape[:2]
    src = np.float32([[0,0],[w,0],[w,h],[0,h]])
    dst = np.float32([[0,0],[w,0],[w-50,h],[50,h]])
    M = cv2.getPerspectiveTransform(src, dst)
    augmented.append(cv2.warpPerspective(image, M, (w,h)))
    augmented.append(util.random_noise(
        image, mode='gaussian', var=0.01))
    augmented.append(util.random_noise(
        image, mode='s&p', amount=0.01))
    return augmented


# Train KNN on HOG features from 40× augmented faces
model = FacialRecognitionModel()
threading.Thread(target=model.train_model,
                 daemon=True).start()


def on_detection(frame, detected_faces):
    """Called every frame: recognize faces, throttle
    notifications with per-detection cooldowns."""
    global last_motion, last_email, last_face

    if detected_faces:
        names = [name for _, name in detected_faces]

        if time.time() >= last_face + COOLDOWN:
            last_motion = time.time()
            logging.info(f"Faces: {', '.join(names)}")

        # Email only for unknown faces, with its own
        # separate cooldown to avoid spam
        if time.time() >= last_email + EMAIL_COOLDOWN:
            known = {"Alice", "Bob"}
            if not set(names).issubset(known):
                os.system(
                    'python3 SendEmailNotification.py')
                last_email = time.time()
                logging.info("Alert email sent")
    else:
        if time.time() >= last_motion + COOLDOWN:
            last_motion = time.time()
            logging.info("Motion detected — no faces")

A real-world facial recognition pipeline that trains on a small personal photo set by generating 40+ augmented variants per image — rotations, gamma shifts, perspective warps, mirror flips, and sensor noise — to simulate the variable lighting and angles of a dorm room. HOG feature vectors feed a KNN classifier that runs locally in a background thread. During live detection, the cooldown system prevents notification spam: motion logging throttles to one entry per interval, while email alerts for unknown faces use a separate, longer cooldown so the system doesn't flood your inbox.

Skills & Technologies

PythonFlaskSwiftSwiftUIOpenCVComputer Visionscikit-learnYOLOFace RecognitionNumPyREST APIsHTMLCSSJavaScriptWeb DashboardiOS Development

Glossary

Computer Vision
Techniques that help software identify and interpret information in images or video.
Face Recognition
Matching a face in an image to a known person using visual features.
Flask
A lightweight Python framework for building web applications and APIs.
OpenCV
A library for processing images and video, often used in computer vision.
SwiftUI
Apple’s framework for describing and building app interfaces in Swift.
YOLO
You Only Look Once: a family of models that locate and identify objects in images.
See more glossary terms