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

Client Animation Export #534

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 0 additions & 1 deletion vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
"@techstark/opencv-js": "^4.9.0-release.2",
"@turf/turf": "7.0.0-alpha.113",
"@types/mapbox__mapbox-gl-draw": "^1.4.6",
"canvas-capture": "^2.1.1",
"django-s3-file-field": "^1.0.1",
"js-cookie": "^3.0.5",
"lodash": "^4.17.21",
Expand Down
11 changes: 11 additions & 0 deletions vue/src/client/services/ApiService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ export interface DownloadSettings {
pointArea?: number;
}

export interface DefaultAnimationSettings {
fps: number;
sources: Constellation[];
noData: number;
include: ('obs' | 'nonobs')[];
point_radius: number;
cloudCover: number;
rescale: boolean;
rescale_border: number;
}

export interface DownloadAnimationSettings {
output_format: 'mp4' | 'gif';
fps: number;
Expand Down
26 changes: 16 additions & 10 deletions vue/src/components/animation/AnimationDownloadDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ import { debounce } from "lodash";
import {
ApiService,
Constellation,
DefaultAnimationSettings,
DownloadAnimationSettings,
} from "../../client/services/ApiService";
import AnimationDownloaded from "./AnimationDownloaded.vue";

const props = defineProps<{
type: "site" | "modelRun";
id: string;
defaults?: DefaultAnimationSettings;
}>();

const emit = defineEmits<{
Expand All @@ -22,10 +24,10 @@ const validForm = ref(true);
const outputFormat: Ref<DownloadAnimationSettings["output_format"]> =
ref("mp4");
const formatChoices = ref(["mp4", "gif"]);
const fps = ref(1);
const pointRadius = ref(5);
const constellationChoices = ref(["S2", "WV", "L8"]);
const selectedSources: Ref<Constellation[]> = ref(["WV", "S2"]);
const fps = ref(props.defaults ? props.defaults.fps : 1);
const pointRadius = ref(props.defaults ? props.defaults.point_radius : 5);
const constellationChoices = ref( ["S2", "WV", "L8"]);
const selectedSources: Ref<Constellation[]> = ref(props.defaults?.sources || ["WV", "S2"]);
const labelChoices = ref(["geom", "date", "source", "obs", "obs_label"]);
const labels: Ref<DownloadAnimationSettings["labels"]> = ref([
"geom",
Expand All @@ -34,9 +36,13 @@ const labels: Ref<DownloadAnimationSettings["labels"]> = ref([
"obs",
"obs_label",
]);
const cloudCover = ref(95);
const noData = ref(100);
const include: Ref<DownloadAnimationSettings["include"]> = ref([
onMounted(() => {
console.log('Animation Defaults');
console.log(props.defaults);
});
floryst marked this conversation as resolved.
Show resolved Hide resolved
const cloudCover = ref(props.defaults ? props.defaults.cloudCover : 95);
const noData = ref(props.defaults ? props.defaults.noData : 100);
const include: Ref<DownloadAnimationSettings["include"]> = ref(props.defaults?.include || [
"obs",
"nonobs",
]);
Expand Down Expand Up @@ -158,9 +164,9 @@ const cancel = debounce(() => emit("close"), 5000, { leading: true });
>
<v-slider
v-model="fps"
min="1"
max="60"
step="1"
min="0.1"
max="30"
step="0.1"
thumb-label="always"
label="FPS"
class="pt-2"
Expand Down
164 changes: 159 additions & 5 deletions vue/src/components/imageViewer/ImageFilter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,43 @@ import { computed, ref, watch, withDefaults } from "vue";
import { EvaluationImage } from "../../types";
import { PixelPoly } from "./imageUtils";
import { state } from '../../store';
import { DefaultAnimationSettings } from "../../client/services/ApiService";

interface Props {
combinedImages: {image: EvaluationImage; poly: PixelPoly, groundTruthPoly?: PixelPoly}[];
rescaleImage: boolean;
}
const props = withDefaults(defineProps<Props>(), {
});

const emit = defineEmits<{
(e: "imageFilter", data: {image: EvaluationImage; poly: PixelPoly, groundTruthPoly?: PixelPoly}[]): void;
(e: "imageFilter", data: {image: EvaluationImage; poly: PixelPoly, groundTruthPoly?: PixelPoly}[]): void,
(e: "animationDefaults", data: DefaultAnimationSettings): void;
(e: "rescaleBBox", data: number): void;
}>();

const baseImageSources = ref(['S2', 'WV', 'L8', 'PL'])
const baseObs = ref(['observations', 'non-observations'])
const filterSettings = ref(true);
const rescaleBorder = ref(1)

const downloadingGifPointSize = computed({
get() {
return state.gifSettings.pointSize || 1;
},
set(val: number) {
state.gifSettings = { ...state.gifSettings, pointSize: val };
},
});

const playbackFps = computed({
get() {
return state.gifSettings.fps || 1;
},
set(val: number) {
state.gifSettings = { ...state.gifSettings, fps: val };
},
});


const filteredImages = computed(() => {
Expand Down Expand Up @@ -44,6 +67,39 @@ const filteredImages = computed(() => {
watch(filteredImages, () => {
emit('imageFilter', filteredImages.value);
})

watch([
() => state.imageFilter.sources,
() => state.imageFilter.obsFilter,
() => state.imageFilter.cloudCover,
() => state.imageFilter.noData], () => {
const defaultAnimationSettings: DefaultAnimationSettings = {
cloudCover: state.imageFilter.cloudCover,
noData: state.imageFilter.noData,
sources: state.imageFilter.sources,
include: state.imageFilter.obsFilter.map((item) => item === 'non-observations' ? 'nonobs' : 'obs'),
rescale: props.rescaleImage,
rescale_border: rescaleBorder.value,
fps: playbackFps.value,
point_radius: downloadingGifPointSize.value,
}
console.log('Emitting Animation Defaults');
emit('animationDefaults', defaultAnimationSettings);
})
watch(rescaleBorder, () => {
const defaultAnimationSettings: DefaultAnimationSettings = {
cloudCover: state.imageFilter.cloudCover,
noData: state.imageFilter.noData,
sources: state.imageFilter.sources,
include: state.imageFilter.obsFilter.map((item) => item === 'non-observations' ? 'nonobs' : 'obs'),
rescale: props.rescaleImage,
rescale_border: rescaleBorder.value,
fps: playbackFps.value,
point_radius: downloadingGifPointSize.value,
}
emit('animationDefaults', defaultAnimationSettings);
emit('rescaleBBox', rescaleBorder.value);
})
</script>

<template>
Expand Down Expand Up @@ -77,6 +133,7 @@ watch(filteredImages, () => {
multiple
closable-chips
chips
density="compact"
class="mx-2"
/>
<v-select
Expand All @@ -85,6 +142,7 @@ watch(filteredImages, () => {
:items="baseImageSources"
multiple
closable-chips
density="compact"
chips
class="mx-2"
/>
Expand All @@ -94,7 +152,10 @@ watch(filteredImages, () => {
justify="center"
align="center"
>
<v-col cols="3">
<v-col
cols="2"
class="slider-label"
>
<span>Cloud Cover:</span>
</v-col>
<v-col cols="7">
Expand All @@ -105,7 +166,7 @@ watch(filteredImages, () => {
step="1"
color="primary"
density="compact"
class="mt-5"
hide-details
/>
</v-col>
<v-col>
Expand All @@ -119,7 +180,10 @@ watch(filteredImages, () => {
justify="center"
align="center"
>
<v-col cols="3">
<v-col
cols="2"
class="slider-label"
>
<span>NoData:</span>
</v-col>
<v-col cols="7">
Expand All @@ -129,8 +193,8 @@ watch(filteredImages, () => {
max="100"
step="1"
color="primary"
hide-details
density="compact"
class="mt-5"
/>
</v-col>
<v-col>
Expand All @@ -139,6 +203,96 @@ watch(filteredImages, () => {
</span>
</v-col>
</v-row>
<v-row
dense
justify="center"
align="center"
>
<v-col
cols="2"
class="slider-label"
>
<span>FPS:</span>
</v-col>
<v-col cols="7">
<v-slider
v-model.number="playbackFps"
min="0.1"
max="30"
step="0.1"
color="primary"
hide-details
density="compact"
/>
</v-col>
<v-col>
<span>
{{ playbackFps.toFixed(2) }}fps
</span>
</v-col>
</v-row>
<v-row
dense
justify="center"
align="center"
>
<v-col
cols="2"
class="slider-label"
>
<span>Rescale Border:</span>
</v-col>
<v-col cols="7">
<v-slider
v-model.number="rescaleBorder"
min="1"
max="5"
step="1"
color="primary"
hide-details
density="compact"
/>
</v-col>
<v-col>
<span class="pl-2">
{{ rescaleBorder }}X
</span>
</v-col>
</v-row>
<v-row
dense
justify="center"
align="center"
>
<v-col
cols="2"
class="slider-label"
>
<span>Point Radius:</span>
</v-col>
<v-col cols="7">
<v-slider
v-model.number="downloadingGifPointSize"
min="1"
max="20"
step="1"
color="primary"
hide-details
density="compact"
/>
</v-col>
<v-col>
<span class="pl-2">
{{ downloadingGifPointSize }}px
</span>
</v-col>
</v-row>
</div>
</div>
</template>

<style scoped>
.slider-label {
font-size: 0.75em;
}
</style>
Loading
Loading