"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _a, _b;
Object.defineProperty(exports, "__esModule", { value: true });
exports.detectTrackingCameraROIsResolver = void 0;
const robotics_types_1 = require("../../../controllers/robotics-types");
const integration_base_1 = require("@things-factory/integration-base");
const env_1 = require("@things-factory/env");
const await_spawn_1 = __importDefault(require("await-spawn"));
const visionConfig = env_1.config.get('vision', {});
const program = (_b = (_a = visionConfig.camera) === null || _a === void 0 ? void 0 : _a.ROIDetector) === null || _b === void 0 ? void 0 : _b.program;
exports.detectTrackingCameraROIsResolver = {
    async detectTrackingCameraROIs(_, { name }, context) {
        const { domain } = context.state;
        var camera = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, name);
        if (!camera || camera.discriminator !== robotics_types_1.ROBOTICS_OBJECT_TYPES.CAMERA) {
            throw Error(`Tracking Camera '${name}' Not Found`);
        }
        var executable = program[0];
        var params = [...program.slice(1), name];
        var rois = await (0, await_spawn_1.default)(executable, params);
        return JSON.parse(rois.toString());
    }
};
//# sourceMappingURL=detect-tracking-camera-rois.js.map