Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React UI, data streaming: Added displaying filename #1311

Merged
merged 4 commits into from
Mar 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 47 additions & 21 deletions cvat-core/src/frames.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
const PluginRegistry = require('./plugins');
const serverProxy = require('./server-proxy');
const { isBrowser, isNode } = require('browser-or-node');
const { Exception, ArgumentError } = require('./exceptions');
const { Exception, ArgumentError, DataError } = require('./exceptions');

// This is the frames storage
const frameDataCache = {};
Expand All @@ -24,8 +24,28 @@
* @hideconstructor
*/
class FrameData {
constructor(width, height, tid, number, startFrame, stopFrame, decodeForward) {
constructor({
width,
height,
name,
taskID,
frameNumber,
startFrame,
stopFrame,
decodeForward,
}) {
Object.defineProperties(this, Object.freeze({
/**
* @name filename
* @type {string}
* @memberof module:API.cvat.classes.FrameData
* @readonly
* @instance
*/
filename: {
value: name,
writable: false,
},
/**
* @name width
* @type {integer}
Expand All @@ -49,7 +69,7 @@
writable: false,
},
tid: {
value: tid,
value: taskID,
writable: false,
},
/**
Expand All @@ -60,7 +80,7 @@
* @instance
*/
number: {
value: number,
value: frameNumber,
writable: false,
},
startFrame: {
Expand Down Expand Up @@ -297,7 +317,7 @@
});
};

const getFrameSize = (taskID, frame) => {
function getFrameMeta(taskID, frame) {
const { meta, mode } = frameDataCache[taskID];
let size = null;
if (mode === 'interpolation') {
Expand All @@ -311,12 +331,12 @@
size = meta.frames[frame];
}
} else {
throw new ArgumentError(
throw new DataError(
`Invalid mode is specified ${mode}`,
);
}
return size;
};
}

class FrameBuffer {
constructor(size, chunkSize, stopFrame, taskID) {
Expand Down Expand Up @@ -347,15 +367,15 @@
};
for (const frame of this._requestedChunks[chunkIdx].requestedFrames.entries()) {
const requestedFrame = frame[1];
const size = getFrameSize(this._taskID, requestedFrame);
const frameData = new FrameData(
size.width,
size.height,
this._taskID,
requestedFrame,
frameDataCache[this._taskID].startFrame,
frameDataCache[this._taskID].stopFrame,
);
const frameMeta = getFrameMeta(this._taskID, requestedFrame);
const frameData = new FrameData({
...frameMeta,
taskID: this._taskID,
frameNumber: requestedFrame,
startFrame: frameDataCache[this._taskID].startFrame,
stopFrame: frameDataCache[this._taskID].stopFrame,
decodeForward: false,
});

frameData.data().then(() => {
if (!(chunkIdx in this._requestedChunks)
Expand Down Expand Up @@ -452,9 +472,15 @@
}

this._required = frameNumber;
const size = getFrameSize(taskID, frameNumber);
let frame = new FrameData(size.width, size.height, taskID, frameNumber,
frameDataCache[taskID].startFrame, frameDataCache[taskID].stopFrame, !fillBuffer);
const frameMeta = getFrameMeta(taskID, frameNumber);
let frame = new FrameData({
...frameMeta,
taskID,
frameNumber,
startFrame: frameDataCache[taskID].startFrame,
stopFrame: frameDataCache[taskID].stopFrame,
decodeForward: !fillBuffer,
});

if (frameNumber in this._buffer) {
frame = this._buffer[frameNumber];
Expand Down Expand Up @@ -559,9 +585,9 @@
activeChunkRequest: null,
nextChunkRequest: null,
};
const size = getFrameSize(taskID, frame);
const frameMeta = getFrameMeta(taskID, frame);
// actual only for video chunks
frameDataCache[taskID].provider.setRenderSize(size.width, size.height);
frameDataCache[taskID].provider.setRenderSize(frameMeta.width, frameMeta.height);
}

return frameDataCache[taskID].frameBuffer.require(frame, taskID, isPlaying, step);
Expand Down
1 change: 1 addition & 0 deletions cvat-core/src/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@
* @async
* @throws {module:API.cvat.exceptions.PluginError}
* @throws {module:API.cvat.exceptions.ServerError}
* @throws {module:API.cvat.exceptions.DataError}
* @throws {module:API.cvat.exceptions.ArgumentError}
*/

Expand Down
11 changes: 10 additions & 1 deletion cvat-ui/src/actions/annotation-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,13 @@ ThunkAction<Promise<void>, {}, {}, AnyAction> {
payload: {
number: state.annotation.player.frame.number,
data: state.annotation.player.frame.data,
filename: state.annotation.player.frame.filename,
delay: state.annotation.player.frame.delay,
changeTime: state.annotation.player.frame.changeTime,
states: state.annotation.annotations.states,
minZ: state.annotation.annotations.zLayer.min,
maxZ: state.annotation.annotations.zLayer.max,
curZ: state.annotation.annotations.zLayer.cur,
},
});

Expand Down Expand Up @@ -789,9 +795,11 @@ ThunkAction<Promise<void>, {}, {}, AnyAction> {
payload: {
number: toFrame,
data,
filename: data.filename,
states,
minZ,
maxZ,
curZ: maxZ,
changeTime: currentTime + delay,
delay,
},
Expand Down Expand Up @@ -936,20 +944,21 @@ export function getJobAsync(
const colors = [...cvat.enums.colors];

loadJobEvent.close(await jobInfoGenerator(job));

dispatch({
type: AnnotationActionTypes.GET_JOB_SUCCESS,
payload: {
job,
states,
frameNumber,
frameFilename: frameData.filename,
frameData,
colors,
filters,
minZ,
maxZ,
},
});
dispatch(changeFrameAsync(frameNumber, false));
} catch (error) {
dispatch({
type: AnnotationActionTypes.GET_JOB_FAILED,
Expand Down
1 change: 1 addition & 0 deletions cvat-ui/src/components/annotation-page/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
overflow: hidden;
text-overflow: ellipsis;
user-select: none;
word-break: break-all;
}

.cvat-player-frame-url-icon {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ interface Props {
startFrame: number;
stopFrame: number;
frameNumber: number;
frameFilename: string;
inputFrameRef: React.RefObject<InputNumber>;
onSliderChange(value: SliderValue): void;
onInputChange(value: number | undefined): void;
Expand All @@ -31,6 +32,7 @@ function PlayerNavigation(props: Props): JSX.Element {
startFrame,
stopFrame,
frameNumber,
frameFilename,
inputFrameRef,
onSliderChange,
onInputChange,
Expand All @@ -53,8 +55,8 @@ function PlayerNavigation(props: Props): JSX.Element {
</Row>
<Row type='flex' justify='center'>
<Col className='cvat-player-filename-wrapper'>
<Tooltip title='filename.png'>
<Text type='secondary'>filename.png</Text>
<Tooltip title={frameFilename}>
<Text type='secondary'>{frameFilename}</Text>
</Tooltip>
</Col>
<Col offset={1}>
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 @@ -23,6 +23,7 @@ interface Props {
saving: boolean;
savingStatuses: string[];
frameNumber: number;
frameFilename: string;
inputFrameRef: React.RefObject<InputNumber>;
startFrame: number;
stopFrame: number;
Expand Down Expand Up @@ -54,6 +55,7 @@ export default function AnnotationTopBarComponent(props: Props): JSX.Element {
redoAction,
playing,
frameNumber,
frameFilename,
inputFrameRef,
startFrame,
stopFrame,
Expand Down Expand Up @@ -102,6 +104,7 @@ export default function AnnotationTopBarComponent(props: Props): JSX.Element {
startFrame={startFrame}
stopFrame={stopFrame}
frameNumber={frameNumber}
frameFilename={frameFilename}
inputFrameRef={inputFrameRef}
onSliderChange={onSliderChange}
onInputChange={onInputChange}
Expand Down
10 changes: 9 additions & 1 deletion cvat-ui/src/containers/annotation-page/top-bar/top-bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { CombinedState, FrameSpeed, Workspace } from 'reducers/interfaces';
interface StateToProps {
jobInstance: any;
frameNumber: number;
frameFilename: string;
frameStep: number;
frameSpeed: FrameSpeed;
frameDelay: number;
Expand Down Expand Up @@ -63,6 +64,7 @@ function mapStateToProps(state: CombinedState): StateToProps {
player: {
playing,
frame: {
filename: frameFilename,
number: frameNumber,
delay: frameDelay,
},
Expand Down Expand Up @@ -103,6 +105,7 @@ function mapStateToProps(state: CombinedState): StateToProps {
saving,
savingStatuses,
frameNumber,
frameFilename,
jobInstance,
undoAction: history.undo[history.undo.length - 1],
redoAction: history.redo[history.redo.length - 1],
Expand Down Expand Up @@ -208,7 +211,10 @@ class AnnotationTopBarContainer extends React.PureComponent<Props> {
setTimeout(() => {
const { playing: stillPlaying } = this.props;
if (stillPlaying) {
onChangeFrame(frameNumber + 1 + framesSkiped, stillPlaying, framesSkiped + 1);
onChangeFrame(
frameNumber + 1 + framesSkiped,
stillPlaying, framesSkiped + 1,
);
}
}, frameDelay);
} else {
Expand Down Expand Up @@ -450,6 +456,7 @@ class AnnotationTopBarContainer extends React.PureComponent<Props> {
stopFrame,
},
frameNumber,
frameFilename,
undoAction,
redoAction,
workspace,
Expand Down Expand Up @@ -622,6 +629,7 @@ class AnnotationTopBarContainer extends React.PureComponent<Props> {
startFrame={startFrame}
stopFrame={stopFrame}
frameNumber={frameNumber}
frameFilename={frameFilename}
inputFrameRef={this.inputFrameRef}
undoAction={undoAction}
redoAction={redoAction}
Expand Down
8 changes: 7 additions & 1 deletion cvat-ui/src/reducers/annotation-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const defaultState: AnnotationState = {
player: {
frame: {
number: 0,
filename: '',
data: null,
fetching: false,
delay: 0,
Expand Down Expand Up @@ -111,6 +112,7 @@ export default (state = defaultState, action: AnyAction): AnnotationState => {
job,
states,
frameNumber: number,
frameFilename: filename,
colors,
filters,
frameData: data,
Expand Down Expand Up @@ -145,6 +147,7 @@ export default (state = defaultState, action: AnyAction): AnnotationState => {
...state.player,
frame: {
...state.player.frame,
filename,
number,
data,
},
Expand Down Expand Up @@ -192,9 +195,11 @@ export default (state = defaultState, action: AnyAction): AnnotationState => {
const {
number,
data,
filename,
states,
minZ,
maxZ,
curZ,
delay,
changeTime,
} = action.payload;
Expand All @@ -209,6 +214,7 @@ export default (state = defaultState, action: AnyAction): AnnotationState => {
...state.player,
frame: {
data,
filename,
number,
fetching: false,
changeTime,
Expand All @@ -222,7 +228,7 @@ export default (state = defaultState, action: AnyAction): AnnotationState => {
zLayer: {
min: minZ,
max: maxZ,
cur: maxZ,
cur: curZ,
},
},
};
Expand Down
1 change: 1 addition & 0 deletions cvat-ui/src/reducers/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ export interface AnnotationState {
player: {
frame: {
number: number;
filename: string;
data: any | null;
fetching: boolean;
delay: number;
Expand Down