From e2959df0bcde7b9c38d8c371e7217862f8746543 Mon Sep 17 00:00:00 2001 From: Artur Tamborski Date: Sun, 24 Jan 2021 02:36:36 +0100 Subject: [PATCH] src: add implementation of finding solutions --- src/components/Recognizer/Recognizer.tsx | 58 +++++++++++++++++++++++- src/helpers/recognizeTextOnImage.ts | 2 +- 2 files changed, 57 insertions(+), 3 deletions(-) diff --git a/src/components/Recognizer/Recognizer.tsx b/src/components/Recognizer/Recognizer.tsx index 52dffcd..3e2f1a3 100644 --- a/src/components/Recognizer/Recognizer.tsx +++ b/src/components/Recognizer/Recognizer.tsx @@ -35,6 +35,47 @@ export default class Recognizer extends React.Component= gridW || rd < 0 || + cd >= gridH || cd < 0 || + g[rd][cd] !== key[k]) + break; + + rd += x[dir]; + cd += y[dir]; + } + + if (k === key.length) { + cd += Math.sign(col - cd); + rd += Math.sign(row - rd); + + return { + key, + selection: { + start: {x: col, y: row}, + end: {x: cd, y: rd}, + } + } + } + } + } + handleTakePhoto(files: any[], _: any[]): void { const image = document.createElement('img'); image.src = URL.createObjectURL(files[0]); @@ -97,16 +138,29 @@ export default class Recognizer extends React.Component {