Ultimate Computer Vision TicTacToe is a Python project that simulates a TicTacToe player whose "eyes" are the camera of a mobile device. The application uses Python and OpenCV to recognize and interact with the TicTacToe board.
- Play against an AI with three difficulty modes: Easy, Medium, and Nightmare.
- Real-time board recognition via a mobile device camera.
- Train and test your own symbol classifier for custom configurations.
- Python (latest version recommended)
- DroidCam installed on your mobile device
Follow these steps to set up the project:
-
Clone the Repository
git clone https://github.com/macorisd/U-CV-TTT.git
-
Install Python
- Go to python.org/downloads.
- Download and install the latest version of Python.
-
Install DroidCam on a Mobile Device
- For Android: Download from Google Play Store.
-
Install Required Python Packages
-
Open the project folder, named
U-CV-TTT. -
Right-click in the folder and select Open in Terminal.
-
Install dependencies using one of the following methods:
Option 1: Run the batch file
install_packages.batlocated in theSetupfolder.Option 2: Install packages manually by running the following commands:
pip install opencv-python pip install shapely pip install matplotlib
-
-
You're ready to play!
- Open the file
U-CV-TTT.pywfor direct execution, or runU-CV-TTT.pyto view the Python code.
- Open the file
- Connect both your mobile device and computer to the same Wi-Fi network (or tether your computer to your mobile data).
- Launch DroidCam on your mobile device.
- Run the
U-CV-TTT.pywfile. - Click on the IP/Port button in the application window.
- Enter the IP and port provided by DroidCam into the corresponding fields.
- Select a difficulty mode: Easy, Medium, or Nightmare.
- Capture board images by pressing the spacebar. Exit the application by pressing
q.
- Use plain white paper and a black marker for better recognition.
- Align the TicTacToe board approximately within the provided grid, but avoid placing it too close to the camera.
- You may choose to draw or not draw the bot's moves on the paper; both approaches work.
-
Train Your Own Symbol Classifier
- Use the
train_classifier.pyscript to train a custom symbol classifier.
- Use the
-
Test the Symbol Classifier
- Use the
test_classifier.pyscript to evaluate your classifier's performance.
- Use the
Made with ❤️ by Macorís Decena Giménez.
GitHub Profile
If you encounter any bugs or issues, please feel free to contact me at macorisd@gmail.com.