本文整理汇总了Python中homeassistant.components.image_processing.PLATFORM_SCHEMA.extend方法的典型用法代码示例。如果您正苦于以下问题:Python PLATFORM_SCHEMA.extend方法的具体用法?Python PLATFORM_SCHEMA.extend怎么用?Python PLATFORM_SCHEMA.extend使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类homeassistant.components.image_processing.PLATFORM_SCHEMA
的用法示例。
在下文中一共展示了PLATFORM_SCHEMA.extend方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: async_setup_platform
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
'fr',
'gb',
'kr',
'kr2',
'mx',
'sg',
'us',
'vn2'
]
CONF_ALPR_BIN = 'alp_bin'
DEFAULT_BINARY = 'alpr'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_REGION): vol.All(vol.Lower, vol.In(OPENALPR_REGIONS)),
vol.Optional(CONF_ALPR_BIN, default=DEFAULT_BINARY): cv.string,
})
async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Set up the OpenALPR local platform."""
command = [config[CONF_ALPR_BIN], '-c', config[CONF_REGION], '-']
confidence = config[CONF_CONFIDENCE]
entities = []
for camera in config[CONF_SOURCE]:
entities.append(OpenAlprLocalEntity(
camera[CONF_ENTITY_ID], command, confidence, camera.get(CONF_NAME)
))
示例2: import
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
import requests
import voluptuous as vol
from homeassistant.core import split_entity_id
import homeassistant.helpers.config_validation as cv
from homeassistant.components.image_processing import (
PLATFORM_SCHEMA, ImageProcessingFaceEntity, CONF_SOURCE, CONF_ENTITY_ID,
CONF_NAME)
from homeassistant.const import (CONF_IP_ADDRESS, CONF_PORT)
_LOGGER = logging.getLogger(__name__)
CLASSIFIER = 'facebox'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_IP_ADDRESS): cv.string,
vol.Required(CONF_PORT): cv.port,
})
def encode_image(image):
"""base64 encode an image stream."""
base64_img = base64.b64encode(image).decode('ascii')
return {"base64": base64_img}
def get_matched_faces(faces):
"""Return the name and rounded confidence of matched faces."""
return {face['name']: round(face['confidence'], 2)
for face in faces if face['matched']}
示例3: validate_attributes
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
]
CONF_ATTRIBUTES = 'attributes'
DEFAULT_ATTRIBUTES = [ATTR_AGE, ATTR_GENDER]
def validate_attributes(list_attributes):
"""Validate face attributes."""
for attr in list_attributes:
if attr not in SUPPORTED_ATTRIBUTES:
raise vol.Invalid("Invalid attribtue {0}".format(attr))
return list_attributes
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_ATTRIBUTES, default=DEFAULT_ATTRIBUTES):
vol.All(cv.ensure_list, validate_attributes),
})
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up the Microsoft Face detection platform."""
api = hass.data[DATA_MICROSOFT_FACE]
attributes = config[CONF_ATTRIBUTES]
entities = []
for camera in config[CONF_SOURCE]:
entities.append(MicrosoftFaceDetectEntity(
camera[CONF_ENTITY_ID], api, attributes, camera.get(CONF_NAME)
))
示例4: import
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
from homeassistant.components.image_processing import (
ATTR_CONFIDENCE, CONF_CONFIDENCE, CONF_ENTITY_ID, CONF_NAME, CONF_SOURCE,
PLATFORM_SCHEMA, ImageProcessingFaceEntity)
from homeassistant.components.microsoft_face import DATA_MICROSOFT_FACE
from homeassistant.const import ATTR_NAME
from homeassistant.core import split_entity_id
from homeassistant.exceptions import HomeAssistantError
import homeassistant.helpers.config_validation as cv
_LOGGER = logging.getLogger(__name__)
CONF_GROUP = 'group'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_GROUP): cv.slugify,
})
async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Set up the Microsoft Face identify platform."""
api = hass.data[DATA_MICROSOFT_FACE]
face_group = config[CONF_GROUP]
confidence = config[CONF_CONFIDENCE]
entities = []
for camera in config[CONF_SOURCE]:
entities.append(MicrosoftFaceIdentifyEntity(
camera[CONF_ENTITY_ID], api, face_group, confidence,
camera.get(CONF_NAME)
示例5: draw_box
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
vol.Optional(CONF_LEFT, default=0): cv.small_float,
vol.Optional(CONF_RIGHT, default=1): cv.small_float,
vol.Optional(CONF_TOP, default=0): cv.small_float,
})
CATEGORY_SCHEMA = vol.Schema({
vol.Required(CONF_CATEGORY): cv.string,
vol.Optional(CONF_AREA): AREA_SCHEMA,
})
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_FILE_OUT, default=[]):
vol.All(cv.ensure_list, [cv.template]),
vol.Required(CONF_MODEL): vol.Schema({
vol.Required(CONF_GRAPH): cv.isfile,
vol.Optional(CONF_AREA): AREA_SCHEMA,
vol.Optional(CONF_CATEGORIES, default=[]):
vol.All(cv.ensure_list, [vol.Any(cv.string, CATEGORY_SCHEMA)]),
vol.Optional(CONF_LABELS): cv.isfile,
vol.Optional(CONF_MODEL_DIR): cv.isdir,
})
})
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)
示例6: timedelta
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
DEFAULT_CLASSIFIER_PATH = 'lbp_frontalface.xml'
DEFAULT_MIN_SIZE = (30, 30)
DEFAULT_NEIGHBORS = 4
DEFAULT_SCALE = 1.1
DEFAULT_TIMEOUT = 10
SCAN_INTERVAL = timedelta(seconds=2)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_CLASSIFIER): {
cv.string: vol.Any(
cv.isfile,
vol.Schema({
vol.Required(CONF_FILE): cv.isfile,
vol.Optional(CONF_SCALE, DEFAULT_SCALE): float,
vol.Optional(CONF_NEIGHBORS, DEFAULT_NEIGHBORS):
cv.positive_int,
vol.Optional(CONF_MIN_SIZE, DEFAULT_MIN_SIZE):
vol.Schema((int, int))
})
)
}
})
def _create_processor_from_config(hass, camera_entity, config):
"""Create an OpenCV processor from configuration."""
classifier_config = config.get(CONF_CLASSIFIER)
name = '{} {}'.format(
config[CONF_NAME], split_entity_id(camera_entity)[1].replace('_', ' '))
示例7: timedelta
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
CLASSIFIER_GROUP_CONFIG,
CONF_CLASSIFIER,
CONF_ENTITY_ID,
CONF_NAME,
process_image,
)
DEPENDENCIES = ['opencv']
_LOGGER = logging.getLogger(__name__)
DEFAULT_TIMEOUT = 10
SCAN_INTERVAL = timedelta(seconds=2)
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(CLASSIFIER_GROUP_CONFIG)
def _create_processor_from_config(hass, camera_entity, config):
"""Create an OpenCV processor from configurtaion."""
classifier_config = config[CONF_CLASSIFIER]
name = '{} {}'.format(
config[CONF_NAME],
split_entity_id(camera_entity)[1].replace('_', ' '))
processor = OpenCVImageProcessor(
hass,
camera_entity,
name,
classifier_config,
)
示例8: import
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
from homeassistant.core import split_entity_id
from homeassistant.components.image_processing import (
ImageProcessingFaceEntity, PLATFORM_SCHEMA, CONF_SOURCE, CONF_ENTITY_ID,
CONF_NAME)
import homeassistant.helpers.config_validation as cv
REQUIREMENTS = ['face_recognition==1.2.3']
_LOGGER = logging.getLogger(__name__)
ATTR_NAME = 'name'
CONF_FACES = 'faces'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_FACES): {cv.string: cv.isfile},
})
def setup_platform(hass, config, add_entities, discovery_info=None):
"""Set up the Dlib Face detection platform."""
entities = []
for camera in config[CONF_SOURCE]:
entities.append(DlibFaceIdentifyEntity(
camera[CONF_ENTITY_ID], config[CONF_FACES], camera.get(CONF_NAME)
))
add_entities(entities)
class DlibFaceIdentifyEntity(ImageProcessingFaceEntity):
示例9: async_setup_platform
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
CONF_HEIGHT = 'height'
CONF_ROTATE = 'rotate'
CONF_SSOCR_BIN = 'ssocr_bin'
CONF_THRESHOLD = 'threshold'
CONF_WIDTH = 'width'
CONF_X_POS = 'x_position'
CONF_Y_POS = 'y_position'
DEFAULT_BINARY = 'ssocr'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_EXTRA_ARGUMENTS, default=''): cv.string,
vol.Optional(CONF_DIGITS): cv.positive_int,
vol.Optional(CONF_HEIGHT, default=0): cv.positive_int,
vol.Optional(CONF_SSOCR_BIN, default=DEFAULT_BINARY): cv.string,
vol.Optional(CONF_THRESHOLD, default=0): cv.positive_int,
vol.Optional(CONF_ROTATE, default=0): cv.positive_int,
vol.Optional(CONF_WIDTH, default=0): cv.positive_int,
vol.Optional(CONF_X_POS, default=0): cv.string,
vol.Optional(CONF_Y_POS, default=0): cv.positive_int,
})
async def async_setup_platform(hass, config, async_add_entities,
discovery_info=None):
"""Set up the Seven segments OCR platform."""
entities = []
for camera in config[CONF_SOURCE]:
entities.append(ImageProcessingSsocr(
hass, camera[CONF_ENTITY_ID], config, camera.get(CONF_NAME)
))
示例10: async_setup_platform
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
'eu',
'fr',
'gb',
'kr',
'kr2',
'mx',
'sg',
'us',
'vn2'
]
CONF_REGION = 'region'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_API_KEY): cv.string,
vol.Required(CONF_REGION):
vol.All(vol.Lower, vol.In(OPENALPR_REGIONS)),
})
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up the openalpr cloud api platform."""
confidence = config[CONF_CONFIDENCE]
params = {
'secret_key': config[CONF_API_KEY],
'tasks': "plate",
'return_image': 0,
'country': config[CONF_REGION],
}
示例11: import
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
from homeassistant.core import split_entity_id
import homeassistant.helpers.config_validation as cv
from homeassistant.components.image_processing import (
PLATFORM_SCHEMA, CONF_SOURCE, CONF_ENTITY_ID,
CONF_NAME)
from homeassistant.components.image_processing.microsoft_face_identify import (
ImageProcessingFaceEntity)
_LOGGER = logging.getLogger(__name__)
CONF_ENDPOINT = 'endpoint'
ROUNDING_DECIMALS = 2
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_ENDPOINT): cv.string,
})
def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the classifier."""
entities = []
for camera in config[CONF_SOURCE]:
entities.append(Facebox(
camera.get(CONF_NAME),
config[CONF_ENDPOINT],
camera[CONF_ENTITY_ID]
))
add_devices(entities)
示例12: check_box_health
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
ATTR_BOUNDING_BOX = 'bounding_box'
ATTR_CLASSIFIER = 'classifier'
ATTR_IMAGE_ID = 'image_id'
ATTR_ID = 'id'
ATTR_MATCHED = 'matched'
FACEBOX_NAME = 'name'
CLASSIFIER = 'facebox'
DATA_FACEBOX = 'facebox_classifiers'
FILE_PATH = 'file_path'
SERVICE_TEACH_FACE = 'facebox_teach_face'
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_IP_ADDRESS): cv.string,
vol.Required(CONF_PORT): cv.port,
vol.Optional(CONF_USERNAME): cv.string,
vol.Optional(CONF_PASSWORD): cv.string,
})
SERVICE_TEACH_SCHEMA = vol.Schema({
vol.Optional(ATTR_ENTITY_ID): cv.entity_ids,
vol.Required(ATTR_NAME): cv.string,
vol.Required(FILE_PATH): cv.string,
})
def check_box_health(url, username, password):
"""Check the health of the classifier and return its id if healthy."""
kwargs = {}
if username:
kwargs['auth'] = requests.auth.HTTPBasicAuth(username, password)
示例13: async_setup_platform
# 需要导入模块: from homeassistant.components.image_processing import PLATFORM_SCHEMA [as 别名]
# 或者: from homeassistant.components.image_processing.PLATFORM_SCHEMA import extend [as 别名]
'gb',
'kr',
'mx',
'sg',
]
CONF_REGION = 'region'
CONF_ALPR_BIN = 'alp_bin'
DEFAULT_BINARY = 'alpr'
DEFAULT_CONFIDENCE = 80
PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_REGION):
vol.All(vol.Lower, vol.In(OPENALPR_REGIONS)),
vol.Optional(CONF_ALPR_BIN, default=DEFAULT_BINARY): cv.string,
vol.Optional(CONF_CONFIDENCE, default=DEFAULT_CONFIDENCE):
vol.All(vol.Coerce(float), vol.Range(min=0, max=100))
})
@asyncio.coroutine
def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
"""Set up the openalpr local platform."""
command = [config[CONF_ALPR_BIN], '-c', config[CONF_REGION], '-']
confidence = config[CONF_CONFIDENCE]
entities = []
for camera in config[CONF_SOURCE]:
entities.append(OpenAlprLocalEntity(
camera[CONF_ENTITY_ID], command, confidence, camera.get(CONF_NAME)