Skip to content

Marks

Base classes

Name Children Inherits
BaseModel
pydantic.main
!!! abstract "Usage Documentation"

⋔ Inheritance diagram

graph TD
  3031477309["models.Marks"]
  3879467795["main.BaseModel"]
  2751680898["builtins.object"]
  3879467795 --> 3031477309
  2751680898 --> 3879467795

🛈 DocStrings

Bases: BaseModel

Annotations drawn onto video tiles and the timeline (--marks marks.json).

Times are seconds of the media; coordinates are fractions (0-1) of the video frame, or pixels of frame if given.

Source code in src/framesheet/models.py
class Marks(BaseModel):
    """Annotations drawn onto video tiles and the timeline (``--marks marks.json``).

    Times are seconds of the media; coordinates are fractions (0-1) of the video frame,
    or pixels of ``frame`` if given.
    """

    model_config = ConfigDict(extra="forbid", strict=True)
    frame: MarkFrame | None = None
    points: list[MarkPoint] = Field(default_factory=list)
    regions: list[MarkRegion] = Field(default_factory=list)
    spans: list[MarkSpan] = Field(default_factory=list)

    @model_validator(mode="after")
    def _coordinates(self) -> Any:
        fw, fh = (self.frame.width, self.frame.height) if self.frame else (1.0, 1.0)
        for kind, items in (("points", self.points), ("regions", self.regions)):
            for i, item in enumerate(items):
                _check_xy(f"{kind}[{i}]", item, fw, fh)
        for i, item in enumerate(self.spans):
            _check_xy(f"spans[{i}]", item, fw, fh)
        return self

    def norm(self, x: float, y: float) -> tuple[float, float]:
        """A position as fractions of the frame."""
        if self.frame:
            return x / self.frame.width, y / self.frame.height
        return x, y

norm

norm(x: float, y: float) -> tuple[float, float]

A position as fractions of the frame.

Source code in src/framesheet/models.py
def norm(self, x: float, y: float) -> tuple[float, float]:
    """A position as fractions of the frame."""
    if self.frame:
        return x / self.frame.width, y / self.frame.height
    return x, y

:fa-brands-github: Show source on GitHub