tessl install tessl/pypi-imutils@0.5.0A series of convenience functions to make basic image processing functions such as translation, rotation, resizing, skeletonization, displaying Matplotlib images, sorting contours, detecting edges, and much more easier with OpenCV and both Python 2.7 and Python 3.
Agent Success
Agent success rate when using this tile
91%
Improvement
Agent success rate improvement when using this tile compared to baseline
1.34x
Baseline
Agent success rate without this tile
68%
A simple image processing module that demonstrates proper handling of OpenCV version differences.
You need to create an image processing module that works correctly across different OpenCV versions. OpenCV has API breaking changes between versions 2.x, 3.x, and 4.x, particularly in how cv2.findContours() returns results. Your module should handle these differences seamlessly.
Create a Python module that provides the following image processing capabilities:
Find and Sort Objects: Implement a function that:
cv2.findContours() with RETR_EXTERNAL and CHAIN_APPROX_SIMPLE modesGet Version Report: Implement a function that returns a dictionary with:
@generates
def find_and_sort_objects(binary_image):
"""
Find contours in a binary image and sort by area.
Args:
binary_image: A binary (thresholded) image as a numpy array.
Returns:
list: List of contours sorted by area in descending order (largest first).
"""
def get_version_report():
"""
Get information about the OpenCV version.
Returns:
dict: Dictionary with keys:
- "version" (int): Major version number (2, 3, or 4)
- "supports_modern_features" (bool): True if version 3.x or higher
- "is_latest_major" (bool): True if version 4.x or higher
"""Provides convenient image processing functions and version compatibility utilities.