@@ -426,6 +426,42 @@ def from_common(cls, segment):
426
426
)
427
427
428
428
429
+ class NDSegments (NDBaseObject ):
430
+ segments : List [NDSegment ]
431
+
432
+ def to_common (self , name : str , feature_schema_id : Cuid ):
433
+ result = []
434
+ for idx , segment in enumerate (self .segments ):
435
+ result .extend (
436
+ segment .to_common (
437
+ name = name ,
438
+ feature_schema_id = feature_schema_id ,
439
+ segment_index = idx ,
440
+ uuid = self .uuid ,
441
+ )
442
+ )
443
+ return result
444
+
445
+ @classmethod
446
+ def from_common (
447
+ cls ,
448
+ segments : List [VideoObjectAnnotation ],
449
+ data : GenericDataRowData ,
450
+ name : str ,
451
+ feature_schema_id : Cuid ,
452
+ extra : Dict [str , Any ],
453
+ ) -> "NDSegments" :
454
+ segments = [NDSegment .from_common (segment ) for segment in segments ]
455
+
456
+ return cls (
457
+ segments = segments ,
458
+ data_row = DataRow (id = data .uid , global_key = data .global_key ),
459
+ name = name ,
460
+ schema_id = feature_schema_id ,
461
+ uuid = extra .get ("uuid" ),
462
+ )
463
+
464
+
429
465
class _URIMask (BaseModel ):
430
466
instanceURI : str
431
467
colorRGB : Tuple [int , int , int ]
@@ -693,7 +729,18 @@ def from_common(
693
729
obj = cls .lookup_object (annotation )
694
730
695
731
# if it is video segments
696
- if obj == NDVideoMasks :
732
+ if obj == NDSegments :
733
+ first_video_annotation = annotation [0 ][0 ]
734
+ args = dict (
735
+ segments = annotation ,
736
+ data = data ,
737
+ name = first_video_annotation .name ,
738
+ feature_schema_id = first_video_annotation .feature_schema_id ,
739
+ extra = first_video_annotation .extra ,
740
+ )
741
+
742
+ return obj .from_common (** args )
743
+ elif obj == NDVideoMasks :
697
744
return obj .from_common (annotation , data )
698
745
699
746
subclasses = [
0 commit comments