isimple.core package¶
Submodules¶
isimple.core.backend module¶
-
exception
isimple.core.backend.BackendSetupError(*args)[source]¶ Bases:
isimple.core.SetupError-
msg= 'Error while setting up backend'¶
-
-
exception
isimple.core.backend.BackendError(*args)[source]¶ Bases:
isimple.core.RootException-
msg= 'Error in backend'¶
-
-
exception
isimple.core.backend.CacheAccessError(*args)[source]¶ Bases:
isimple.core.RootException-
msg= 'Trying to access cache out of context'¶
-
-
class
isimple.core.backend.CachingInstance(config: isimple.core.config.BaseConfig = None)[source]¶ Bases:
isimple.core.config.InstanceInterface to diskcache.Cache
-
class
isimple.core.backend.FeatureConfig[source]¶ Bases:
isimple.core.config.BaseConfig,abc.ABC
-
class
isimple.core.backend.Feature(elements: Tuple[isimple.core.config.Instance, ...], global_config: isimple.core.backend.FeatureConfig, config: Optional[dict] = None)[source]¶ Bases:
abc.ABC,isimple.core.config.ConfigurableA feature implements interactions between BackendElements to produce a certain value
-
calculate(frame: numpy.ndarray, state: numpy.ndarray = None) → Tuple[Any, Optional[numpy.ndarray]][source]¶ Calculate Feature for given frame and update state image (optional)
-
skip¶
-
ready¶
-
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) → 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
-
config¶
-
-
class
isimple.core.backend.FeatureSet(features: Tuple[isimple.core.backend.Feature, ...])[source]¶ Bases:
object-
colors¶
-
features¶
-
-
class
isimple.core.backend.FeatureType(string: str = None)[source]¶ Bases:
isimple.core.config.Factory
-
class
isimple.core.backend.AnalyzerEvent[source]¶ Bases:
enum.EnumAn enumeration.
-
STATUS= 'status'¶
-
CONFIG= 'config'¶
-
RESULT= 'result'¶
-
RMETAD= 'result_metadata'¶
-
-
class
isimple.core.backend.AnalyzerState[source]¶ Bases:
enum.IntEnumAn enumeration.
-
UNKNOWN= 0¶
-
INCOMPLETE= 1¶
-
CAN_LAUNCH= 2¶
-
LAUNCHED= 3¶
-
CAN_FILTER= 4¶
-
CAN_ANALYZE= 5¶
-
ANALYZING= 6¶
-
DONE= 7¶
-
CANCELED= 8¶
-
ERROR= 9¶
-
-
class
isimple.core.backend.BaseVideoAnalyzer(config: isimple.core.backend.BaseAnalyzerConfig = None, eventstreamer: isimple.core.streaming.EventStreamer = None)[source]¶ Bases:
isimple.core.config.Instance,isimple.core.RootInstance-
model¶
-
eventstreamer¶
-
event(category: isimple.core.backend.AnalyzerEvent, data: dict)[source]¶ Push an event
Parameters: - category – event category
- data – event data
Returns:
-
launched¶
-
state¶
-
done¶
-
busy¶
-
busy_context(busy_state: isimple.core.backend.AnalyzerState = None, done_state: isimple.core.backend.AnalyzerState = None)[source]¶
-
progress¶
-
config¶
-
position¶
-
cached¶
-
has_results¶
-
caching()[source]¶ Caching context: propagated context to every object in _instances that implements caching
-
timing¶
-
description¶
-
isimple.core.config module¶
-
class
isimple.core.config.Factory(string: str = None)[source]¶ Bases:
isimple.core.EnforcedStr-
options¶
-
descriptions¶
-
default¶
-
-
class
isimple.core.config.extend(factory: Type[isimple.core.config.Factory], key: Optional[str] = None)[source]¶ Bases:
object
-
class
isimple.core.config.BaseConfig[source]¶ Bases:
pydantic.main.BaseModel,isimple.core.DescribedAbstract class for configuration data.
- Usage, where SomeConfig is a subclass of BaseConfig:
- Writing BaseConfig subclasses:
- Use the @extends(ConfigType) decorator to make your configuration
- class accessible from the ConfigType Factory (defined below)
- Configuration keys are declared as pydantic Field instances
- Must be type-annotated for type resolution to work properly!
- ```
from pydantic import Field from isimple.core.config import BaseConfig
@extend(ConfigType) class SomeConfig(BaseConfig):
field1: int = Field(default=42) field2: SomeNestedConfig = Field(default_factory=SomeOtherConfig)
-
class
Config[source]¶ Bases:
objectpydantic configuration class
-
arbitrary_types_allowed= False¶
-
use_enum_value= True¶
-
validate_assignment= True¶
-
json_encoders= {<class 'numpy.ndarray'>: <class 'list'>}¶
-
-
class
isimple.core.config.ConfigType(string: str = None)[source]¶ Bases:
isimple.core.config.Factory
-
class
isimple.core.config.Configurable[source]¶ Bases:
isimple.core.Described
-
class
isimple.core.config.Instance(config: isimple.core.config.BaseConfig = None)[source]¶ Bases:
isimple.core.config.Configurable-
config¶
-
isimple.core.db module¶
-
class
isimple.core.db.SessionWrapper[source]¶ Bases:
objectWrapper object for a SQLAlchemy session factory.
-
class
isimple.core.db.DbModel(**kwargs)[source]¶ Bases:
sqlalchemy.ext.declarative.api.Base,isimple.core.db.SessionWrapperAbstract database model class.
Subclasses should
-
session(add: bool = True)[source]¶ SQLAlchemy session context manager.
Opens a SQLAlchemy session and commits after the block is done. Changes are rolled back if an exception is raised. Usage:
with self.session() as s: # interact with the database here
Calls
DbModel._pre()before yielding the session andDbModel._post()after the block is completed.Parameters: add (bool) – add model(s) after opening the session
-
-
class
isimple.core.db.FileModel(path: str)[source]¶ Bases:
isimple.core.db.DbModelAbstrat database model for files.
Files are hashed and resolved in order to keep a single entry per file.
-
id= Column(None, Integer(), table=None, primary_key=True, nullable=False)¶
-
hash= Column(None, String(), table=None)¶
-
path= Column(None, String(), table=None)¶
-
used= Column(None, DateTime(), table=None)¶
-
resolved¶ Whether the
FileModelhas been resolved.
-
resolve() → isimple.core.db.FileModel[source]¶ Resolve the file by its SHA1 hash. todo: reference to util.hash_file
If the computed hash is new, the file is committed to the database. Otherwise, the original entry is re-used.
Returns: The current instance if the file is new, or a new FileModelinstance representing the original database entry.Return type: FileModel
-
-
class
isimple.core.db.BaseAnalysisModel(**kwargs)[source]¶ Bases:
isimple.core.db.DbModelAnalysisModel interface
-
load_config(video_path: str, design_path: str = None, include: List[str] = None) → Optional[dict][source]¶ Load configuration from the database
-
undo_config(context: str = None) → Optional[dict][source]¶ Undo configuration. If a
contextis supplied, ensure that thecontextfield changes, but the other fields remain the same
-
isimple.core.interface module¶
-
class
isimple.core.interface.InterfaceFactory(string: str = None)[source]¶ Bases:
isimple.core.config.Factory
-
class
isimple.core.interface.HandlerConfig[source]¶ Bases:
isimple.core.config.BaseConfig,abc.ABC
-
class
isimple.core.interface.TransformConfig[source]¶ Bases:
isimple.core.config.BaseConfigUndefined transform
-
class
isimple.core.interface.TransformInterface[source]¶ Bases:
isimple.core.config.Configurable,abc.ABC-
estimate(roi: isimple.maths.coordinates.Roi, from_shape: tuple, to_shape: tuple) → numpy.ndarray[source]¶
-
-
class
isimple.core.interface.FilterConfig[source]¶ Bases:
isimple.core.config.BaseConfigUndefined filter
-
ready¶ Return true if filter can be applied ~ this configuration. Override for specific filter implementations
-
-
class
isimple.core.interface.FilterInterface[source]¶ Bases:
isimple.core.config.Configurable,abc.ABCHandles pixel filtering operations
isimple.core.streaming module¶
-
class
isimple.core.streaming.StreamHandler[source]¶ Bases:
isimple.core.LockableA singleton object to handle streaming frames from methods
Module contents¶
-
exception
isimple.core.SetupError(*args)[source]¶ Bases:
isimple.core.RootException
-
class
isimple.core.EnforcedStr(string: str = None)[source]¶ Bases:
str-
options¶
-
descriptions¶
-
describe¶
-
default¶
-
-
class
isimple.core.Endpoint(signature: _GenericAlias, streaming: isimple.core._Streaming = <_Streaming 'off'>)[source]¶ Bases:
object-
signature¶
-
streaming¶
-
registered¶
-
name¶
-
-
class
isimple.core.InstanceRegistry[source]¶ Bases:
isimple.core.EndpointRegistryThis one is global, collects callables that expose endpoints
-
endpoints¶
-
-
class
isimple.core.ImmutableRegistry(endpoints: isimple.core.InstanceRegistry = None)[source]¶ Bases:
isimple.core.EndpointRegistry-
endpoints¶
-