An Interactive Educational Tool for Mastering Blackjack Strategies
- Introduction
- Features
- How It Works
- Screenshots and Examples
- Prerequisites
- Installation
- Usage
- Project Structure
- Contributing
- License
- Contact
DeckDetective is an innovative educational platform designed to help users learn and master blackjack strategies through real-time simulation and feedback. By leveraging computer vision, strategic algorithms, and a user-friendly interface built with Vue.js, DeckDetective provides an interactive experience that teaches:
- Basic blackjack strategies
- Card counting techniques
- Strategy deviations based on the true count
Whether you're a beginner looking to understand the fundamentals or an experienced player aiming to refine your skills, DeckDetective offers a hands-on approach to learning blackjack in an engaging and immersive way.
- Real-Time Card Detection: Utilizes computer vision to detect and recognize playing cards from a live video stream.
- Strategy Suggestions: Provides immediate recommendations based on basic blackjack strategy, including when to hit, stand, double down, split pairs, or surrender.
- Card Counting Integration: Tracks the running count and calculates the true count to adjust strategy suggestions dynamically.
- Strategy Deviations: Incorporates advanced strategy deviations based on the true count, teaching users when to adjust their play.
- Interactive Interface: Displays live video with annotations, including detected cards, true count, and strategic suggestions, all within a Vue.js application.
- Educational Focus: Designed to be a learning tool, making complex blackjack strategies accessible and understandable.
DeckDetective processes video frames from a webcam or video feed to detect and recognize playing cards on the table. It then:
- Detects Cards: Uses image processing to find cards within the video frame.
- Recognizes Cards: Matches detected cards against a trained dataset to identify the rank and suit.
- Calculates Counts: Updates the running count and true count based on recognized cards using card counting techniques.
- Generates Suggestions: Provides strategy suggestions based on basic blackjack strategy and adjusts them according to the true count.
- Displays Information: Overlays the video feed with annotations showing the detected cards, true count, and strategic advice within a Vue.js frontend.
Below are some screenshots and GIFs demonstrating DeckDetective in action:
DeckDetective detecting and recognizing cards in real-time.
Real-time strategy suggestions displayed alongside the video feed.
The true count and optimal move are updated dynamically as cards are detected.
Before running DeckDetective, ensure you have the following installed:
- Python 3.7 or higher
- OpenCV: For image processing tasks.
- NumPy: For numerical computations.
- FastAPI: For serving the backend application.
- uvicorn: For running the ASGI server.
- WebSocket Support: For real-time communication between the backend and frontend.
- Node.js and npm: For running the frontend application (Vue.js).
- Vue CLI: For serving the Vue.js application.
git clone https://github.com/jonleed/DeckDetective.git
cd DeckDetectivepython3 -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`pip install -r requirements.txtEnsure OpenCV is installed. If not, install it using:
pip install opencv-pythoncd frontendnpm installNavigate back to the root directory (if not already there) and run the FastAPI application:
uvicorn main:app --reload- The backend server will start on
http://localhost:8000.
In a new terminal, navigate to the frontend directory and start the Vue.js application:
npm run serve- The frontend application will start on
http://localhost:8080or another available port.
Open your web browser and navigate to the frontend URL provided in the terminal (e.g., http://localhost:8080).
- Set Up Your Camera: Ensure your webcam is connected and positioned to capture the playing area where you'll place the cards.
- Start Playing: Place playing cards in view of the camera. The application will detect the cards and display strategy suggestions in real-time.
- View Suggestions: The true count and optimal move suggestions will update dynamically as cards are detected and recognized.
- Interactive Learning: Use the suggestions to learn about optimal blackjack strategies and how card counting affects decision-making.
- backend/: Contains the Python backend application code.
main.py: FastAPI application with WebSocket endpoint.CardDetector.py: Main class for card detection and strategy computation.Cards.py: Helper functions and classes for card processing.VideoStream.py: Video stream handling.requirements.txt: Python dependencies.
- frontend/: Contains the Vue.js frontend application code.
src/: Vue.js components and assets.App.vue: Main Vue.js application component.components/: Contains Vue.js components likeSocket.vue.main.js: Entry point for the Vue.js application.
package.json: Node.js dependencies.
- Card_Imgs/: Contains the training images for card ranks and suits used for card recognition.
- images/: Directory to store screenshots and GIFs for the README.
- README.md: Project documentation.
- LICENSE: License information.
Contributions are welcome! If you'd like to contribute to DeckDetective, please follow these steps:
- Fork the Repository: Create your own fork of the project.
- Create a Feature Branch: Develop your feature or fix in a new branch.
git checkout -b feature/your-feature-name
- Commit Your Changes: Write clear and concise commit messages.
git commit -m "Add your commit message here" - Push to Your Fork: Push your changes to your forked repository.
git push origin feature/your-feature-name
- Submit a Pull Request: Describe your changes and submit a pull request for review.
This project is licensed under the MIT License.
For any questions or support, please open an issue on the GitHub repository or contact the project maintainers.
- Card Dataset: Ensure you have the training images for card ranks and suits in the
Card_Imgs/directory. These images are essential for card recognition. - Camera Calibration: For best results, calibrate your camera settings and ensure good lighting conditions to improve card detection accuracy.
- Error Handling: The application includes basic error handling, but additional robustness can be added to handle edge cases and improve performance.
- Extensibility: DeckDetective is designed to be extensible. Feel free to add new features, such as additional strategy rules, support for different blackjack variations, or enhanced user interfaces.
- Platform Compatibility: The application is cross-platform and should run on Windows, macOS, and Linux systems that meet the prerequisites.
- WebSocket Connection Issues: Ensure that both the backend and frontend are running on the correct ports and that there are no firewall restrictions.
- Module Not Found Errors: Verify that all dependencies are installed correctly in your virtual environment.
- Camera Access Problems: Check that your webcam is properly connected and that you have granted the necessary permissions for camera access.
- OpenCV: For providing powerful computer vision tools.
- Vue.js: For the progressive JavaScript framework used in the frontend.
- FastAPI: For the modern, fast (high-performance) web framework used in the backend.
- Contributors: Thanks to everyone who has contributed to this project.
Thank you for using DeckDetective! We hope this tool enhances your understanding and enjoyment of blackjack strategies.
