This project provides a real-time translation tool for story-based games or any application where you want to instantly translate on-screen text. The script captures a specific region of your screen, performs OCR (Optical Character Recognition) to extract English text, and then translates it to Turkish using Google Translate. The translation is displayed in a temporary popup window for quick reference while playing or reading.
- Continuously takes screenshots of your screen.
- Crops a user-defined region (ROI) where the text appears (e.g., dialogue box in a game).
- Uses Tesseract OCR to extract English text from the cropped region.
- Translates the extracted text to Turkish using the Deep Translator library.
- Shows the translation in a small, semi-transparent popup window at the top right of the screen.
- The selected region is also shown in a separate OpenCV window for visual feedback.
- Press 'q' to exit the program at any time.
- Install requirements:
pip install pyautogui opencv-python numpy pytesseract deep-translator
- Also install Tesseract-OCR and set its path in the script.
- Set the coordinates:
- Change the values of
x1, y1, x2, y2
in the script to match the region where the text appears on your screen.
- Change the values of
- Run the script:
- The script will start capturing, translating, and displaying the results in real time.
This tool is especially useful for:
- Translating dialogue in story-based games that do not have Turkish language support.
- Instantly understanding any on-screen English text in a specific region.
- The translation popup window automatically closes after 1.5 seconds.
- Make sure the selected region covers only the text area for best OCR results.
- You can adjust the region and popup duration as needed.
This project is a practical solution for gamers and readers who want to quickly translate and understand on-screen English text in real time.