70 lines
1.8 KiB
JavaScript
70 lines
1.8 KiB
JavaScript
const fs = require('fs');
|
|
const path = require('path');
|
|
const { execFileSync } = require('child_process');
|
|
|
|
const PROJECT_PATH = process.cwd()
|
|
const TEST_PATH = path.join(__dirname, '.');
|
|
const SOURCE_DIR = path.join(__dirname,'data', 'screenShots');
|
|
const TARGET_DIR = path.join(__dirname,'data', 'screenshots', '1778819665744_detection_singleTest_testResults');
|
|
const PYTHON_CMD = process.platform === 'win32' ? 'python' : 'python3';
|
|
const TEST_SETUP_FILE = path.join(TEST_PATH, 'data', '0_testSetup.json');
|
|
const SCRIPT_FILE = path.join(PROJECT_PATH, 'programs', '1_detect_aruco_observations.py');
|
|
const ROBOT_PATH = path.join(__dirname, 'data', 'robot', 'robot.json');
|
|
|
|
|
|
const cam = {
|
|
id : 'cam1',
|
|
image: 'snapshot_video1_1779690911822.jpg',
|
|
intrinsics: path.join(PROJECT_PATH, 'data', 'settings','callibration_cam0.npz')
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
describe('Check if Python runs', () => {
|
|
|
|
test('First Run of Python', () => {
|
|
|
|
|
|
console.log('Intrinsics : ', cam.intrinsics);
|
|
execFileSync(PYTHON_CMD, [
|
|
SCRIPT_FILE,
|
|
'-i', path.join(SOURCE_DIR, cam.image),
|
|
'-npz', cam.intrinsics,
|
|
'-robot', ROBOT_PATH,
|
|
'-cameraId', cam.id
|
|
|
|
,
|
|
'-outDir', TARGET_DIR
|
|
], {
|
|
stdio: 'inherit',
|
|
cwd: SOURCE_DIR // <- wichtig
|
|
});
|
|
|
|
|
|
const resultFile = path.join(TARGET_DIR, 'snapshot_video1_1779690911822_aruco_detection.json');
|
|
|
|
if (!fs.existsSync(resultFile)) {
|
|
throw new Error(`Erwartete Datei fehlt: ${resultFile}`);
|
|
}
|
|
|
|
|
|
});
|
|
|
|
/*
|
|
// ✅ Cleanup läuft IMMER nach jedem Test
|
|
afterEach(() => {
|
|
if (!fs.existsSync(TARGET_DIR)) return;
|
|
|
|
fs.readdirSync(TARGET_DIR).forEach(file => {
|
|
fs.rmSync(path.join(TARGET_DIR, file), {
|
|
recursive: true,
|
|
force: true
|
|
});
|
|
});
|
|
});
|
|
*/
|
|
|
|
}); |