From b3d9b23b4dbc351a3996b756e2f781e3d85f2f54 Mon Sep 17 00:00:00 2001 From: Kirill Lakhov Date: Tue, 10 Oct 2023 14:10:13 +0300 Subject: [PATCH] Persist image filters across jobs (#6953) ### Motivation and context ### How has this been tested? ### Checklist - [ ] I submit my changes into the `develop` branch - [ ] I have created a changelog fragment - [ ] I have updated the documentation accordingly - [ ] I have added tests to cover my changes - [ ] I have linked related issues (see [GitHub docs]( https://help.github.com/en/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword)) - [ ] I have increased versions of npm packages if it is necessary ([cvat-canvas](https://github.com/opencv/cvat/tree/develop/cvat-canvas#versioning), [cvat-core](https://github.com/opencv/cvat/tree/develop/cvat-core#versioning), [cvat-data](https://github.com/opencv/cvat/tree/develop/cvat-data#versioning) and [cvat-ui](https://github.com/opencv/cvat/tree/develop/cvat-ui#versioning)) ### License - [ ] I submit _my code changes_ under the same [MIT License]( https://github.com/opencv/cvat/blob/develop/LICENSE) that covers the project. Feel free to contact the maintainers if that's a concern. --- .../20231006_155231_persist_image_filters.md | 4 ++++ cvat-ui/package.json | 2 +- .../canvas/views/canvas2d/gamma-filter.tsx | 2 ++ cvat-ui/src/reducers/settings-reducer.ts | 6 +++++- .../src/utils/fabric-wrapper/gamma-correciton.ts | 14 ++++++++++++++ 5 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 changelog.d/20231006_155231_persist_image_filters.md diff --git a/changelog.d/20231006_155231_persist_image_filters.md b/changelog.d/20231006_155231_persist_image_filters.md new file mode 100644 index 000000000000..ca10b538dd37 --- /dev/null +++ b/changelog.d/20231006_155231_persist_image_filters.md @@ -0,0 +1,4 @@ +### Fixed + +- Persist image filters across jobs + () diff --git a/cvat-ui/package.json b/cvat-ui/package.json index 4fbfa49cd725..974248426a62 100644 --- a/cvat-ui/package.json +++ b/cvat-ui/package.json @@ -1,6 +1,6 @@ { "name": "cvat-ui", - "version": "1.57.2", + "version": "1.57.3", "description": "CVAT single-page application", "main": "src/index.tsx", "scripts": { diff --git a/cvat-ui/src/components/annotation-page/canvas/views/canvas2d/gamma-filter.tsx b/cvat-ui/src/components/annotation-page/canvas/views/canvas2d/gamma-filter.tsx index cdd2d887f2ac..29c5709363f8 100644 --- a/cvat-ui/src/components/annotation-page/canvas/views/canvas2d/gamma-filter.tsx +++ b/cvat-ui/src/components/annotation-page/canvas/views/canvas2d/gamma-filter.tsx @@ -46,6 +46,8 @@ export default function GammaFilter(): JSX.Element { useEffect(() => { if (filters.length === 0) { setGamma(1); + } else if (gammaFilter) { + setGamma((gammaFilter.modifier as GammaCorrection).gamma); } }, [filters]); diff --git a/cvat-ui/src/reducers/settings-reducer.ts b/cvat-ui/src/reducers/settings-reducer.ts index fdbf1baa62f7..a3917329fd3d 100644 --- a/cvat-ui/src/reducers/settings-reducer.ts +++ b/cvat-ui/src/reducers/settings-reducer.ts @@ -462,6 +462,10 @@ export default (state = defaultState, action: AnyAction): SettingsState => { case BoundariesActionTypes.RESET_AFTER_ERROR: case AnnotationActionTypes.GET_JOB_SUCCESS: { const { job } = action.payload; + const filters = [...state.imageFilters]; + filters.forEach((imageFilter) => { + imageFilter.modifier.currentProcessedImage = null; + }); return { ...state, @@ -477,7 +481,7 @@ export default (state = defaultState, action: AnyAction): SettingsState => { } : {}), }, - imageFilters: [], + imageFilters: filters, }; } case AnnotationActionTypes.INTERACT_WITH_CANVAS: { diff --git a/cvat-ui/src/utils/fabric-wrapper/gamma-correciton.ts b/cvat-ui/src/utils/fabric-wrapper/gamma-correciton.ts index 4e5bb657c9a4..04a76fd7a580 100644 --- a/cvat-ui/src/utils/fabric-wrapper/gamma-correciton.ts +++ b/cvat-ui/src/utils/fabric-wrapper/gamma-correciton.ts @@ -10,6 +10,8 @@ export interface GammaFilterOptions { } export default class GammaCorrection extends FabricFilter { + #gamma: number[]; + constructor(options: GammaFilterOptions) { super(); @@ -22,5 +24,17 @@ export default class GammaCorrection extends FabricFilter { this.filter = new fabric.Image.filters.Gamma({ gamma, }); + this.#gamma = gamma; + } + + public configure(options: object): void { + super.configure(options); + + const { gamma: newGamma } = options as GammaFilterOptions; + this.#gamma = newGamma; + } + + get gamma(): number { + return this.#gamma[0]; } }