isimple.core package

Submodules

isimple.core.backend module

exception isimple.core.backend.BackendSetupError(*args)[source]

Bases: isimple.core.common.SetupError

msg = 'Error while setting up backend'
exception isimple.core.backend.BackendError(*args)[source]

Bases: isimple.core.common.RootException

msg = 'Error in backend'
exception isimple.core.backend.CacheAccessError(*args)[source]

Bases: isimple.core.common.RootException

msg = 'Trying to access cache out of context'
class isimple.core.backend.BackendInstance(config: Optional[isimple.core.config.BackendInstanceConfig])[source]

Bases: object

class isimple.core.backend.CachingBackendInstance(config: isimple.core.config.CachingBackendInstanceConfig = None)[source]

Bases: isimple.core.backend.BackendInstance

Interface to diskcache.Cache

caching()[source]
class isimple.core.backend.Handler[source]

Bases: object

set_implementation(implementation: str) → str[source]
get_implementation() → str[source]
class isimple.core.backend.BackendManager(config: isimple.core.config.BackendManagerConfig = None)[source]

Bases: isimple.core.backend.BackendInstance, isimple.core.common.Manager

launch()[source]
caching()[source]

Caching contest on VideoAnalysis: propagate context to every contained BackendElement that implements caching

save()[source]

isimple.core.common module

exception isimple.core.common.RootException(*args)[source]

Bases: Exception

msg = ''
exception isimple.core.common.SetupError(*args)[source]

Bases: isimple.core.common.RootException

class isimple.core.common.Endpoint(signature: Type[Callable])[source]

Bases: object

compatible(method: Callable) → bool[source]
signature
registered
add(method)[source]
register(name: str)[source]
class isimple.core.common.EndpointRegistry[source]

Bases: object

class isimple.core.common.InstanceRegistry[source]

Bases: isimple.core.common.EndpointRegistry

This one is global, collects callables that expose endpoints

expose(endpoint: isimple.core.common.Endpoint)[source]
exposes(endpoint: isimple.core.common.Endpoint)[source]
endpoints
class isimple.core.common.ImmutableRegistry(endpoints: isimple.core.common.InstanceRegistry = None)[source]

Bases: isimple.core.common.EndpointRegistry

expose(endpoint: isimple.core.common.Endpoint)[source]
exposes(endpoint: isimple.core.common.Endpoint)[source]
endpoints
class isimple.core.common.Manager[source]

Bases: object

connect(manager)[source]
get(endpoint: isimple.core.common.Endpoint, index: int = None) → Callable[source]

isimple.core.config module

class isimple.core.config.HsvColor(h, s, v)

Bases: tuple

h

Alias for field number 0

s

Alias for field number 1

v

Alias for field number 2

class isimple.core.config.EnforcedStr(string: str = None)[source]

Bases: object

options
default
class isimple.core.config.Factory(string: str = None)[source]

Bases: isimple.core.config.EnforcedStr

get() → type[source]
classmethod get_str(mapped_value)[source]
options
default
classmethod extend(mapping: dict)[source]
class isimple.core.config.ColorSpace(string: str = None)[source]

Bases: isimple.core.config.EnforcedStr

class isimple.core.config.FrameIntervalSetting(string: str = None)[source]

Bases: isimple.core.config.EnforcedStr

class isimple.core.config.TransformType(string: str = None)[source]

Bases: isimple.core.config.Factory

class isimple.core.config.FilterType(string: str = None)[source]

Bases: isimple.core.config.Factory

class isimple.core.config.VideoFeatureType(string: str = None)[source]

Bases: isimple.core.config.Factory

class isimple.core.config.BackendType(string: str = None)[source]

Bases: isimple.core.config.Factory

class isimple.core.config.Config(**kwargs)[source]

Bases: abc.ABC

Abstract class for configuration data. * Default values for Config or Factory subclasses should be provided as

None and ‘’ respectively; in this way they should be caught by self.resolve and resolved at runtime. This is important to resolve to the latest version of the Factory, as it may have been extended.
static resolve(val, type, iter=False)[source]

