im stuff
This commit is contained in:
parent
58ff242241
commit
7c53328001
1 changed files with 14 additions and 2 deletions
|
@ -141,9 +141,21 @@ export default defineComponent({
|
||||||
},
|
},
|
||||||
|
|
||||||
caption() {
|
caption() {
|
||||||
const img = document.getElementById('imgtocaption');
|
const getBase64FromUrl = async (url) => {
|
||||||
|
const data = await fetch(url);
|
||||||
|
const blob = await data.blob();
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const reader = new FileReader();
|
||||||
|
reader.readAsDataURL(blob);
|
||||||
|
reader.onloadend = () => {
|
||||||
|
const base64data = reader.result;
|
||||||
|
resolve(base64data);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
const img = document.getElementById('imgtocaption') as HTMLImageElement;
|
||||||
Tesseract.recognize(
|
Tesseract.recognize(
|
||||||
img,
|
getBase64FromUrl(img.src),
|
||||||
'eng',
|
'eng',
|
||||||
{ logger: m => console.log(m) },
|
{ logger: m => console.log(m) },
|
||||||
).then(({ data: { text } }) => {
|
).then(({ data: { text } }) => {
|
||||||
|
|
Loading…
Reference in a new issue