Skip to content

Commit

Permalink
merged develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Boris Sekachev committed Aug 6, 2021
2 parents df53299 + e1198c3 commit 7753c58
Show file tree
Hide file tree
Showing 16 changed files with 264 additions and 42 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- TDB
- Fixed multiple tasks moving (<https://github.com/openvinotoolkit/cvat/pull/3517>)
- Fixed task creating CLI parameter (<https://github.com/openvinotoolkit/cvat/pull/3519>)

### Security

Expand Down
4 changes: 2 additions & 2 deletions components/analytics/logstash/logstash.conf
Original file line number Diff line number Diff line change
Expand Up @@ -124,15 +124,15 @@ output {
if [type] == "client" {
elasticsearch {
hosts => ["${LOGSTASH_OUTPUT_HOST}"]
index => "cvat.client"
index => "%{[@metadata][target_index_client]}"
user => "${LOGSTASH_OUTPUT_USER:}"
password => "${LOGSTASH_OUTPUT_PASS:}"
manage_template => false
}
} else if [type] == "server" {
elasticsearch {
hosts => ["${LOGSTASH_OUTPUT_HOST}"]
index => "cvat.server"
index => "%{[@metadata][target_index_server]}"
user => "${LOGSTASH_OUTPUT_USER:}"
password => "${LOGSTASH_OUTPUT_PASS:}"
manage_template => false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
notification.error({
description: error.toString(),
message: 'OpenCV.js processing error occured',
className: 'cvat-notification-notice-opencv-processing-error',
});
}
};
Expand Down Expand Up @@ -263,6 +264,7 @@ class OpenCVControlComponent extends React.PureComponent<Props & DispatchToProps
notification.error({
description: error.toString(),
message: 'OpenCV.js processing error occured',
className: 'cvat-notification-notice-opencv-processing-error',
});
} finally {
this.disableCanvasForceUpdate();
Expand Down
4 changes: 2 additions & 2 deletions cvat-ui/src/components/move-task-modal/move-task-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ export default function MoveTaskModal(): JSX.Element {
const [labelMap, setLabelMap] = useState<{ [key: string]: LabelMapperItemValue }>({});

const initValues = (): void => {
const labelValues: { [key: string]: LabelMapperItemValue } = {};
if (task) {
const labelValues: { [key: string]: LabelMapperItemValue } = {};
task.labels.forEach((label: any) => {
labelValues[label.id] = {
labelId: label.id,
newLabelName: null,
clearAttributes: true,
};
});
setLabelMap(labelValues);
}
setLabelMap(labelValues);
};

const onCancel = (): void => {
Expand Down
3 changes: 1 addition & 2 deletions cvat-ui/src/utils/opencv-wrapper/histogram-equalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ export default class HistogramEqualizationImplementation implements HistogramEqu
this.hashFrame(imgData, frameNumber);
return imgData;
} catch (e) {
console.log('Histogram equalization error', e);
return src;
throw new Error(e.toString());
} finally {
if (matImage) matImage.delete();
if (channels) channels.delete();
Expand Down
10 changes: 4 additions & 6 deletions cvat-ui/src/utils/opencv-wrapper/opencv-wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface Contours {
}

export interface ImgProc {
hist: () => HistogramEqualization
hist: () => HistogramEqualization;
}

export class OpenCVWrapper {
Expand All @@ -41,10 +41,6 @@ export class OpenCVWrapper {
const contentLength = response.headers.get('Content-Length');
const { body } = response;

if (contentLength === null) {
throw new Error('Content length is null, but necessary');
}

if (body === null) {
throw new Error('Response body is null, but necessary');
}
Expand All @@ -64,7 +60,9 @@ export class OpenCVWrapper {
if (value instanceof Uint8Array) {
decodedScript += decoder.decode(value);
receivedLength += value.length;
const percentage = (receivedLength * 100) / +(contentLength as string);
// Cypress workaround: content-length is always zero in cypress, it is done optional here
// Just progress bar will be disabled
const percentage = contentLength ? (receivedLength * 100) / +(contentLength as string) : 0;
onProgress(+percentage.toFixed(0));
}
}
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/manual/advanced/cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ comprehensive CVAT administration tool in the future.

Overview of functionality:

- Create a new task (supports name, bug tracker, labels JSON, local/share/remote files)
- Create a new task (supports name, bug tracker, project, labels JSON, local/share/remote files)
- Delete tasks (supports deleting a list of task IDs)
- List all tasks (supports basic CSV or JSON output)
- Download JPEG frames (supports a list of frame IDs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/// <reference types="cypress" />

import { taskName } from '../../support/const';
import { generateString } from '../../support/utils';

context('Settings. Default number of points in polygon approximation.', () => {
const caseId = '100';
Expand All @@ -26,14 +27,6 @@ context('Settings. Default number of points in polygon approximation.', () => {
});
}

function generateString(countPointsToMove) {
let action = '';
for (let i = 0; i < countPointsToMove; i++) {
action += '{rightarrow}';
}
return action;
}

before(() => {
cy.openTaskJob(taskName);
});
Expand All @@ -43,7 +36,7 @@ context('Settings. Default number of points in polygon approximation.', () => {
testOpenSettingsWorkspace();
cy.get('.cvat-workspace-settings-approx-poly-threshold')
.find('[role="slider"]')
.type(generateString(4))
.type(generateString(4, 'rightarrow'))
.then((slider) => {
const sliderAttrValueNow = slider.attr('aria-valuenow');
const sliderAttrValuemin = slider.attr('aria-valuemin');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

/// <reference types="cypress" />

import { taskName, labelName } from '../../support/const';

context('Create a link for shape, frame.', () => {
const caseId = '102';
const createRectangleShape2Points = {
points: 'By 2 Points',
type: 'Shape',
labelName: labelName,
firstX: 250,
firstY: 350,
secondX: 350,
secondY: 450,
};

before(() => {
cy.openTaskJob(taskName);
cy.createRectangle(createRectangleShape2Points);
cy.saveJob('PATCH', 200, `case${caseId}`);
});

describe(`Testing case "${caseId}"`, () => {
it('Create a link for a shape, for a frame.', () => {
cy.window().then(win => {
cy.stub(win, 'prompt').returns(win.prompt).as('copyToClipboardPromptShape');
});
cy.get('#cvat-objects-sidebar-state-item-1').find('[aria-label="more"]').trigger('mouseover');
cy.get('#cvat_canvas_shape_1').should('have.class', 'cvat_canvas_shape_activated')
cy.get('.cvat-object-item-menu').last().should('be.visible').contains('button', 'Create object URL').click();
cy.get('@copyToClipboardPromptShape').should('be.called');
cy.get('@copyToClipboardPromptShape').then(prompt => {
const url = prompt.args[0][1];
expect(url).include('frame=');
expect(url).include('type=');
expect(url).include('serverID=');
cy.visit(url);
cy.closeModalUnsupportedPlatform();
cy.get('.cvat-canvas-container').should('be.visible');
cy.get('#cvat_canvas_shape_1').should('be.visible');
});

cy.window().then(win => {
cy.stub(win, 'prompt').returns(win.prompt).as('copyToClipboardPromptFrame');
});
cy.get('.cvat-player-frame-url-icon').click();
cy.get('@copyToClipboardPromptFrame').should('be.called');
cy.get('@copyToClipboardPromptFrame').then(prompt => {
const url = prompt.args[0][1];
expect(url).include('frame=');
expect(url).not.include('type=');
expect(url).not.include('serverID=');
cy.visit(url);
cy.get('.cvat-canvas-container').should('be.visible');
cy.get('#cvat_canvas_shape_1').should('be.visible');
});
});
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

/// <reference types="cypress" />

import { taskName, labelName } from '../../support/const';
import { generateString } from '../../support/utils';

context('OpenCV. Intelligent cissors. Histogram Equalization.', () => {
const caseId = '101';
const newLabel = `Case ${caseId}`
const createOpencvShape = {
labelName: labelName,
pointsMap: [
{ x: 200, y: 200 },
{ x: 250, y: 200 },
{ x: 300, y: 250 },
{ x: 350, y: 300 },
{ x: 300, y: 350 },
],
};
const createOpencvShapeSecondLabel = {
labelName: newLabel,
pointsMap: [
{ x: 300, y: 200 },
{ x: 350, y: 200 },
{ x: 400, y: 250 },
{ x: 450, y: 300 },
{ x: 400, y: 350 },
],
finishWithButton: true,
};
const keyCodeN = 78;
const pointsMap = [
{ x: 300, y: 400 },
{ x: 350, y: 500 },
{ x: 400, y: 450 },
{ x: 450, y: 500 },
{ x: 400, y: 550 },
];

function openOpencvControlPopover() {
cy.get('body').focus();
cy.get('.cvat-tools-control').trigger('mouseleave').trigger('mouseout').trigger('mouseover');
}

before(() => {
cy.openTask(taskName);
cy.addNewLabel(newLabel);
cy.openJob();
});

describe(`Testing case "${caseId}"`, () => {
it('Load OpenCV.', () => {
openOpencvControlPopover();
cy.get('.cvat-opencv-control-popover-visible').find('.cvat-opencv-initialization-button').click();
// Intelligent cissors button be visible
cy.get('.cvat-opencv-drawing-tool').should('exist').and('be.visible');
});

it('Create a shape with "Intelligent cissors". Create the second shape with the label change and "Done" button.', () => {
cy.opencvCreateShape(createOpencvShape);
cy.opencvCreateShape(createOpencvShapeSecondLabel);
});

it('Change the number of points when the shape is drawn. Cancel drawing.', () => {
openOpencvControlPopover();
cy.get('.cvat-opencv-drawing-tool').click();
pointsMap.forEach((element) => {
cy.get('.cvat-canvas-container').click(element.x, element.y);
});
cy.get('.cvat_canvas_interact_intermediate_shape').then((intermediateShape) => {
// Get count of points
const intermediateShapeNumberPointsBeforeChange = intermediateShape.attr('points').split(' ').length;
// Change number of points
cy.get('.cvat-approx-poly-threshold-wrapper')
.find('[role="slider"]')
.type(generateString(4, 'rightarrow'));
cy.get('.cvat_canvas_interact_intermediate_shape').then((intermediateShape) => {
// Get count of points againe
const intermediateShapeNumberPointsAfterChange = intermediateShape.attr('points').split(' ').length;
// expected 7 to be below 10
expect(intermediateShapeNumberPointsBeforeChange).to.be.lt(intermediateShapeNumberPointsAfterChange);
});
});
cy.get('body').type('{Esc}'); // Cancel drawing
cy.get('.cvat_canvas_interact_intermediate_shape').should('not.exist');
cy.get('.cvat_canvas_shape').should('have.length', 2);
});

it('Check "Histogram Equalization" feature.', () => {
openOpencvControlPopover();
cy.get('.cvat-opencv-control-popover-visible').contains('[role="tab"]', 'Image').click();
cy.get('.cvat-opencv-image-tool').click().should('have.class', 'cvat-opencv-image-tool-active').trigger('mouseout');
cy.get('.cvat-notification-notice-opencv-processing-error').should('not.exist');
cy.get('.cvat-opencv-image-tool').click().should('not.have.class', 'cvat-opencv-image-tool-active').trigger('mouseout');
});

// Waiting for fix https://github.com/openvinotoolkit/cvat/issues/3474
it.skip('Redraw the shape created with "Intelligent cissors".', () => {
cy.get('.cvat-canvas-container').click();
cy.get('.cvat-opencv-control-popover').should('be.hidden');
cy.get('#cvat_canvas_shape_1')
.trigger('mousemove')
.trigger('mouseover')
.should('have.class', 'cvat_canvas_shape_activated');
cy.get('body').trigger('keydown', { keyCode: keyCodeN, shiftKey: true }).trigger('keyup');
cy.get('.cvat-tools-control').should('have.attr', 'tabindex');
createOpencvShape.pointsMap.forEach((el) => {
cy.get('.cvat-canvas-container')
.click(el.x + 150, el.y + 50)
});
cy.get('body').trigger('keydown', { keyCode: keyCodeN }).trigger('keyup');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,14 @@
/// <reference types="cypress" />

import { taskName } from '../../support/const';
import { generateString } from '../../support/utils';

context('Canvas grid feature', () => {
const caseId = '23';
const settingsGridSize = 50;
const gridColor = 'Black';
const gridOpacity = 80;

function generateString(countPointsToMove) {
let action = '';
for (let i = 0; i < countPointsToMove; i++) {
action += '{leftarrow}';
}
return action;
}

before(() => {
cy.openTaskJob(taskName);
cy.get('.cvat-canvas-image-setups-trigger').click();
Expand All @@ -44,7 +37,7 @@ context('Canvas grid feature', () => {
});
it('Set "Grid opacity" to 80%.', () => {
cy.get('.cvat-image-setups-grid-opacity-input').within(() => {
cy.get('[role="slider"]').type(generateString(20)); // Moving the slider to the left up to 80.
cy.get('[role="slider"]').type(generateString(20, 'leftarrow')); // Moving the slider to the left up to 80.
cy.get('[role="slider"]').should('have.attr', 'aria-valuenow', gridOpacity);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/// <reference types="cypress" />

import { taskName } from '../../support/const';
import { generateString } from '../../support/utils';

context('Canvas brightness/contrast/saturation feature', () => {
const caseId = '26';
Expand All @@ -17,14 +18,6 @@ context('Canvas brightness/contrast/saturation feature', () => {
'.cvat-image-setups-saturation',
];

function generateStringCountAction(countAction) {
let stringAction = '';
for (let i = 0; i < countAction; i++) {
stringAction += '{rightarrow}';
}
return stringAction;
}

function checkStateValuesInBackground(expectedValue) {
cy.get('#cvat_canvas_background')
.should('have.attr', 'style')
Expand All @@ -41,7 +34,7 @@ context('Canvas brightness/contrast/saturation feature', () => {

describe(`Testing case "${caseId}"`, () => {
it('Check apply of settings', () => {
let stringAction = generateStringCountAction(countActionMoveSlider);
let stringAction = generateString(countActionMoveSlider, 'rightarrow');
cy.get('.cvat-canvas-image-setups-content').within(() => {
cy.wrap(classNameSliders).each(($el) => {
cy.wrap($el)
Expand Down
Loading

0 comments on commit 7753c58

Please sign in to comment.