Resolve the value of an attribute to match a specific type :param val: current value :param type: type to resolve to :param iter: if True, interpret val as an iterable and resolve

all elements of val to type
Returns:the resolved value for val; this should be written to the original attribute, i.e. self.attr = resolve(self.attr, type)
to_dict() → dict[source]

Return this instances value as a serializable dict.

class isimple.core.config.BackendInstanceConfig(**kwargs)[source]

Bases: isimple.core.config.Config

class isimple.core.config.CachingBackendInstanceConfig(do_cache: bool = True, do_background: bool = False, cache_dir: str = '.cache', cache_size_limit: int = 4294967296, block_timeout: float = 1, cache_consumer: bool = False)[source]

Bases: isimple.core.config.BackendInstanceConfig

do_cache = True
do_background = False
cache_dir = '.cache'
cache_size_limit = 4294967296
block_timeout = 1
cache_consumer = False
class isimple.core.config.VideoFileHandlerConfig(do_cache: bool = True, do_background: bool = False, cache_dir: str = '.cache', cache_size_limit: int = 4294967296, block_timeout: float = 1, cache_consumer: bool = False, do_resolve_frame_number: bool = True)[source]

Bases: isimple.core.config.CachingBackendInstanceConfig

do_resolve_frame_number = True
class isimple.core.config.TransformHandlerConfig(type: Union[isimple.core.config.TransformType, str] = '', matrix: Union[numpy.ndarray, str] = array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]), coordinates: Union[list, str] = '')[source]

Bases: isimple.core.config.BackendInstanceConfig

TransformHandlerConfig(type: Union[isimple.core.config.TransformType, str] = ‘’, matrix: Union[numpy.ndarray, str] = array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]]), coordinates: Union[list, str] = ‘’)

type = ''
matrix = array([[1., 0., 0.], [0., 1., 0.], [0., 0., 1.]])
coordinates = ''
class isimple.core.config.FilterConfig(**kwargs)[source]

Bases: isimple.core.config.Config

class isimple.core.config.HsvRangeFilterConfig(radius: Union[isimple.core.config.HsvColor, str] = HsvColor(h=10, s=75, v=75), c0: Union[isimple.core.config.HsvColor, str] = HsvColor(h=0, s=0, v=0), c1: Union[isimple.core.config.HsvColor, str] = HsvColor(h=0, s=0, v=0))[source]

Bases: isimple.core.config.FilterConfig

radius = HsvColor(h=10, s=75, v=75)
c0 = HsvColor(h=0, s=0, v=0)
c1 = HsvColor(h=0, s=0, v=0)
class isimple.core.config.FilterHandlerConfig(type: Union[isimple.core.config.FilterType, str] = '', data: Union[isimple.core.config.FilterConfig, dict, NoneType] = None)[source]

Bases: isimple.core.config.BackendInstanceConfig

type = ''
data = None
class isimple.core.config.MaskConfig(name: Union[str, NoneType] = None, height: Union[float, NoneType] = None, filter: Union[isimple.core.config.FilterHandlerConfig, dict, NoneType] = None)[source]

Bases: isimple.core.config.BackendInstanceConfig

name = None
height = None
filter = None
class isimple.core.config.DesignFileHandlerConfig(do_cache: bool = True, do_background: bool = False, cache_dir: str = '.cache', cache_size_limit: int = 4294967296, block_timeout: float = 1, cache_consumer: bool = False, render_dir: str = '.render', keep_renders: bool = False, dpi: int = 400, overlay_alpha: float = 0.1, smoothing: int = 7)[source]

Bases: isimple.core.config.CachingBackendInstanceConfig

render_dir = '.render'
keep_renders = False
dpi = 400
overlay_alpha = 0.1
smoothing = 7
class isimple.core.config.BackendManagerConfig[source]

Bases: isimple.core.config.BackendInstanceConfig

