Skip to content

Commit 6be9441

Browse files
authored
Merge pull request #8 from clamsproject/bbox_union
timepoint rework
2 parents 458f9e5 + e63c34c commit 6be9441

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

app.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import argparse
22
import logging
3-
from typing import Union
3+
from typing import Union, Sequence
44

55
import cv2
6+
import itertools
67
import numpy as np
78
from clams import ClamsApp, Restifier
89
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
8081
bb_annotation = new_view.new_annotation(AnnotationTypes.BoundingBox)
8182
tp = vdh.convert(time=fn, in_unit='frame', out_unit=config['timeUnit'], fps=videodocument.get_property("fps"))
8283
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)
8490
bb_annotation.add_property("boxType", "text")
8591
x0, y0, x1, y1 = box
8692
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+
8798
return mmif
8899

100+
101+
89102
if __name__ == "__main__":
90103
parser = argparse.ArgumentParser()
91104
parser.add_argument("--port", action="store", default="5000", help="set port to listen" )

metadata.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ def appmetadata() -> AppMetadata:
4747
metadata.add_parameter(
4848
name="stopAt",
4949
type="integer",
50-
default="2 * 60 * 60 * 30", # ~2 hours of video at 30fps
50+
default=108000, # ~2 hours of video at 30fps 1 * 60 * 60 * 30
5151
description="Frame number to stop running. Only works with VideoDocument input. The default is roughly 2 hours of video at 30fps.",
5252
)
53-
53+
metadata.add_parameter(
54+
name="mergeBoxes",
55+
type="boolean",
56+
default=False,
57+
description="if True, creates a single merged bounding box from all detected boxes."
58+
)
5459
return metadata
5560

5661

0 commit comments

Comments
 (0)