Angle Double

This commit is contained in:
ChK
2026-05-15 14:20:18 +02:00
parent e406f18169
commit 8410ce685b
14 changed files with 465 additions and 49 deletions

View File

@@ -208,11 +208,16 @@ app.get('/api/latest-snapshot', (req, res) => {
const latestFile = csvFiles[0];
const baseName = path.basename(latestFile.name, path.extname(latestFile.name));
const jsonFilename = `${baseName}.json`;
const jsonPath = path.join(snapshotsDir, jsonFilename);
console.log("JSON Pfad:", jsonPath);
console.log("Existiert JSON:", fs.existsSync(jsonPath));
const imageFilename = `${baseName}_annotated.jpg`;
const imagePath = path.join(snapshotsDir, imageFilename);
const imatePath2 = imagePath.includes('video0') ? imagePath.replace('video0', 'video1') : imagePath.replace('video1', 'video0');
//--
fs.readFile(latestFile.path, 'utf8', (err, data) => {
if (err) {
return res.status(500).json({ error: 'Fehler beim Lesen der Datei' });
@@ -224,39 +229,45 @@ app.get('/api/latest-snapshot', (req, res) => {
content: data
};
// Lade JSON wenn vorhanden
fs.readFile(jsonFilename, { encoding: 'base64' }, (jpgErr, jpgBase64) => {
if (!jpgErr && jpgBase64) {
response.imageFile = {
const jsonPath = path.join(snapshotsDir, jsonFilename);
// ✅ JSON FIRST, dann alles andere
fs.readFile(jsonPath, 'utf8', (jsonErr, jsonData) => {
if (!jsonErr && jsonData) {
response.jsonFile = {
filename: jsonFilename,
mimeType: 'json',
contentBase64: jpgBase64
};
}
});
// Lade beide Bilder
fs.readFile(imagePath, { encoding: 'base64' }, (jpgErr, jpgBase64) => {
if (!jpgErr && jpgBase64) {
response.imageFile = {
filename: imageFilename,
mimeType: 'image/jpeg',
contentBase64: jpgBase64
content: jsonData
};
}
fs.readFile(imatePath2, { encoding: 'base64' }, (jpgErr2, jpgBase642) => {
if (!jpgErr2 && jpgBase642) {
response.image2 = {
filename: path.basename(imatePath2),
// Bild 1
fs.readFile(imagePath, { encoding: 'base64' }, (jpgErr, jpgBase64) => {
if (!jpgErr && jpgBase64) {
response.imageFile = {
filename: imageFilename,
mimeType: 'image/jpeg',
contentBase64: jpgBase642
contentBase64: jpgBase64
};
}
res.json(response);
// Bild 2
fs.readFile(imatePath2, { encoding: 'base64' }, (jpgErr2, jpgBase642) => {
if (!jpgErr2 && jpgBase642) {
response.image2 = {
filename: path.basename(imatePath2),
mimeType: 'image/jpeg',
contentBase64: jpgBase642
};
}
// ✅ jetzt erst senden
res.json(response);
});
});
});
});
//--
});
});