mirror of
https://github.com/home-assistant/core.git
synced 2025-07-29 18:28:14 +02:00
Put draw_box in image_processing (#26712)
* Put draw_box in image_processing * Update draw_box * Update __init__.py * run isort * Fix lints * Update __init__.py * Update requirements_all.txt * Adds type hints * Update gen_requirements_all.py * Update requirements_test_all.txt * rerun script/gen_requirements_all.py * Change Pillow to pillow * Update manifest.json * Run script/gen_requirements_all.py
This commit is contained in:
@ -12,6 +12,7 @@ from homeassistant.components.image_processing import (
|
||||
CONF_SOURCE,
|
||||
PLATFORM_SCHEMA,
|
||||
ImageProcessingEntity,
|
||||
draw_box,
|
||||
)
|
||||
from homeassistant.core import split_entity_id
|
||||
from homeassistant.helpers import template
|
||||
@ -67,24 +68,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
||||
)
|
||||
|
||||
|
||||
def draw_box(draw, box, img_width, img_height, text="", color=(255, 255, 0)):
|
||||
"""Draw bounding box on image."""
|
||||
ymin, xmin, ymax, xmax = box
|
||||
(left, right, top, bottom) = (
|
||||
xmin * img_width,
|
||||
xmax * img_width,
|
||||
ymin * img_height,
|
||||
ymax * img_height,
|
||||
)
|
||||
draw.line(
|
||||
[(left, top), (left, bottom), (right, bottom), (right, top), (left, top)],
|
||||
width=5,
|
||||
fill=color,
|
||||
)
|
||||
if text:
|
||||
draw.text((left, abs(top - 15)), text, fill=color)
|
||||
|
||||
|
||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||
"""Set up the TensorFlow image processing platform."""
|
||||
model_config = config.get(CONF_MODEL)
|
||||
|
Reference in New Issue
Block a user