Update video frame capture dimensions to improve OCR accuracy and adjust related styles. Increase button size to 70% width and 40% height for better alignment with the OCR reading area. Increment version code to 4.72.791 to reflect these changes.

This commit is contained in:
2026-07-13 13:43:06 -04:00
parent a18f25dc84
commit 5fefdccd17
4 changed files with 35 additions and 69 deletions

View File

@ -3461,8 +3461,9 @@ a.ms1-trad-link.btn-aide-trad{
left:50%;
top:50%;
transform:translate(-50%,-50%);
width:55%;
height:30%;
/* Guide un peu large : aligne sur la zone OCR (~70% x 40% du flux). */
width:70%;
height:40%;
border:2px solid rgba(255,255,255,.95);
border-radius:8px;
box-shadow:0 0 0 100vmax rgba(0,0,0,.5);

View File

@ -493,78 +493,43 @@
if (!matches || !matches.length) {
return '';
}
var num = matches[0];
// Si plusieurs groupes (bruit OCR), garder le plus long s'il est unique en longueur.
if (matches.length > 1) {
matches.sort(function (a, b) { return b.length - a.length; });
if (matches[0].length === matches[1].length) {
return '';
if (matches.length === 1) {
var one = matches[0];
return (one.length >= 1 && one.length <= BIB_MAX_LEN) ? one : '';
}
// OCR decoupe souvent un dossard manuscrit en chiffres isoles ("5" "2" "1").
var allSingles = true;
var i;
for (i = 0; i < matches.length; i++) {
if (matches[i].length !== 1) {
allSingles = false;
break;
}
num = matches[0];
}
if (num.length < 1 || num.length > BIB_MAX_LEN) {
return '';
if (allSingles) {
var joined = matches.join('');
return (joined.length <= BIB_MAX_LEN) ? joined : '';
}
return num;
// Sinon : le groupe le plus long s'il domine clairement (evite 2 dossards).
var sorted = matches.slice().sort(function (a, b) { return b.length - a.length; });
if (sorted[0].length <= BIB_MAX_LEN && sorted[0].length > sorted[1].length) {
return sorted[0];
}
return '';
}
// Rectangle source visible avec object-fit:cover (ce que l'usager voit dans le carre).
function getCoverVisibleRect(videoEl, displayEl) {
var vw = videoEl.videoWidth;
var vh = videoEl.videoHeight;
var dw = displayEl.clientWidth || 1;
var dh = displayEl.clientHeight || 1;
var videoRatio = vw / vh;
var displayRatio = dw / dh;
var renderedW;
var renderedH;
var offsetX;
var offsetY;
if (videoRatio > displayRatio) {
renderedH = vh;
renderedW = vh * displayRatio;
offsetX = (vw - renderedW) / 2;
offsetY = 0;
} else {
renderedW = vw;
renderedH = vw / displayRatio;
offsetX = 0;
offsetY = (vh - renderedH) / 2;
}
return {
offsetX: offsetX,
offsetY: offsetY,
renderedW: renderedW,
renderedH: renderedH
};
}
// MSIN-4401 — Crop aligne sur le cadre blanc (~55% x 30% du viseur affiche),
// pas sur le flux brut (sinon object-fit:cover decale / elargit la zone lue).
function captureCenterFrame(videoEl, displayEl) {
// MSIN-4401 — Crop central du flux video (comme avant le polish UI).
// Zone un peu large pour un numero manuscrit entier dans le viseur.
function captureCenterFrame(videoEl) {
if (!videoEl || !videoEl.videoWidth) {
return null;
}
var cropRatioW = 0.55;
var cropRatioH = 0.3;
var sx;
var sy;
var cropW;
var cropH;
if (displayEl && displayEl.clientWidth && displayEl.clientHeight) {
var vis = getCoverVisibleRect(videoEl, displayEl);
cropW = Math.max(1, Math.round(vis.renderedW * cropRatioW));
cropH = Math.max(1, Math.round(vis.renderedH * cropRatioH));
sx = Math.round(vis.offsetX + (vis.renderedW - cropW) / 2);
sy = Math.round(vis.offsetY + (vis.renderedH - cropH) / 2);
} else {
var w = videoEl.videoWidth;
var h = videoEl.videoHeight;
cropW = Math.round(w * cropRatioW);
cropH = Math.round(h * cropRatioH);
sx = Math.round((w - cropW) / 2);
sy = Math.round((h - cropH) / 2);
}
var w = videoEl.videoWidth;
var h = videoEl.videoHeight;
var cropW = Math.round(w * 0.7);
var cropH = Math.round(h * 0.4);
var sx = Math.round((w - cropW) / 2);
var sy = Math.round((h - cropH) / 2);
var canvas = document.createElement('canvas');
var outW = cropW;
var outH = cropH;
@ -750,7 +715,7 @@
if (self.ocrBusy || !self.video || activeScan !== self || !self.workerReady) {
return;
}
var canvas = captureCenterFrame(self.video, self.captureEl);
var canvas = captureCenterFrame(self.video);
if (!canvas) {
return;
}

View File

@ -1482,7 +1482,7 @@ function fxInscrGestionRenderBibScanBlock($strBibInputId, $strLangue) {
echo '<div class="inscr-gestion-bib-scan-capture" role="button" tabindex="0">';
echo '<div class="inscr-gestion-bib-scan-video"></div>';
// Zone-cible centrale (eclaircie) : aligne le repere visuel sur la region
// reellement lue par l'OCR (captureCenterFrame : ~55% largeur x 30% hauteur).
// reellement lue par l'OCR (captureCenterFrame : ~70% largeur x 40% hauteur).
echo '<div class="inscr-gestion-bib-scan-target" aria-hidden="true"></div>';
// Pastille courte (fallback integre) — evite un long texte info qui masque le viseur.
echo '<span class="inscr-gestion-bib-scan-capture-label">'

View File

@ -7,7 +7,7 @@
* Constantes *
*
**************/
define('_VERSION_CODE', '4.72.790');
define('_VERSION_CODE', '4.72.791');
define('_DATE_CODE', '2026-07-13');
//MSIN-4290
define('QR_SECRET_KEY', 'ms1_qr_2026_cle_secrete_longue_et_fixe');