Recognizer: iterate on solutions first
This commit is contained in:
parent
1646e71222
commit
638594aab4
@ -139,9 +139,9 @@ export default class Recognizer extends React.Component<IRecognizerProps, IRecog
|
|||||||
}
|
}
|
||||||
|
|
||||||
let solutions = [];
|
let solutions = [];
|
||||||
|
for (let s of this.state.solutions) {
|
||||||
for (let y = 0; y < this.state.cells.length; y++) {
|
for (let y = 0; y < this.state.cells.length; y++) {
|
||||||
for (let x = 0; x < this.state.cells[y].length; x++) {
|
for (let x = 0; x < this.state.cells[y].length; x++) {
|
||||||
for (let s of this.state.solutions) {
|
|
||||||
let answer = this.findSolution(s.key, x, y);
|
let answer = this.findSolution(s.key, x, y);
|
||||||
if (answer) {
|
if (answer) {
|
||||||
solutions.push(answer);
|
solutions.push(answer);
|
||||||
@ -157,6 +157,9 @@ export default class Recognizer extends React.Component<IRecognizerProps, IRecog
|
|||||||
coordinates: [],
|
coordinates: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
console.debug(this.state.cells);
|
||||||
|
console.debug(solutions);
|
||||||
|
|
||||||
this.props.onRecognitionFinished({
|
this.props.onRecognitionFinished({
|
||||||
...this.state,
|
...this.state,
|
||||||
title: "Wczytano grę",
|
title: "Wczytano grę",
|
||||||
@ -192,8 +195,8 @@ export default class Recognizer extends React.Component<IRecognizerProps, IRecog
|
|||||||
|
|
||||||
const text = await recognizeTextOnImage(tempCanvas);
|
const text = await recognizeTextOnImage(tempCanvas);
|
||||||
let solutions = this.state.solutions.slice();
|
let solutions = this.state.solutions.slice();
|
||||||
|
const keys = text.split('\n').flatMap(t => t.split(' '));
|
||||||
for (let key of text.split("\n")) {
|
for (let key of keys) {
|
||||||
solutions.push({key, selection: {start: {x: 0, y: 0}, end: {x: 0, y: 0}}});
|
solutions.push({key, selection: {start: {x: 0, y: 0}, end: {x: 0, y: 0}}});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user