|
10 | 10 | (() => {
|
11 | 11 | const PluginRegistry = require('./plugins');
|
12 | 12 | const serverProxy = require('./server-proxy');
|
13 |
| - const { getFrame } = require('./frames'); |
| 13 | + const { getFrame, getPreview } = require('./frames'); |
14 | 14 | const { ArgumentError } = require('./exceptions');
|
15 | 15 | const { TaskStatus } = require('./enums');
|
16 | 16 | const { Label } = require('./labels');
|
|
109 | 109 | .apiWrapper.call(this, prototype.frames.get, frame);
|
110 | 110 | return result;
|
111 | 111 | },
|
| 112 | + async preview() { |
| 113 | + const result = await PluginRegistry |
| 114 | + .apiWrapper.call(this, prototype.frames.preview); |
| 115 | + return result; |
| 116 | + }, |
112 | 117 | },
|
113 | 118 | writable: true,
|
114 | 119 | }),
|
|
380 | 385 | * @throws {module:API.cvat.exceptions.ServerError}
|
381 | 386 | * @throws {module:API.cvat.exceptions.ArgumentError}
|
382 | 387 | */
|
| 388 | + /** |
| 389 | + * Get the first frame of a task for preview |
| 390 | + * @method preview |
| 391 | + * @memberof Session.frames |
| 392 | + * @returns {string} - jpeg encoded image |
| 393 | + * @instance |
| 394 | + * @async |
| 395 | + * @throws {module:API.cvat.exceptions.PluginError} |
| 396 | + * @throws {module:API.cvat.exceptions.ServerError} |
| 397 | + * @throws {module:API.cvat.exceptions.ArgumentError} |
| 398 | + */ |
383 | 399 |
|
384 | 400 | /**
|
385 | 401 | * Namespace is used for an interaction with logs
|
|
619 | 635 |
|
620 | 636 | this.frames = {
|
621 | 637 | get: Object.getPrototypeOf(this).frames.get.bind(this),
|
| 638 | + preview: Object.getPrototypeOf(this).frames.preview.bind(this), |
622 | 639 | };
|
623 | 640 | }
|
624 | 641 |
|
|
780 | 797 | get: () => data.mode,
|
781 | 798 | },
|
782 | 799 | /**
|
783 |
| - * Identificator of a user who has created the task |
| 800 | + * Instance of a user who has created the task |
784 | 801 | * @name owner
|
785 |
| - * @type {integer} |
| 802 | + * @type {module:API.cvat.classes.User} |
786 | 803 | * @memberof module:API.cvat.classes.Task
|
787 | 804 | * @readonly
|
788 | 805 | * @instance
|
|
791 | 808 | get: () => data.owner,
|
792 | 809 | },
|
793 | 810 | /**
|
794 |
| - * Identificator of a user who is responsible for the task |
| 811 | + * Instance of a user who is responsible for the task |
795 | 812 | * @name assignee
|
796 |
| - * @type {integer} |
| 813 | + * @type {module:API.cvat.classes.User} |
797 | 814 | * @memberof module:API.cvat.classes.Task
|
798 | 815 | * @instance
|
799 | 816 | * @throws {module:API.cvat.exceptions.ArgumentError}
|
|
1122 | 1139 |
|
1123 | 1140 | this.frames = {
|
1124 | 1141 | get: Object.getPrototypeOf(this).frames.get.bind(this),
|
| 1142 | + preview: Object.getPrototypeOf(this).frames.preview.bind(this), |
1125 | 1143 | };
|
1126 | 1144 | }
|
1127 | 1145 |
|
|
1218 | 1236 | return frameData;
|
1219 | 1237 | };
|
1220 | 1238 |
|
| 1239 | + Job.prototype.frames.preview.implementation = async function () { |
| 1240 | + const frameData = await getPreview(this.task.id); |
| 1241 | + return frameData; |
| 1242 | + }; |
| 1243 | + |
1221 | 1244 | // TODO: Check filter for annotations
|
1222 | 1245 | Job.prototype.annotations.get.implementation = async function (frame, filter) {
|
1223 | 1246 | if (frame < this.startFrame || frame > this.stopFrame) {
|
|
1293 | 1316 | name: this.name,
|
1294 | 1317 | bug_tracker: this.bugTracker,
|
1295 | 1318 | z_order: this.zOrder,
|
1296 |
| - labels: [...this.labels.map(el => el.toJSON())], |
| 1319 | + labels: [...this.labels.map((el) => el.toJSON())], |
1297 | 1320 | };
|
1298 | 1321 |
|
1299 | 1322 | await serverProxy.tasks.saveTask(this.id, taskData);
|
|
1302 | 1325 |
|
1303 | 1326 | const taskData = {
|
1304 | 1327 | name: this.name,
|
1305 |
| - labels: this.labels.map(el => el.toJSON()), |
| 1328 | + labels: this.labels.map((el) => el.toJSON()), |
1306 | 1329 | image_quality: this.imageQuality,
|
1307 | 1330 | z_order: Boolean(this.zOrder),
|
1308 | 1331 | };
|
|
1358 | 1381 | return result;
|
1359 | 1382 | };
|
1360 | 1383 |
|
| 1384 | + Task.prototype.frames.preview.implementation = async function () { |
| 1385 | + const frameData = await getPreview(this.id); |
| 1386 | + return frameData; |
| 1387 | + }; |
| 1388 | + |
1361 | 1389 | // TODO: Check filter for annotations
|
1362 | 1390 | Task.prototype.annotations.get.implementation = async function (frame, filter) {
|
1363 | 1391 | if (!Number.isInteger(frame) || frame < 0) {
|
|
0 commit comments