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

Remove cal images if needed and bump http request size #1295

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ onBeforeUnmount(() => {

<template>
<div class="stream-container">
<img :id="id" crossorigin="anonymous" :src="streamSrc" :alt="streamDesc" :style="streamStyle" ref="mjpgStream" />
<img :id="id" ref="mjpgStream" crossorigin="anonymous" :src="streamSrc" :alt="streamDesc" :style="streamStyle" />
<div class="stream-overlay" :style="overlayStyle">
<pv-icon
icon-name="mdi-camera-image"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useCameraSettingsStore } from "@/stores/settings/CameraSettingsStore";
import { useStateStore } from "@/stores/StateStore";
import { computed, inject, ref } from "vue";
import { getResolutionString, parseJsonFile } from "@/lib/PhotonUtils";
import loadingImage from "@/assets/images/loading.svg";

const props = defineProps<{
videoFormat: VideoFormat;
Expand Down Expand Up @@ -36,13 +37,36 @@ const importCalibration = async () => {
return;
}

let message: any = undefined;

// check size and trim if we have to
let approxSizeMb = uploadedJson.size / 1e6;
if (approxSizeMb > 50) {
data.observations.map((it) => (it.snapshotData = undefined));

// so at this point the calibration is likely pretty small -- it's cheap enough to check though
approxSizeMb = JSON.stringify(data).length / 1e6;

if (approxSizeMb > 50) {
// Absolutely monster dataset, try trimming again
data.observations = [];
}

message = {
color: "warning",
message: `The calibration file was very large (~${approxSizeMb.toFixed(0)}MB) -- images were removed to save space!`,
timeout: 10000
};
}

useCameraSettingsStore()
.importCalibrationFromData({ calibration: data })
.then((response) => {
useStateStore().showSnackbarMessage({
message = message || {
color: "success",
message: response.data.text || response.data
});
};
useStateStore().showSnackbarMessage(message);
})
.catch((error) => {
if (error.response) {
Expand Down Expand Up @@ -256,7 +280,12 @@ const calibrationImageURL = (index: number) =>
<template #expanded-item="{ headers, item }">
<td :colspan="headers.length">
<div style="display: flex; justify-content: center; width: 100%">
<img :src="calibrationImageURL(item.index)" alt="observation image" class="snapshot-preview pt-2 pb-2" />
<v-img
:src="calibrationImageURL(item.index)"
:lazy-src="loadingImage"
alt="observation image"
class="snapshot-preview pt-2 pb-2"
/>
</div>
</td>
</template>
Expand Down
2 changes: 1 addition & 1 deletion photon-client/src/types/SettingTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export interface BoardObservation {
optimisedCameraToObject: Pose3d;
includeObservationInCalibration: boolean;
snapshotName: string;
snapshotData: JsonImageMat;
snapshotData?: JsonImageMat;
}

export interface CameraCalibrationResult {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,9 @@ public static void onCalibrationSnapshotRequest(Context ctx) {
.findFirst()
.orElse(null);

if (calList == null || calList.observations.size() < observationIdx) {
if (calList == null
|| calList.observations.size() < observationIdx
|| calList.observations.get(observationIdx).snapshotData == null) {
ctx.status(404);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ private static void start(int port) {

// Increase the upload size limit (arbitrary, but need to be able to deal with large
// calibration JSONs)
javalinConfig.http.maxRequestSize = (long) (50 * 1e6);
javalinConfig.http.maxRequestSize = (long) (100 * 1e6);
mcm001 marked this conversation as resolved.
Show resolved Hide resolved

javalinConfig.requestLogger.http(
(ctx, ms) -> {
Expand Down
Loading