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

Persist image filters across jobs #6953

Merged
merged 6 commits into from
Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 5 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
4 changes: 4 additions & 0 deletions changelog.d/20231006_155231_persist_image_filters.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Fixed

- Persist image filters across jobs
(<https://github.com/opencv/cvat/pull/6953>)
2 changes: 1 addition & 1 deletion cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ class CanvasWrapperComponent extends React.PureComponent<Props> {
const imageIsNotProcessed = imageFilters.some((imageFilter: ImageFilter) => (
imageFilter.modifier.currentProcessedImage !== frame
));

console.log(imageIsNotProcessed);
klakhov marked this conversation as resolved.
Show resolved Hide resolved
if (imageIsNotProcessed) {
try {
const { renderWidth, renderHeight, imageData: imageBitmap } = originalImage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
6 changes: 5 additions & 1 deletion cvat-ui/src/reducers/settings-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -477,7 +481,7 @@ export default (state = defaultState, action: AnyAction): SettingsState => {
} :
{}),
},
imageFilters: [],
imageFilters: filters,
};
}
case AnnotationActionTypes.INTERACT_WITH_CANVAS: {
Expand Down
14 changes: 14 additions & 0 deletions cvat-ui/src/utils/fabric-wrapper/gamma-correciton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export interface GammaFilterOptions {
}

export default class GammaCorrection extends FabricFilter {
#gamma: number[];

constructor(options: GammaFilterOptions) {
super();

Expand All @@ -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];
}
}
Loading