@ -65,6 +65,28 @@ describe('Feature: get annotations', () => {
expect ( annotations ) . toHaveLength ( 1 ) ;
expect ( annotations [ 0 ] . shapeType ) . toBe ( 'ellipse' ) ;
} ) ;
test ( 'get skeletons with a filter' , async ( ) => {
const job = ( await window . cvat . jobs . get ( { jobID : 40 } ) ) [ 0 ] ;
const annotations = await job . annotations . get ( 0 , false , JSON . parse ( '[{"and":[{"==":[{"var":"shape"},"skeleton"]}]}]' ) ) ;
expect ( Array . isArray ( annotations ) ) . toBeTruthy ( ) ;
expect ( annotations ) . toHaveLength ( 2 ) ;
for ( const object of annotations ) {
expect ( object . shapeType ) . toBe ( 'skeleton' ) ;
expect ( object . elements ) . toBeInstanceOf ( Array ) ;
const label = object . label ;
let points = [ ] ;
object . elements . forEach ( ( element , idx ) => {
expect ( element ) . toBeInstanceOf ( cvat . classes . ObjectState ) ;
expect ( element . label . id ) . toBe ( label . structure . sublabels [ idx ] . id ) ;
expect ( element . shapeType ) . toBe ( 'points' ) ;
points = [ ... points , ... element . points ] ;
} ) ;
expect ( points ) . toEqual ( object . points ) ;
}
expect ( annotations [ 0 ] . shapeType ) . toBe ( 'skeleton' ) ;
} )
} ) ;
describe ( 'Feature: get interpolated annotations' , ( ) => {
@ -351,6 +373,68 @@ describe('Feature: put annotations', () => {
zOrder : 0 ,
} ) ) . toThrow ( window . cvat . exceptions . ArgumentError ) ;
} ) ;
test ( 'put a skeleton shape to a job' , async ( ) => {
const job = ( await window . cvat . jobs . get ( { jobID : 40 } ) ) [ 0 ] ;
const label = job . labels [ 0 ] ;
await job . annotations . clear ( true ) ;
await job . annotations . clear ( ) ;
const skeleton = new window . cvat . classes . ObjectState ( {
frame : 0 ,
objectType : window . cvat . enums . ObjectType . SHAPE ,
shapeType : window . cvat . enums . ShapeType . SKELETON ,
points : [ ] ,
label ,
elements : label . structure . sublabels . map ( ( sublabel , idx ) => ( {
frame : 0 ,
objectType : window . cvat . enums . ObjectType . SHAPE ,
shapeType : window . cvat . enums . ShapeType . POINTS ,
points : [ idx * 10 , idx * 10 ] ,
label : sublabel ,
} ) )
} ) ;
await job . annotations . put ( [ skeleton ] ) ;
const annotations = await job . annotations . get ( 0 ) ;
expect ( annotations . length ) . toBe ( 1 ) ;
expect ( annotations [ 0 ] . objectType ) . toBe ( window . cvat . enums . ObjectType . SHAPE ) ;
expect ( annotations [ 0 ] . shapeType ) . toBe ( window . cvat . enums . ShapeType . SKELETON ) ;
for ( const element of annotations [ 0 ] . elements ) {
expect ( element . objectType ) . toBe ( window . cvat . enums . ObjectType . SHAPE ) ;
expect ( element . shapeType ) . toBe ( window . cvat . enums . ShapeType . POINTS ) ;
}
} ) ;
test ( 'put a skeleton track to a task' , async ( ) => {
const task = ( await window . cvat . tasks . get ( { id : 40 } ) ) [ 0 ] ;
const label = task . labels [ 0 ] ;
await task . annotations . clear ( true ) ;
await task . annotations . clear ( ) ;
const skeleton = new window . cvat . classes . ObjectState ( {
frame : 0 ,
objectType : window . cvat . enums . ObjectType . TRACK ,
shapeType : window . cvat . enums . ShapeType . SKELETON ,
points : [ ] ,
label ,
elements : label . structure . sublabels . map ( ( sublabel , idx ) => ( {
frame : 0 ,
objectType : window . cvat . enums . ObjectType . TRACK ,
shapeType : window . cvat . enums . ShapeType . POINTS ,
points : [ idx * 10 , idx * 10 ] ,
label : sublabel ,
} ) )
} ) ;
await task . annotations . put ( [ skeleton ] ) ;
const annotations = await task . annotations . get ( 2 ) ;
expect ( annotations . length ) . toBe ( 1 ) ;
expect ( annotations [ 0 ] . objectType ) . toBe ( window . cvat . enums . ObjectType . TRACK ) ;
expect ( annotations [ 0 ] . shapeType ) . toBe ( window . cvat . enums . ShapeType . SKELETON ) ;
for ( const element of annotations [ 0 ] . elements ) {
expect ( element . objectType ) . toBe ( window . cvat . enums . ObjectType . TRACK ) ;
expect ( element . shapeType ) . toBe ( window . cvat . enums . ShapeType . POINTS ) ;
}
} ) ;
} ) ;
describe ( 'Feature: check unsaved changes' , ( ) => {
@ -772,6 +856,21 @@ describe('Feature: get statistics', () => {
expect ( statistics ) . toBeInstanceOf ( window . cvat . classes . Statistics ) ;
expect ( statistics . total . total ) . toBe ( 1012 ) ;
} ) ;
test ( 'get statistics from a job with skeletons' , async ( ) => {
const job = ( await window . cvat . jobs . get ( { jobID : 40 } ) ) [ 0 ] ;
await job . annotations . clear ( true ) ;
const statistics = await job . annotations . statistics ( ) ;
expect ( statistics ) . toBeInstanceOf ( window . cvat . classes . Statistics ) ;
expect ( statistics . total . total ) . toBe ( 30 ) ;
const labelName = job . labels [ 0 ] . name ;
expect ( statistics . label [ labelName ] . skeleton . shape ) . toBe ( 1 ) ;
expect ( statistics . label [ labelName ] . skeleton . track ) . toBe ( 1 ) ;
expect ( statistics . label [ labelName ] . manually ) . toBe ( 2 ) ;
expect ( statistics . label [ labelName ] . interpolated ) . toBe ( 3 ) ;
expect ( statistics . label [ labelName ] . total ) . toBe ( 5 ) ;
} ) ;
} ) ;
describe ( 'Feature: select object' , ( ) => {