or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/imutils@0.5.x
tile.json

tessl/pypi-imutils

tessl install tessl/pypi-imutils@0.5.0

A 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%

task.mdevals/scenario-1/

Face Detection Bounding Box Converter

Build a simple utility that converts face detection results to OpenCV-compatible bounding box format.

Requirements

Create a Python module that converts dlib rectangle objects (from face detection) into OpenCV bounding box tuples with the format (x, y, width, height).

Your solution should:

  • Accept a single dlib rectangle and return a bounding box tuple
  • Handle multiple rectangles, preserving their order
  • Produce output compatible with OpenCV drawing functions

Test Cases

  • Given a dlib rectangle with coordinates (50, 100, 150, 200), the output is (50, 100, 100, 100) representing x=50, y=100, w=100, h=100 @test
  • Given a list of three dlib rectangles, the function returns three corresponding bounding box tuples in the same order @test
  • The output format is compatible with OpenCV's cv2.rectangle() function which expects (x, y, w, h) format @test

Implementation

@generates

API

def convert_detection_to_bbox(rect):
    """
    Convert a face detection rectangle to OpenCV bounding box format.

    Args:
        rect: A dlib rectangle object representing a detected face

    Returns:
        tuple: A 4-element tuple (x, y, w, h) where:
            - x: left coordinate
            - y: top coordinate
            - w: width
            - h: height
    """
    pass

def convert_detections_to_bboxes(rects):
    """
    Convert multiple face detection rectangles to OpenCV bounding box format.

    Args:
        rects: A list of dlib rectangle objects

    Returns:
        list: A list of tuples, each containing (x, y, w, h)
    """
    pass

Dependencies { .dependencies }

imutils { .dependency }

Provides utilities for converting between dlib and OpenCV coordinate formats.

dlib { .dependency }

Face detection library that outputs rectangle objects.