class isimple.core.config.VideoAnalyzerConfig(video_path: Union[str, NoneType] = None, design_path: Union[str, NoneType] = None, frame_interval_setting: Union[isimple.core.config.FrameIntervalSetting, str] = '', dt: Union[float, NoneType] = 5.0, Nf: Union[int, NoneType] = 100, height: float = 0.000153, video: Union[isimple.core.config.VideoFileHandlerConfig, dict, NoneType] = None, design: Union[isimple.core.config.DesignFileHandlerConfig, dict, NoneType] = None, transform: Union[isimple.core.config.TransformHandlerConfig, dict, NoneType] = None, masks: Tuple[Union[isimple.core.config.MaskConfig, dict, NoneType], ...] = (None,), features: Tuple[Union[isimple.core.config.VideoFeatureType, str], ...] = ('',))[source]

Bases: isimple.core.config.BackendManagerConfig

video_path = None
design_path = None
frame_interval_setting = ''
dt = 5.0
Nf = 100
height = 0.000153
video = None
design = None
transform = None
masks = (None,)
features = ('',)
isimple.core.config.load(path: str) → isimple.core.config.VideoAnalyzerConfig[source]
isimple.core.config.dump(config: isimple.core.config.VideoAnalyzerConfig, path: str)[source]
isimple.core.config.dumps(config: isimple.core.config.VideoAnalyzerConfig) → str[source]

isimple.core.endpoints module

class isimple.core.endpoints.BackendRegistry(endpoints: isimple.core.common.InstanceRegistry = None)[source]

Bases: isimple.core.common.ImmutableRegistry

get_config = <isimple.core.common.Endpoint object>
set_config = <isimple.core.common.Endpoint object>
get_name = <isimple.core.common.Endpoint object>
get_total_frames = <isimple.core.common.Endpoint object>
get_raw_frame = <isimple.core.common.Endpoint object>
set_transform_implementation = <isimple.core.common.Endpoint object>
transform = <isimple.core.common.Endpoint object>
estimate_transform = <isimple.core.common.Endpoint object>
get_coordinates = <isimple.core.common.Endpoint object>
get_mask_name = <isimple.core.common.Endpoint object>
get_mask_names = <isimple.core.common.Endpoint object>
set_filter_implementation = <isimple.core.common.Endpoint object>
set_filter_parameters = <isimple.core.common.Endpoint object>
get_filter_parameters = <isimple.core.common.Endpoint object>
get_filter_mean_color = <isimple.core.common.Endpoint object>
get_overlay = <isimple.core.common.Endpoint object>
get_frame = <isimple.core.common.Endpoint object>
get_masked_frame = <isimple.core.common.Endpoint object>
filter = <isimple.core.common.Endpoint object>
mask = <isimple.core.common.Endpoint object>
get_filtered_frame = <isimple.core.common.Endpoint object>
get_filtered_masked_frame = <isimple.core.common.Endpoint object>
overlay_frame = <isimple.core.common.Endpoint object>
get_overlaid_frame = <isimple.core.common.Endpoint object>
get_inverse_transformed_overlay = <isimple.core.common.Endpoint object>
get_colors = <isimple.core.common.Endpoint object>
get_time = <isimple.core.common.Endpoint object>
get_fps = <isimple.core.common.Endpoint object>
get_h = <isimple.core.common.Endpoint object>
get_dpi = <isimple.core.common.Endpoint object>
class isimple.core.endpoints.GuiRegistry(endpoints: isimple.core.common.InstanceRegistry = None)[source]

Bases: isimple.core.common.ImmutableRegistry

open_setupwindow = <isimple.core.common.Endpoint object>
open_transformwindow = <isimple.core.common.Endpoint object>
open_filterwindow = <isimple.core.common.Endpoint object>
update_filterwindow = <isimple.core.common.Endpoint object>
open_progresswindow = <isimple.core.common.Endpoint object>
update_progresswindow = <isimple.core.common.Endpoint object>

isimple.core.features module

class isimple.core.features.Feature(elements: Tuple[isimple.core.backend.BackendInstance, ...])[source]

Bases: abc.ABC

