u
This commit is contained in:
@@ -376,10 +376,10 @@ apply_camera_settings() {
|
|||||||
local applied=0
|
local applied=0
|
||||||
for ctrl in $keys; do
|
for ctrl in $keys; do
|
||||||
local value
|
local value
|
||||||
value=$(echo "$values" | jq -r ".[\"$ctrl\"] // empty")
|
value=$(echo "$values" | jq -r ".\"$ctrl\" // empty")
|
||||||
if [[ -n "$value" && "$value" != "null" ]]; then
|
if [[ -n "$value" && "$value" != "null" ]]; then
|
||||||
if v4l2-ctl -d "$VIDEO_DEVICE" --set-ctrl="${ctrl}=${value}" 2>/dev/null; then
|
if v4l2-ctl -d "$VIDEO_DEVICE" --set-ctrl="${ctrl}=${value}" 2>/dev/null; then
|
||||||
((applied++))
|
((applied++)) || true
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
20
server.js
20
server.js
@@ -147,15 +147,18 @@ app.post('/upload', authenticate, upload.single('image'), async (req, res) => {
|
|||||||
const settings = allSettings[storageKey] || {};
|
const settings = allSettings[storageKey] || {};
|
||||||
|
|
||||||
// Check if we need to modify the image
|
// Check if we need to modify the image
|
||||||
if (settings.rotation || settings.crop) {
|
const shouldRotate = settings.rotation && settings.rotation !== 0;
|
||||||
|
const shouldCrop = settings.crop && settings.crop.width > 0 && settings.crop.height > 0;
|
||||||
|
|
||||||
|
if (shouldRotate || shouldCrop) {
|
||||||
console.log(`Applying transformations for ${cameraId}:`, { rotation: settings.rotation, crop: settings.crop });
|
console.log(`Applying transformations for ${cameraId}:`, { rotation: settings.rotation, crop: settings.crop });
|
||||||
let pipeline = sharp(req.file.path);
|
let pipeline = sharp(req.file.path);
|
||||||
|
|
||||||
if (settings.rotation) {
|
if (shouldRotate) {
|
||||||
pipeline = pipeline.rotate(settings.rotation);
|
pipeline = pipeline.rotate(settings.rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (settings.crop) {
|
if (shouldCrop) {
|
||||||
// crop format: { left, top, width, height }
|
// crop format: { left, top, width, height }
|
||||||
pipeline = pipeline.extract(settings.crop);
|
pipeline = pipeline.extract(settings.crop);
|
||||||
}
|
}
|
||||||
@@ -542,8 +545,19 @@ app.post('/settings/:cameraId/available', authenticate, express.json(), (req, re
|
|||||||
const allSettings = loadCameraSettings();
|
const allSettings = loadCameraSettings();
|
||||||
const existing = allSettings[storageKey] || {};
|
const existing = allSettings[storageKey] || {};
|
||||||
|
|
||||||
|
// Default config values for new entries
|
||||||
|
const defaultConfig = {
|
||||||
|
rotation: 0,
|
||||||
|
crop: { left: 0, top: 0, width: 0, height: 0 },
|
||||||
|
ocr: { enabled: false, minval: 0, maxval: 9999 },
|
||||||
|
chartLabel: null,
|
||||||
|
insertBrightnessToDb: false
|
||||||
|
};
|
||||||
|
|
||||||
// Preserve existing configured values, but update available controls
|
// Preserve existing configured values, but update available controls
|
||||||
allSettings[storageKey] = {
|
allSettings[storageKey] = {
|
||||||
|
// Start with defaults, then overlay existing config
|
||||||
|
...defaultConfig,
|
||||||
...existing,
|
...existing,
|
||||||
availableControls: controls,
|
availableControls: controls,
|
||||||
// Merge current camera values as defaults if no values configured yet
|
// Merge current camera values as defaults if no values configured yet
|
||||||
|
|||||||
Reference in New Issue
Block a user