Video Sequence Matching
py_fort_myrmidon.VideoSegment
- class py_fort_myrmidon.VideoSegment
A VideoSegment represents a part of a Video file with its associated tracking data.
VideoSegment are most often queried with
Query.FindVideoSegments()
. Once queried, they are blank, i.e. no query results will appears inVideoSegment.Data
. One would callMatch()
to associate queries results with these segments. Finally aVideoSequence
context manager can be used to iterate over each video frame of theVideoSegmentList
.Note
Query.FindVideoSegment()
,Match()
andVideoSequence
use aVideoSegmentList
as return value or arguments. Indeed it could happen that the desired sequence of images span over multiple video file.Example
import py_fort_myrmidon as fm e = fm.Experiment.Open("file.myrmidon") # note it would be extremly computationally intensive to # iterate over the whole experiment, we select a time region. start = fm.Time.Parse('2019-11-02T20:00:00.000Z') end = start.Add(30 * fm.Duration.Second) ## step 0: make some query on the experiment trajectories = fm.Query.ComputeAntTrajectories(e,start=start,end=end) ## step 1: look up segments bet segments = fm.Query.FindVideoSegments(e, space = 1, start = start, end = end) ## step 2: match queried data with video frames fm.VideoSegment.Match(segments,trajectories) ## step 3: iterate over all video frame and matched data with fm.VideoSequence(segments) as sequence: for frame,data in sequence: ## step 3.1 on each cv2.Mat `frame` do something based ## on `data` pass
- property Begin
the first video frame position in the video file corresponding to the segment
- Type:
- property Data
matched query result with the video frame in the list. If no tracking data is associated with a given frame, there will be no corresponding object in this field.
- Type:
List[VideoFrameData]
- property End
the last+1 video frame postion in the video file corresponding to the segment
- Type:
- static Match(*args, **kwargs)
Overloaded function.
Match(segments: py_fort_myrmidon.VideoSegmentList, identifiedFrames: List[py_fort_myrmidon.IdentifiedFrame]) -> None
Matches
IdentifiedFrame
with aVideoSegmentList
- Parameters:
segments (VideoSegmentList) – the segments to associate data with
identifiedFrames (List[IdentifiedFrame]) – the IdentifiedFrames to match with segments.
- Raises:
ValueError – if the all segments are not from the same
Space
Match(segments: py_fort_myrmidon.VideoSegmentList, collisionData: List[Tuple[py_fort_myrmidon.IdentifiedFrame, py_fort_myrmidon.CollisionFrame]]) -> None
Matches
CollisionData
with aVideoSegmentList
- Parameters:
segments (VideoSegmentList) – the segments to associate data with
collisionData (List[CollisionData]) – the CollisionData to match with segments.
- Raises:
ValueError – if the all segments are not from the same
Space
Match(segments: py_fort_myrmidon.VideoSegmentList, trajectories: List[py_fort_myrmidon.AntTrajectory]) -> None
Matches
AntTrajectory
with aVideoSegmentList
- Parameters:
segments (VideoSegmentList) – the segments to associate data with
trajectories (List[AntTrajectory]) – the AntTrajectories to match with segments.
- Raises:
ValueError – if the all segments are not from the same
Space
Match(segments: py_fort_myrmidon.VideoSegmentList, interactions: List[py_fort_myrmidon.AntInteraction]) -> None
Matches
AntInteraction
with aVideoSegmentList
- Parameters:
segments (VideoSegmentList) – the segments to associate data with
interactions (List[AntInteraction]) – the AntInteractions to match with segments.
- Raises:
ValueError – if the all segments are not from the same
Space
py_fort_myrmidon.VideoSegmentList
- class py_fort_myrmidon.VideoSegmentList
An opaque list of
VideoSegment
.It works just as a
list
ofVideoSegment
.- append(self: py_fort_myrmidon.VideoSegmentList, x: py_fort_myrmidon.VideoSegment) None
Add an item to the end of the list
- clear(self: py_fort_myrmidon.VideoSegmentList) None
Clear the contents
- deepcopy(self: py_fort_myrmidon.VideoSegmentList) py_fort_myrmidon.VideoSegmentList
Performs a deepcopy of the list.
The main purpose is for the unittest implementation.
- extend(*args, **kwargs)
Overloaded function.
extend(self: py_fort_myrmidon.VideoSegmentList, L: py_fort_myrmidon.VideoSegmentList) -> None
Extend the list by appending all the items in the given list
extend(self: py_fort_myrmidon.VideoSegmentList, L: Iterable) -> None
Extend the list by appending all the items in the given list
- insert(self: py_fort_myrmidon.VideoSegmentList, i: int, x: py_fort_myrmidon.VideoSegment) None
Insert an item at a given position.
- pop(*args, **kwargs)
Overloaded function.
pop(self: py_fort_myrmidon.VideoSegmentList) -> py_fort_myrmidon.VideoSegment
Remove and return the last item
pop(self: py_fort_myrmidon.VideoSegmentList, i: int) -> py_fort_myrmidon.VideoSegment
Remove and return the item at index
i
py_fort_myrmidon.VideoFrameData
- class py_fort_myrmidon.VideoFrameData
The tracking data and query results associated with a Video frame.
Note
After a call to
Query.FindMovieSegments()
this structure will contain no matched data. One must callVideoSequence.Match()
to associate query results with theVideoFrameData
present in theVideoSegmentList
.Warning
In the unlikely case of a
VideoFrameData
without any tracking data ( the movie frame was exported but no tracking was reported ), the value ofVideoFrameData.Time
will be set toTime.SinceEver()
and all other query result field will be set to None.- property Collided
the ants collision (if previously matched)
- Type:
- Empty(self: py_fort_myrmidon.VideoFrameData) bool
Indicates the (unlikely) case where no tracking data is associated with this video frame.
- Returns:
True if there is no tracking data (even a timeout / frame drop report) associated with this video frame.
- Return type:
- property Identified
the ants position (if previously matched)
- Type:
- property Interactions
the interactions in this frame (if previously matched)
- Type:
List[AntInteraction]
- property Trajectories
the trajectories in this frame (if previously matched)
- Type:
List[AntTrajectory]
py_fort_myrmidon.VideoSequence
- class py_fort_myrmidon.VideoSequence
A contextmanager for iterating over Video Frame and matched data.
Examples
import py_fort_myrmidon as fm ## will iterate over all video frame of space 1 segments = fm.Query.FindVideoSegments(e,space = 1) with fm.VideoSequence(segments) as sequence: for frame, data in sequence: pass