|
1 | 1 | import argparse
|
2 | 2 | import logging
|
3 |
| -from typing import Union |
| 3 | +from typing import Union, Sequence |
4 | 4 |
|
5 | 5 | import cv2
|
| 6 | +import itertools |
6 | 7 | import numpy as np
|
7 | 8 | from clams import ClamsApp, Restifier
|
8 | 9 | from mmif import Mmif, DocumentTypes, View, AnnotationTypes, Document
|
@@ -80,12 +81,24 @@ def run_on_video(self, mmif: Mmif, videodocument: Document, new_view: View, **co
|
80 | 81 | bb_annotation = new_view.new_annotation(AnnotationTypes.BoundingBox)
|
81 | 82 | tp = vdh.convert(time=fn, in_unit='frame', out_unit=config['timeUnit'], fps=videodocument.get_property("fps"))
|
82 | 83 | self.logger.debug(f"Adding a timepoint at frame: {fn} >> {tp}")
|
83 |
| - bb_annotation.add_property("timePoint", tp) |
| 84 | + |
| 85 | + tp_annotation = new_view.new_annotation(AnnotationTypes.TimePoint) |
| 86 | + tp_annotation.add_property("timeUnit", config["timeUnit"]) |
| 87 | + tp_annotation.add_property("timePoint", tp) |
| 88 | + |
| 89 | + #bb_annotation.add_property("timePoint", tp) |
84 | 90 | bb_annotation.add_property("boxType", "text")
|
85 | 91 | x0, y0, x1, y1 = box
|
86 | 92 | bb_annotation.add_property("coordinates", [[x0, y0], [x1, y0], [x0, y1], [x1, y1]])
|
| 93 | + |
| 94 | + alignment_annotation = new_view.new_annotation(AnnotationTypes.Alignment) |
| 95 | + alignment_annotation.add_property("source", tp_annotation.id) |
| 96 | + alignment_annotation.add_property("target", bb_annotation.id) |
| 97 | + |
87 | 98 | return mmif
|
88 | 99 |
|
| 100 | + |
| 101 | + |
89 | 102 | if __name__ == "__main__":
|
90 | 103 | parser = argparse.ArgumentParser()
|
91 | 104 | parser.add_argument("--port", action="store", default="5000", help="set port to listen" )
|
|
0 commit comments