Final project for the Image Analysis course (SSY098) at Chalmers University of Technology.
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.
- 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
main.ipynb: main notebook with the full processing, training, and testing workflowfunctions.py: support functions for feature extraction, matching, training, etc.card_classifier.pth: pre-trained CNN model for card classificationimages/: sample images, full games, training and test samplesrequirements.txt: Python dependenciesreport/: final report and related resources
- Python 3.10+
- See
requirements.txtfor all dependencies (including OpenCV, torch, torchvision, matplotlib, scikit-learn, etc.)
To install dependencies:
pip install -r requirements.txt- Prepare images: place game images in the
images/gameX/folder (see examples). - Run the notebook
main.ipynbin Jupyter or VS Code. - The system will automatically detect cards, classify front/back, and suggest moves.
- 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
- Train the CNN classifier on new data (
- 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.
Gabriele Beltrami
Chalmers University of Technology
SSY098 - Image Analysis VT2025
- See
report/for the detailed report and experimental results. - The project uses SIFT, CNN (PyTorch), OpenCV, and other open source libraries.