From debbf5ff1f0e5868d02e4b34138195ddaf7d2244 Mon Sep 17 00:00:00 2001 From: folx bot Date: Thu, 27 Aug 2026 04:58:48 +0200 Subject: [PATCH] =?UTF-8?q?Zaris=20naslovnic=20iz=20zaznave=20obrazov=20(O?= =?UTF-8?q?penCV)=20namesto=20LLM=20ugibanja=20=E2=80=94=20glave=20se=20ne?= =?UTF-8?q?=20rezejo=20vec?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/focal-point.ts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/server/focal-point.ts b/server/focal-point.ts index 044cc49..4915f86 100644 --- a/server/focal-point.ts +++ b/server/focal-point.ts @@ -7,6 +7,23 @@ const openai = new OpenAI({ baseURL: process.env.AI_INTEGRATIONS_OPENAI_BASE_URL, }); + +// Zaris iz zaznave obrazov (OpenCV) — /opt/folxtv-uploads/focal_points.json, +// ki ga polni /opt/folx-fix/focal_calc.py na openclaw1. LLM je zaris ugibal in +// je pri portretnih slikah rezal glave, zato ima ta datoteka prednost. +const DETECTED_PATH = path.join(process.cwd(), "client/public/uploads/focal_points.json"); +let detected: Record = {}; +let detectedMtime = 0; +function loadDetected() { + try { + const st = fs.statSync(DETECTED_PATH); + if (st.mtimeMs === detectedMtime) return; + detected = JSON.parse(fs.readFileSync(DETECTED_PATH, "utf-8")); + detectedMtime = st.mtimeMs; + console.log("[focal-point] zaznanih zarisov:", Object.keys(detected).length); + } catch {} +} + const cache = new Map(); const manualOverrides: Record = { @@ -33,6 +50,11 @@ export async function analyzeFocalPoint(imagePath: string): Promise<{ x: number; cache.set(originalPath, manualOverrides[originalPath]); return manualOverrides[originalPath]; } + loadDetected(); + if (detected[originalPath]) { + cache.set(originalPath, detected[originalPath]); + return detected[originalPath]; + } if (cache.has(originalPath)) { return cache.get(originalPath)!; } @@ -102,9 +124,14 @@ export async function analyzeAllArticleImages(articles: Array<{ coverImage: stri } export function getCachedFocalPoints(): Record { + loadDetected(); const result: Record = {}; for (const [key, value] of cache.entries()) { result[key] = value; } + // zaznani zaris ima prednost pred LLM ugibanjem + for (const [key, value] of Object.entries(detected)) { + result[key] = value; + } return result; }