Skip to content

beltra/MemoryAssistant

Repository files navigation

A Vision-Based Assistant for the Memory Game

Final project for the Image Analysis course (SSY098) at Chalmers University of Technology.

Overview

This project implements a computer vision system to assist a player in the card game "Memory". The system detects, classifies, and matches cards using computer vision and machine learning techniques, providing automatic support during the game.

Main Features

  • Card detection using edge detection (Canny) and contour analysis
  • Card classification (front/back) via:
    • SIFT feature matching
    • Convolutional Neural Network (CNN)
  • Matching of face-up cards using SIFT feature matching
  • Game logic for two players, with turn and score management
  • Support for images from different perspectives and rotations

Project Structure

  • main.ipynb: main notebook with the full processing, training, and testing workflow
  • functions.py: support functions for feature extraction, matching, training, etc.
  • card_classifier.pth: pre-trained CNN model for card classification
  • images/: sample images, full games, training and test samples
  • requirements.txt: Python dependencies
  • report/: final report and related resources

Requirements

  • Python 3.10+
  • See requirements.txt for all dependencies (including OpenCV, torch, torchvision, matplotlib, scikit-learn, etc.)

To install dependencies:

pip install -r requirements.txt

Usage

  1. Prepare images: place game images in the images/gameX/ folder (see examples).
  2. Run the notebook main.ipynb in Jupyter or VS Code.
  3. The system will automatically detect cards, classify front/back, and suggest moves.
  4. Available functions:
    • Train the CNN classifier on new data (trainCardClassifier)
    • Generate new samples via augmentation (augmentDataset)
    • Test the system on single images or full games

Notes and Limitations

  • Card detection may fail on very light backgrounds or when cards are touching.
  • The system was tested on 1024x1024 px images, but can be adapted.
  • Robustness is guaranteed for different rotations and perspectives, but depends on image quality.

Author

Gabriele Beltrami
Chalmers University of Technology
SSY098 - Image Analysis VT2025

References

  • See report/ for the detailed report and experimental results.
  • The project uses SIFT, CNN (PyTorch), OpenCV, and other open source libraries.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published