{"id":24030473,"url":"https://github.com/zreechxnn/servo-controller-ocr","last_synced_at":"2025-10-14T18:06:24.440Z","repository":{"id":271097848,"uuid":"912394097","full_name":"Zreechxnn/servo-controller-OCR","owner":"Zreechxnn","description":"Servo Controller-OCR integrates computer vision, OCR, and Arduino to control a servo motor based on text detection from a webcam. It uses Python for real-time image processing and Tesseract OCR for text recognition, combined with Arduino to handle servo motor operations. Ideal for automation projects requiring text-based triggers.","archived":false,"fork":false,"pushed_at":"2025-01-10T11:06:59.000Z","size":44,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-14T18:06:23.330Z","etag":null,"topics":["arduino-uno","iot-device","ocr-python","ocr-text-reader","opencv","opencv-python","servo-controller"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zreechxnn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-01-05T13:06:44.000Z","updated_at":"2025-01-10T11:07:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"2a0efece-f177-4d3c-b9b1-4dd345f130da","html_url":"https://github.com/Zreechxnn/servo-controller-OCR","commit_stats":null,"previous_names":["zreechxnn/servo-controller-ocr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Zreechxnn/servo-controller-OCR","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zreechxnn%2Fservo-controller-OCR","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zreechxnn%2Fservo-controller-OCR/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zreechxnn%2Fservo-controller-OCR/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zreechxnn%2Fservo-controller-OCR/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zreechxnn","download_url":"https://codeload.github.com/Zreechxnn/servo-controller-OCR/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zreechxnn%2Fservo-controller-OCR/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279020323,"owners_count":26086864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino-uno","iot-device","ocr-python","ocr-text-reader","opencv","opencv-python","servo-controller"],"created_at":"2025-01-08T17:44:12.060Z","updated_at":"2025-10-14T18:06:24.436Z","avatar_url":"https://github.com/Zreechxnn.png","language":"Python","readme":"# servo-controller-OCR\n\nServo Controller-OCR is a project that integrates computer vision, OCR (Optical Character Recognition), and Arduino to control a servo motor based on the detection of specific text (e.g., card numbers). This project uses Python for the computer vision and OCR processing, and Arduino for servo motor control.\n\n## Features\n- Real-time card detection using a webcam.\n- Optical Character Recognition (OCR) using Tesseract.\n- Servo motor control via Arduino based on detected text similarity.\n- Adjustable similarity threshold for text recognition.\n- Easy configuration for custom card numbers.\n\n---\n\n## Technologies Used\n### Python Libraries\n- **OpenCV**: For webcam video capture and image preprocessing.\n- **pytesseract**: For text recognition from images.\n- **serial**: For communication with Arduino.\n- **difflib**: For text similarity comparison.\n\n### Arduino Components\n- **Servo.h**: For servo motor control.\n- Arduino Uno or similar board.\n- Servo motor.\n- USB cable for serial communication.\n\n---\n\n## Prerequisites\n1. Install Python (3.x).\n2. Install Tesseract-OCR:\n   - Download and install Tesseract from [Tesseract OCR](https://github.com/tesseract-ocr/tesseract).\n   - Update the path to the Tesseract executable in the Python script:\n     ```python\n     pytesseract.pytesseract.tesseract_cmd = r\"C:\\Program Files\\Tesseract-OCR\\tesseract.exe\"\n     ```\n3. Install required Python libraries:\n   ```bash\n   pip install opencv-python pyserial pytesseract\n   ```\n4. Set up an Arduino with a servo motor.\n\n---\n\n## Hardware Setup\n- Connect the servo motor's signal pin to Arduino pin 2.\n- Ensure the Arduino is connected to your computer via USB.\n- Upload the provided Arduino code to your Arduino board using the Arduino IDE.\n\n---\n\n## Usage\n### 1. Prepare Card Data\nCreate a file named `data.txt` in the project directory and add the card numbers (one per line) that should trigger the servo.\n\n### 2. Run the Python Script\nExecute the Python script to start real-time card detection:\n```bash\npython ocr.py\n```\n\n- The webcam will capture frames and process them for OCR.\n- If the detected text matches any card number in `data.txt` with a similarity score ≥ 85%, the servo motor will turn on for 5 seconds, then turn off.\n- Press `q` to exit the program.\n\n---\n\n## Python Code Explanation\nThe Python script performs the following tasks:\n1. Captures video frames using OpenCV.\n2. Processes the frames (grayscale and Gaussian blur) for better OCR results.\n3. Uses Tesseract to extract text from the processed frames.\n4. Compares the detected text with predefined card numbers using `SequenceMatcher`.\n5. Sends commands (`ON`/`OFF`) to the Arduino via serial communication to control the servo motor.\n\n---\n\n## Arduino Code Explanation\nThe Arduino code listens for serial commands (`ON` or `OFF`):\n- `ON`: Rotates the servo motor to 90° (active position).\n- `OFF`: Rotates the servo motor back to 0° (idle position).\n\n---\n\n## Important Notes\n1. Ensure the correct COM port is specified in the Python script:\n   ```python\n   arduino = serial.Serial(port='COM3', baudrate=9600, timeout=1)\n   ```\n2. Adjust the camera resolution if needed:\n   ```python\n   cap.set(cv2.CAP_PROP_FRAME_WIDTH, 320)\n   cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 240)\n   ```\n3. Modify the similarity threshold as necessary in the Python script (default is 85%).\n\n---\n\n## Troubleshooting\n- **Webcam not detected:** Ensure the camera is properly connected and accessible.\n- **Serial communication issues:** Verify the correct COM port and baud rate are set in the Python script.\n- **OCR accuracy issues:**\n  - Improve lighting conditions.\n  - Use high-quality text for recognition.\n  - Adjust Tesseract configuration options (e.g., `--psm` mode).\n\n---\n\n## Future Improvements\n- Add a GUI for better user interaction.\n- Enhance text preprocessing for improved OCR accuracy.\n- Integrate additional sensors or features for more complex applications.\n\n---\n\n## License\nThis project is open-source and available under the [License](LICENSE).\n\n---\n\n## Acknowledgments\n- [Tesseract OCR](https://github.com/tesseract-ocr/tesseract)\n- [OpenCV](https://opencv.org/)\n- Arduino community for their comprehensive documentation and examples.\n\n---\n\n## License\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n---\n\nFeel free to modify the code or improve the project as needed!\n\n\u003cp align=\"center\"\u003e©️ 2024 Rechan Dinata\u003c/p\u003e\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzreechxnn%2Fservo-controller-ocr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzreechxnn%2Fservo-controller-ocr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzreechxnn%2Fservo-controller-ocr/lists"}