200326 TIL

hy9202·3일 전
0

Immersive_TIL📓

목록 보기
73/74

import React, { useEffect, useState } from "react";
import ImageUploader from "react-images-upload";
import { createWorker } from "tesseract.js";
import { StepConnector } from "@material-ui/core";
import image from "./reactjs-redux.jpeg";
import image_png from "./js.png";
//* (ref: https://www.npmjs.com/package/react-images-upload)

export default class FileUploader_image extends React.Component {
constructor(props) {
super(props);
this.state = {
image: image,
ocr: "Recognizing..."
};
this.onDrop = this.onDrop.bind(this);
this.doOCR = this.doOCR.bind(this);
// this.detectText = this.detectText.bind(this);
}

worker = createWorker({
logger: m => console.log(m)
});

onDrop(imageData) {
console.log(imageData);
// Tesseract.recognize(imageData, "eng").then(function(result) {
// console.log(result);
// });
this.setState({
image: imageData
});
}

doOCR = async () => {
// console.log("image", this.state.image);
await this.worker.load();
await this.worker.loadLanguage("eng");
await this.worker.initialize("eng");
const {
data: { text }
// } = await this.worker.recognize(this.state.image);
//? } = await this.worker.recognize(image);
// } = await this.worker.recognize(image);
} = await this.worker.recognize(image_png);

};

// setOCR() {
// this.setState({
// ocr: text
// });
// }

// componentDidMount() {
// this.doOCR();
// }

render() {
const { handleImage } = this.props;
return (

}
}

profile
JavaScript를 공부하고 있습니다:)

0개의 댓글