A feature implements interactions between BackendElements to produce a certain value

calculate(frame: numpy.ndarray, state: numpy.ndarray = None) → Tuple[Any, numpy.ndarray][source]

Calculate Feature for given frame and update state image (optional)

color

Color of the Feature in figures.

A Feature’s color must be set as not to overlap with other Features in the same FeatureSet. Therefore, <Feature>._color must be determined by FeatureSet!

state(frame: numpy.ndarray, state: numpy.ndarray = None) → numpy.ndarray[source]

Return the Feature instance’s state image for a given frame

value(frame: numpy.ndarray) → Any[source]

Compute the value of the Feature instance for a given frame

name() → str[source]

Return the name of the feature

class isimple.core.features.FeatureSet(features: Tuple[isimple.core.features.Feature, ...])[source]

Bases: object

get_colors() → Tuple[isimple.core.config.HsvColor, ...][source]
colors
features

isimple.core.log module

isimple.core.log.vdebug(self, message, *args, **kwargs)[source]
class isimple.core.log.CustomLogger(name, level=0)[source]

Bases: logging.Logger

debug(msg, *args, **kwargs)[source]

Log ‘msg % args’ with severity ‘DEBUG’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.debug(“Houston, we have a %s”, “thorny problem”, exc_info=1)

info(msg, *args, **kwargs)[source]

Log ‘msg % args’ with severity ‘INFO’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.info(“Houston, we have a %s”, “interesting problem”, exc_info=1)

warning(msg, *args, **kwargs)[source]

Log ‘msg % args’ with severity ‘WARNING’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.warning(“Houston, we have a %s”, “bit of a problem”, exc_info=1)

error(msg, *args, **kwargs)[source]

Log ‘msg % args’ with severity ‘ERROR’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.error(“Houston, we have a %s”, “major problem”, exc_info=1)

critical(msg, *args, **kwargs)[source]

Log ‘msg % args’ with severity ‘CRITICAL’.

To pass exception information, use the keyword argument exc_info with a true value, e.g.

logger.critical(“Houston, we have a %s”, “major disaster”, exc_info=1)

vdebug(message, *args, **kwargs)[source]
isimple.core.log.get_logger(name: str = 'isimple.core.log') → isimple.core.log.CustomLogger[source]

isimple.core.schema module

isimple.core.schema.resolve_type_to_most_specific(t: _GenericAlias) → _GenericAlias[source]
Resolve Union in a type annotation to its most specific element
  • Use case:

todo: extend to Optional

Parameters:t
Returns:
isimple.core.schema.get_config_schema(config: Type[isimple.core.config.Config]) → schema.Schema[source]
isimple.core.schema.get_method_schema(method: Callable) → schema.Schema[source]
isimple.core.schema.get_return_schema(method: Callable) → schema.Schema[source]
isimple.core.schema.schema(obj) → dict[source]

isimple.core.util module

isimple.core.util.restrict(val, minval, maxval)[source]

https://stackoverflow.com/questions/4092528

isimple.core.util.rotations(sequence) → list[source]

Returns all rotations of a list.

isimple.core.util.timing(f)[source]

Function decorator to measure elapsed time. :param f: function

isimple.core.util.describe_function(f)[source]
isimple.core.util.bases(c: type) → List[type][source]
isimple.core.util.nbases(c: type) → int[source]
isimple.core.util.all_attributes(t: Union[object, type], include_under: bool = True, include_methods: bool = True, include_mro: bool = False) → List[str][source]
isimple.core.util.all_annotations(t: Union[object, type]) → Dict[str, type][source]
isimple.core.util.get_overridden_methods(c, m) → list[source]
isimple.core.util.frame_number_iterator(total: int, Nf: int = None, dt: float = None, fps: float = None) → Generator[int, None, None][source]
isimple.core.util.before_version(version_a, version_b)[source]

Check whether version_a precedes version_b. Only handles numerics, i.e. no ‘1.25b.3v7’

isimple.core.util.after_version(version_a, version_b)[source]

Module contents