Skip to content

feat(afis): integrate new C# matcher & hybrid minutiae pairing pipeline#153

Open
bruno12303 wants to merge 10 commits into
BiometricsUBB:masterfrom
bruno12303:feature/source-afis-slider
Open

feat(afis): integrate new C# matcher & hybrid minutiae pairing pipeline#153
bruno12303 wants to merge 10 commits into
BiometricsUBB:masterfrom
bruno12303:feature/source-afis-slider

Conversation

@bruno12303

Copy link
Copy Markdown

Description of Changes

This Pull Request introduces a custom geometric registration and minutiae-pairing algorithm developed entirely on the application's frontend, creating a hybrid solution integrated with the SourceAFIS biometric engine.

Key Features & Refactoring:

  • Custom 2D Matcher (Procrustes Analysis): Implemented an algorithm that computes centroids, rotation matrices, and translations based on 4 anchor points selected by the user.
  • Virtual Point Cloud Registration: Added a rigid transformation mechanism that maps the left image's minutiae coordinates directly onto the right image's coordinate space.
  • Pairing & Filtering (Greedy Matching): Implemented a greedy pairing mechanism ensuring strict 1-to-1 unique relationships, biological feature-type verification, and a Euclidean distance threshold (tolerance limit set to 45 pixels).
  • Dynamic Feature Limit Slider: Added a fully styled range slider to the application sidebar, allowing real-time control over the maximum number of extracted target features (range: 5-50).
  • Full Linter & TypeScript Compliance: The vertical-toolbar.tsx component was entirely refactored to reduce cognitive complexity (extracting heavy mathematical logic into clean helper functions) and satisfy strict TypeScript compiler flags (noUncheckedIndexedAccess, noPropertyAccessFromIndexSignature).

@TheMultii TheMultii left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build artifacts and binaries are committed to git - they shouldn't be committed at all. Please add src-tauri/sourceafis_cli_src/bin/ and obj/ to .gitignore and remove them from this pull request.

Committed binaries that can't be reviewed are also a supply-chain risk.

alert(
`Dopasowanie udane! Zablokowano ${manualPairs.length} punktów bazowych. Automat dobrał ${automatedPairs.length} kolejnych cech. Score: ${data.matchScore}`
);
} catch (error) {}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't swallow the error here

Comment on lines +1062 to +1065
? "Zaznacz CORE na obu zdjęciach"
: currentManualPairsCount < 4
? `Zaznacz jeszcze ${4 - currentManualPairsCount} punkty bazowe`
: "Wyodrębnij i dopasuj"}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use i18 translations. everywhere


const leftClone = Object.create(
Object.getPrototypeOf(leftCore)
) as Record<string, unknown>;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

createTransformedMarkings clones the core marking with Object.create(Object.getPrototypeOf(leftCore)) and copies enumerable keys, skipping _-prefixed ones. The codebase has real classes (RayMarking, etc.) with constructors and a labelGenerator for labels. Clones built this way may miss private fields the class methods rely on and can break rendering or serialization.

Comment on lines +86 to +97
function detectCoordinatePath(obj: AppMarking) {
if (obj.origin && typeof obj.origin.x === "number") {
return { x: obj.origin.x, y: obj.origin.y, path: "origin" };
}
if (obj.position && typeof obj.position.x === "number") {
return { x: obj.position.x, y: obj.position.y, path: "position" };
}
if (typeof obj.x === "number" && typeof obj.y === "number") {
return { x: obj.x, y: obj.y, path: "plain" };
}
return { x: 0, y: 0, path: "unknown" };
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

detectCoordinatePath duck-types origin/position/x,y at runtime (and matchWithSourceafis does the same with m.x ?? m.X), but the marking shape is known and typed in this codebase - MarkingBase always carries origin. The extra branches are dead code and the ?? 0 fallbacks would mask a real shape mismatch instead of surfacing it. Please use the typed marking interfaces directly.

return finalHybridResult;

} catch (error) {
console.error("❌ Błąd podczas hybrydowego dopasowywania SourceAFIS:", error);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✂️

leftCoreCoords: { path: string },
rightCoreCoords: { path: string },
maxCurrentLabel: number,
rozwidlenieTypeId: string,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't use polish in prop names

Comment on lines +306 to +309
name.includes("rozwidlenie") ||
display.includes("rozwidlenie") ||
name.includes("bifurcation") ||
display.includes("bifurcation")

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With custom user presets, minutiae get silently assigned to arbitrary marking types here. The existing code already has resolveSourceafisTypeId(minutia.type) - extend that instead.

Comment on lines +335 to +348
console.log(
"SŁOWNIK TYPÓW ADNOTACJI W APLIKACJI",
allMarkingTypes.map(t => ({
id: t.id,
name: t.name,
displayName: t.displayName,
}))
);
console.log(
"Przypisane ID robocze -> Rozwidlenie:",
rozwidlenieTypeId,
"Zakończenie:",
zakonczenieTypeId
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✂️


console.log("4. [Hybryda] Uruchamiam nowy Matcher C# dla obliczenia Score...");
const matcherTool = await createSourceAfisMatcherTool();
const matchResult = await matcherTool.run({

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant work in the hybrid pipeline: by this point both images have already been processed by cliTool.run, and matcherTool.run makes the C# side compute both FingerprintTemplates again from scratch - 4 extractions where 2 would do. The matcher's --out-template/--out-json outputs (matchTemplatePath/matchJsonPath) are also written and then ignored except for matchScore. Consider having the matcher accept the already-serialized templates (the old CLI already writes them via --out-template) instead of re-extracting from images.

}
},
},
*/

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the Auto-mark feature is being retired, please delete this block instead of commenting it out

Comment on lines +1036 to +1038
MarkingsStore(
CANVAS_ID.LEFT
).actions.markings.reset();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wipes all of the user's manual markings and re-adds them merged with the automated ones - if addMany throws midway (and the catch below is empty), the examiner's work is silently lost. It also bypasses GlobalHistoryManager, so undo history is destroyed. Please add only the new markings via AddOrUpdateMarkingCommand (see autoMarkWithSourceafis.ts for the existing pattern) instead of reset + re-add.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants