Files
appRobotVideoControls/test/AA_readTwoImages.test.js
2026-05-25 09:50:05 +02:00

49 lines
1.6 KiB
JavaScript

const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const BASE_PATH = path.join(__dirname, '..');
const PYTHON_CMD = process.platform === 'win32' ? 'python' : 'python3';
const screenshotFiles = [
'snapshot_video0_1778819665744.jpg',
'snapshot_video1_1778819665744.jpg',
];
const SOURCE_DIR = path.join(__dirname, 'data', 'screenShots');
const DEST_DIR = path.join(__dirname, 'data', 'screenshots', '1778819665744_twoCam_testResults');
describe('Camera Pose Script', () => {
beforeEach(() => {
if (!fs.existsSync(DEST_DIR)) {
fs.mkdirSync(DEST_DIR, { recursive: true });
}
screenshotFiles.forEach((file) => {
const src = path.join(SOURCE_DIR, file);
if (!fs.existsSync(src)) {
throw new Error(`Missing test fixture screenshot: ${src}`);
}
});
});
afterEach(() => {
// Keep generated outputs for inspection.
});
test('should execute readTwoImages without modifying shared fixtures', () => {
const strFile0 = path.join(SOURCE_DIR, 'snapshot_video0_1778819665744.jpg');
const strFile1 = path.join(SOURCE_DIR, 'snapshot_video1_1778819665744.jpg');
const command2 = `${PYTHON_CMD} "${path.join(BASE_PATH, 'programs/readTwoImages.py')}" \
-i "${strFile0}" \
-i "${strFile1}" \
-npz "${path.join(BASE_PATH, 'data/settings/callibration_cam0.npz')}" \
-npz "${path.join(BASE_PATH, 'data/settings/callibration_cam1.npz')}" \
-settings "${path.join(BASE_PATH, 'data/settings/settings1m.json')}" \
--outDir "${DEST_DIR}"`;
expect(() => {
execSync(command2, { stdio: 'inherit' });
}).not.toThrow();
});
});