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:
Robin
2019-09-24 11:09:16 +01:00
committed by Pascal Vizeli
parent 53e6b8ade6
commit 1d60cccc21
8 changed files with 51 additions and 40 deletions

View File

@ -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)