Skip to content

Commit

Permalink
Major refactoring of decoding module, added cached frames indication …
Browse files Browse the repository at this point in the history
…in player
  • Loading branch information
bsekachev committed Jul 30, 2023
1 parent 9554c7d commit aee5c56
Show file tree
Hide file tree
Showing 10 changed files with 414 additions and 736 deletions.
7 changes: 3 additions & 4 deletions cvat-canvas/src/typescript/canvasModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,10 +566,9 @@ export class CanvasModelImpl extends MasterImpl implements CanvasModel {
this.data.objects = objectStates;
this.notify(UpdateReasons.OBJECTS_UPDATED);
})
.catch((exception: any): void => {
this.data.exception = exception;
// don't notify when the frame is no longer needed
if (typeof exception !== 'number' || exception === this.data.imageID) {
.catch((exception: Error | number): void => {
if (typeof exception !== 'number') {
this.data.exception = exception;
this.notify(UpdateReasons.DATA_FAILED);
}
});
Expand Down
755 changes: 216 additions & 539 deletions cvat-core/src/frames.ts

Large diffs are not rendered by default.

337 changes: 145 additions & 192 deletions cvat-data/src/ts/cvat-data.ts

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions cvat-ui/src/actions/annotation-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,7 @@ export function changeFrameAsync(
relatedFiles: currentState.annotation.player.frame.relatedFiles,
delay: currentState.annotation.player.frame.delay,
changeTime: currentState.annotation.player.frame.changeTime,
ranges: currentState.annotation.player.ranges,
states: currentState.annotation.annotations.states,
minZ: currentState.annotation.annotations.zLayer.min,
maxZ: currentState.annotation.annotations.zLayer.max,
Expand All @@ -645,6 +646,8 @@ export function changeFrameAsync(
}

const data = await job.frames.get(toFrame, fillBuffer, frameStep);
const ranges = await job.frames.ranges();
console.log(ranges);
const states = await job.annotations.get(toFrame, showAllInterpolationTracks, filters);

if (!isAbleToChangeFrame() || statisticsVisible || propagateVisible) {
Expand Down Expand Up @@ -695,6 +698,7 @@ export function changeFrameAsync(
curZ: maxZ,
changeTime: currentTime + delay,
delay,
ranges,
},
});
} catch (error) {
Expand Down
22 changes: 21 additions & 1 deletion cvat-ui/src/components/annotation-page/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,35 @@
}
}

.cvat-player-slider {
.cvat-player-slider.ant-slider {
width: 350px;
margin: 0;
margin-top: $grid-unit-size * -0.5;

> .ant-slider-handle {
z-index: 100;
margin-top: -3.5px;
}
> .ant-slider-track {
background: none;
}
> .ant-slider-rail {
height: $grid-unit-size;
background-color: $player-slider-color;
}
}

.cvat-player-slider-progress {
width: 350px;
position: absolute;
top: 0;
pointer-events: none;

> rect {
fill: #ff4136;
}
}

.cvat-player-filename-wrapper {
max-width: $grid-unit-size * 30;
max-height: $grid-unit-size * 3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface Props {
startFrame: number;
stopFrame: number;
playing: boolean;
ranges: string;
frameNumber: number;
frameFilename: string;
frameDeleted: boolean;
Expand All @@ -47,6 +48,7 @@ function PlayerNavigation(props: Props): JSX.Element {
deleteFrameShortcut,
focusFrameInputShortcut,
inputFrameRef,
ranges,
onSliderChange,
onInputChange,
onURLIconClick,
Expand Down Expand Up @@ -105,6 +107,17 @@ function PlayerNavigation(props: Props): JSX.Element {
value={frameNumber || 0}
onChange={onSliderChange}
/>
<svg className='cvat-player-slider-progress' viewBox='0 0 1000 9' xmlns='http://www.w3.org/2000/svg'>
{ranges.split(';').map((range) => {
let [start, end] = range.split(':').map((num) => +num);

Check failure on line 112 in cvat-ui/src/components/annotation-page/top-bar/player-navigation.tsx

View workflow job for this annotation

GitHub Actions / Linter

'end' is never reassigned. Use 'const' instead
start = Math.max(0, start - 1);
const totalSegments = stopFrame - startFrame;
const segmentWidth = 1000 / totalSegments;
const width = Math.max((end - start), 1) * segmentWidth;
const offset = (Math.max((start - startFrame), 0) / totalSegments) * 1000;
return (<rect x={offset} y={0} height={9} width={width} />);
})}
</svg>
</Col>
</Row>
<Row justify='center'>
Expand Down
3 changes: 3 additions & 0 deletions cvat-ui/src/components/annotation-page/top-bar/top-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ interface Props {
onRestoreFrame(): void;
switchNavigationBlocked(blocked: boolean): void;
jobInstance: any;
ranges: string;
}

export default function AnnotationTopBarComponent(props: Props): JSX.Element {
Expand All @@ -77,6 +78,7 @@ export default function AnnotationTopBarComponent(props: Props): JSX.Element {
undoAction,
redoAction,
playing,
ranges,
frameNumber,
frameFilename,
frameDeleted,
Expand Down Expand Up @@ -168,6 +170,7 @@ export default function AnnotationTopBarComponent(props: Props): JSX.Element {
startFrame={startFrame}
stopFrame={stopFrame}
playing={playing}
ranges={ranges}
frameNumber={frameNumber}
frameFilename={frameFilename}
frameDeleted={frameDeleted}
Expand Down
5 changes: 5 additions & 0 deletions cvat-ui/src/containers/annotation-page/top-bar/top-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ interface StateToProps {
normalizedKeyMap: Record<string, string>;
canvasInstance: Canvas | Canvas3d;
forceExit: boolean;
ranges: string;
activeControl: ActiveControl;
}

Expand All @@ -91,6 +92,7 @@ function mapStateToProps(state: CombinedState): StateToProps {
annotation: {
player: {
playing,
ranges,
frame: {
data: { deleted: frameIsDeleted },
filename: frameFilename,
Expand Down Expand Up @@ -142,6 +144,7 @@ function mapStateToProps(state: CombinedState): StateToProps {
canvasInstance,
forceExit,
activeControl,
ranges: ranges.join(';'),
};
}

Expand Down Expand Up @@ -638,6 +641,7 @@ class AnnotationTopBarContainer extends React.PureComponent<Props, State> {
workspace,
canvasIsReady,
keyMap,
ranges,
normalizedKeyMap,
activeControl,
searchAnnotations,
Expand Down Expand Up @@ -766,6 +770,7 @@ class AnnotationTopBarContainer extends React.PureComponent<Props, State> {
workspace={workspace}
playing={playing}
saving={saving}
ranges={ranges}
startFrame={startFrame}
stopFrame={stopFrame}
frameNumber={frameNumber}
Expand Down
3 changes: 3 additions & 0 deletions cvat-ui/src/reducers/annotation-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ const defaultState: AnnotationState = {
delay: 0,
changeTime: null,
},
ranges: [],
playing: false,
frameAngles: [],
navigationBlocked: false,
Expand Down Expand Up @@ -275,12 +276,14 @@ export default (state = defaultState, action: AnyAction): AnnotationState => {
maxZ,
curZ,
delay,
ranges,
changeTime,
} = action.payload;
return {
...state,
player: {
...state.player,
ranges,
frame: {
data,
filename,
Expand Down
1 change: 1 addition & 0 deletions cvat-ui/src/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -692,6 +692,7 @@ export interface AnnotationState {
delay: number;
changeTime: number | null;
};
ranges: string[];
navigationBlocked: boolean;
playing: boolean;
frameAngles: number[];
Expand Down

0 comments on commit aee5c56

Please sign in to comment.