Added exception handling to ML grid detection

This commit is contained in:
Mitchell McCaffrey 2020-10-22 12:07:30 +11:00
parent d4ccad8e0a
commit c1e67b716c

View File

@ -133,7 +133,16 @@ async function gridSizeML(image, candidates) {
export async function getGridSize(image) {
const candidates = dividers(image.width, image.height);
let prediction = await gridSizeML(image, candidates);
let prediction;
// Try and use ML grid detection
// TODO: Fix possible error on Android
try {
prediction = await gridSizeML(image, candidates);
} catch (error) {
console.error(error);
}
if (!prediction) {
prediction = gridSizeHeuristic(image, candidates);
}