feat: Add bounding box functionality for machine learning applications #81
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Bounding Box Functionality for Machine Learning Applications
Overview
This PR adds a new
generate_with_bounding_boxesmethod to theImageCaptchaclass that provides precise character-level bounding box coordinates alongside CAPTCHA generation. This functionality is specifically designed to support machine learning, computer vision, and OCR development by providing high-quality labeled training data.New Features
Core Functionality
generate_with_bounding_boxes()method that returns both the CAPTCHA image and character bounding box informationCharacterBoundingBoxTypedDict for structured bounding box dataKey Benefits
Use Cases
Implementation Details
API Design
Technical Features
Files Added
examples/example_bounding_boxes.py- Comprehensive usage examplesexamples/README.md- Detailed documentation and ML integration guides.gitignoreto exclude generated example imagesExample Output
The example generates multiple CAPTCHA images with visualized bounding boxes, demonstrating:
ML Integration Examples
The documentation includes conversion examples for popular ML formats:
Backward Compatibility
Testing
This enhancement makes the captcha library significantly more valuable for the ML/CV community while maintaining its simplicity and reliability for traditional CAPTCHA use cases.