Пример #1
0
def get_resolved_layer_type(layer_config: LayerConfig) -> ResolvedLayerType:
    if layer_config.get('filter'):
        return ResolvedLayerType.FILTER
    if layer_config.get('input_path'):
        return ResolvedLayerType.INPUT_SOURCE
    if layer_config.get('output_path'):
        return ResolvedLayerType.OUTPUT_SINK
    raise ValueError('unable to determine resolved layer type for: %s' % layer_config)
Пример #2
0
 def __init__(self, layer_config: LayerConfig, **kwargs):
     super().__init__(layer_config, **kwargs)
     self.model_path = (layer_config.get('model_path')
                        or BodyPixModelPaths.MOBILENET_FLOAT_50_STRIDE_16)
     self._bodypix_model = None
     self.threshold = float(layer_config.get('threshold') or 0.50)
     self.internal_resolution = float(
         layer_config.get('internal_resolution') or 0.50)
     self.cache_model_result_secs = float(
         layer_config.get('cache_model_result_secs') or 0.0)
     self.parts = list(layer_config.get('parts') or [])
     self._bodypix_result_cache = None
     self._bodypix_result_cache_time = None
Пример #3
0
 def _add_layer_recursively(
     self,
     layer_config: LayerConfig,
     default_id: str,
     default_input_layer: Optional[ResolvedLayerConfig]
 ) -> ResolvedLayerConfig:
     layer_id = layer_config.get('id') or default_id
     branches = layer_config.get('branches')
     if branches:
         return self._add_branches_recursively(
             layer_config,
             layer_id=layer_id,
             default_input_layer=default_input_layer
         )
     resolved_layer_config = ResolvedLayerConfig({
         **layer_config.props,
         'id': layer_id
     }, default_input_layer=default_input_layer)
     return self._add_resolved_layer(resolved_layer_config)
Пример #4
0
 def parse_fill_config(self, layer_config: LayerConfig) -> Config:
     color = layer_config.get('color')
     color_value: Optional[np.ndarray] = get_color_numpy_array(color)
     value = layer_config.get_int('value')
     poly_points_list = layer_config.get_list('poly_points')
     poly_points = (np.asarray(poly_points_list, dtype=np.float32)
                    if poly_points_list else None)
     config = FillFilter.Config(color=color_value,
                                value=value,
                                poly_points=poly_points)
     LOGGER.info('fill config: %s', config)
     assert config.color is not None or config.value is not None
     return config