Issues with setting up and multiple languages #968
Unanswered
RoseSamaras
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Can you provide a minimal, reproducible example of the issue? While this OP does contain code, it is not something that can be easily run by other users, and no example images are provided. You are most likely to get a response if you can replicate the issue using the example code (modified as needed to replicate the issue) and providing image(s). |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello people, I am Rose from Greece, I am building a business card reader, and I am having lots of issues with language packs, I am a noob and I use a lot of claude to help me, but i cant make it work, results are really bad, and it doesnt read Greek at all, can anyone help?
BusinessCardScanner.jsx
import React, { useState, useRef, useEffect } from 'react';
import {
Button,
VStack,
Image,
useToast,
Box,
Text,
HStack,
Center,
Spinner,
Progress,
IconButton,
Icon
} from '@chakra-ui/react';
import Webcam from 'react-webcam';
import jsQR from 'jsqr';
import { parseVCard, parseBusinessCard } from '../utils/dataExtraction';
import OCRService from '../services/ocrService';
import { MdCameraAlt, MdRefresh } from 'react-icons/md';
import { RiQrScanLine, RiCameraLine, RiRefreshLine } from 'react-icons/ri';
const CAPTURE_OPTIONS = {
width: 1920,
height: 1080,
facingMode: 'environment'
};
// BusinessCardScanner.jsx
const BusinessCardScanner = ({ onExtractedData }) => {
const [mode, setMode] = useState('qr'); // 'qr' or 'card'
const [capturedImage, setCapturedImage] = useState(null);
const [isProcessing, setIsProcessing] = useState(false);
const [extractedText, setExtractedText] = useState([]);
const [scanProgress, setScanProgress] = useState(0);
const [isInitialized, setIsInitialized] = useState(false);
const webcamRef = useRef(null);
const qrIntervalRef = useRef(null);
const canvasRef = useRef(document.createElement('canvas'));
const toast = useToast();
// QR Code scanning
useEffect(() => {
if (mode !== 'qr' || !webcamRef.current || isProcessing) return;
}, [mode, isProcessing]);
// Initialize OCR
useEffect(() => {
let mounted = true;
}, [toast]);
const handleQRCode = async (data) => {
try {
setIsProcessing(true);
};
const handleCapture = async () => {
if (!webcamRef.current || !isInitialized) {
toast({
title: "Error",
description: "Camera or scanner not initialized",
status: "error",
duration: 3000,
});
return;
}
};
const preprocessImage = (imageSrc) => {
return new Promise((resolve) => {
const img = document.createElement('img');
img.onload = () => {
const canvas = canvasRef.current;
const ctx = canvas.getContext('2d');
};
const handleRetake = () => {
setCapturedImage(null);
setExtractedText([]);
setMode('qr');
setIsProcessing(false);
setScanProgress(0);
};
const toggleMode = () => {
setMode(prev => prev === 'qr' ? 'card' : 'qr');
setCapturedImage(null);
setExtractedText([]);
};
return (
<Button
colorScheme={mode === 'qr' ? 'green' : 'gray'}
onClick={() => setMode('qr')}
leftIcon={}
>
QR Code
<Button
colorScheme={mode === 'card' ? 'blue' : 'gray'}
onClick={() => setMode('card')}
leftIcon={}
>
Paper Card
);
};
export default BusinessCardScanner;
OCR Services
import { createWorker } from 'tesseract.js';
class OCRService {
static worker = null;
static isInitializing = false;
static async getWorker() {
if (OCRService.worker) {
return OCRService.worker;
}
}
static async recognize(imageSrc) {
if (!OCRService.worker) {
throw new Error('OCR worker is not initialized');
}
}
static async terminate() {
if (OCRService.worker) {
await OCRService.worker.terminate();
OCRService.worker = null;
}
}
}
export default OCRService;
Beta Was this translation helpful? Give feedback.
All reactions