Skip to content

TarikToha/OCR-2048-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

2048 OCR API

MIT License

A Python-based OCR API for extracting 4×4 tile values from 2048 game screenshots using OpenCV and Tesseract. It includes a FastAPI backend and a browser-based HTML frontend.


Requirements

  • Python 3.9+
  • A modern web browser (for the frontend)
  • Tesseract OCR installed and available in your system path

Install dependencies:

pip install -r requirements.txt

Run Server

Start the FastAPI backend:

uvicorn ocr_api:app --reload

Launch Frontend

Serve index.html with a simple HTTP server:

python -m http.server

Then open the page in your browser.


Upload

Upload a screenshot of the 2048 game using the browser interface served by index.html.


Example Output

Input Output

🧩 OCR 2048 Board:
   2   4   4   8
  32  16   4   2
   2  64  16   4
  32   8   4   2
      

File Structure

.
├── index.html         # Frontend interface
├── ocr_api.py         # FastAPI backend
├── requirements.txt   # Python dependencies

Credits