@@ -70,9 +70,9 @@ class LineCounterManifest(WorkflowBlockManifest):
7070 description = "Line consisting of exactly two points. For line [[0, 100], [100, 100]], objects entering from the bottom will count as IN." ,
7171 examples = [[[0 , 50 ], [500 , 50 ]], "$inputs.zones" ],
7272 )
73- triggering_anchor : Union [str , Selector (kind = [STRING_KIND ]), Literal [tuple (sv .Position .list ())]] = Field ( # type: ignore
73+ triggering_anchor : Optional [ Union [str , Selector (kind = [STRING_KIND ]), Literal [tuple (sv .Position .list ())] ]] = Field ( # type: ignore
7474 description = f"The point on the detection that must cross the line to be counted." ,
75- default = "CENTER" ,
75+ default = None ,
7676 examples = ["CENTER" ],
7777 )
7878
@@ -121,7 +121,7 @@ def run(
121121 detections : sv .Detections ,
122122 image : WorkflowImageData ,
123123 line_segment : List [Tuple [int , int ]],
124- triggering_anchor : str = "CENTER" ,
124+ triggering_anchor : Optional [ str ] = None ,
125125 ) -> BlockResult :
126126 if detections .tracker_id is None :
127127 raise ValueError (
@@ -144,11 +144,17 @@ def run(
144144 raise ValueError (
145145 f"{ self .__class__ .__name__ } requires each coordinate of line zone to be a number"
146146 )
147- self ._batch_of_line_zones [metadata .video_identifier ] = sv .LineZone (
148- start = sv .Point (* line_segment [0 ]),
149- end = sv .Point (* line_segment [1 ]),
150- triggering_anchors = [sv .Position (triggering_anchor )],
151- )
147+ if triggering_anchor is not None :
148+ self ._batch_of_line_zones [metadata .video_identifier ] = sv .LineZone (
149+ start = sv .Point (* line_segment [0 ]),
150+ end = sv .Point (* line_segment [1 ]),
151+ triggering_anchors = [sv .Position (triggering_anchor )],
152+ )
153+ else :
154+ self ._batch_of_line_zones [metadata .video_identifier ] = sv .LineZone (
155+ start = sv .Point (* line_segment [0 ]),
156+ end = sv .Point (* line_segment [1 ]),
157+ )
152158 line_zone = self ._batch_of_line_zones [metadata .video_identifier ]
153159
154160 mask_in , mask_out = line_zone .trigger (detections = detections )
0 commit comments