src: load uploaded image
This commit is contained in:
parent
5dafe543a4
commit
c00532ce74
@ -43,17 +43,21 @@ export default class App extends React.Component {
|
||||
|
||||
handleTakePhoto(pictures: any[], _: any[]): void {
|
||||
console.log("handleTakePhoto: loading image...")
|
||||
const image = pictures[0];
|
||||
|
||||
const url = URL.createObjectURL(pictures[0]);
|
||||
const image = document.createElement('img');
|
||||
image.src = url;
|
||||
image.onload = () => {
|
||||
console.log("handleTakePhoto: finding text regions...")
|
||||
const {grid, gridWidth, gridHeight} = findTextRegions(image);
|
||||
console.log(grid, gridWidth, gridHeight);
|
||||
|
||||
image.src = "";
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
if (!grid) {
|
||||
return;
|
||||
}
|
||||
|
||||
debugger;
|
||||
|
||||
let g = grid[0][0];
|
||||
let ot = document.createElement('canvas');
|
||||
ot.width = g.w;
|
||||
@ -61,6 +65,7 @@ export default class App extends React.Component {
|
||||
ot.getContext('2d')?.putImageData(g.data, 0, 0);
|
||||
document.body.appendChild(ot);
|
||||
}
|
||||
}
|
||||
|
||||
renderAnswers(): Array<JSX.Element> {
|
||||
return this.game.solutions.map(s => s.key).map(k =>
|
||||
|
@ -179,7 +179,7 @@ export function findTextRegions(image, maxWhiteSpace, maxFontLineWidth, minTextW
|
||||
|
||||
// hopefully we matched every letter in the grid
|
||||
if (gridWidth * gridHeight !== segments.length) {
|
||||
console.warning("findTextRegions(): Dimensions are not equal to the number of matches");
|
||||
console.warn("findTextRegions(): Dimensions are not equal to the number of matches");
|
||||
}
|
||||
|
||||
// prepare grid for letters
|
||||
|
Loading…
Reference in New Issue
Block a user