Added logic in ocr for config
This commit is contained in:
@@ -48,10 +48,15 @@ use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
$text = (new TesseractOCR($filePath))
|
||||
->executable('/usr/bin/tesseract')
|
||||
->lang('eng')
|
||||
->psm(6)
|
||||
->psm(6) // treats the image as a block of text
|
||||
->config(['tessedit_char_whitelist' => '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'])
|
||||
->run();
|
||||
|
||||
return response()->json(['success' => true, 'text' => $text]);
|
||||
//return response()->json(['success' => true, 'text' => $text]);
|
||||
$lines = preg_split('/\r\n|\r|\n/', $text);
|
||||
$serials = array_filter(array_map('trim', $lines), fn($line) => preg_match('/^[A-Z0-9]+$/', $line));
|
||||
|
||||
return response()->json(['success' => true, 'text' => $serials]);
|
||||
}
|
||||
//catch (\Exception $e) {
|
||||
// return response()->json(['success' => false, 'error' => $e->getMessage()]);
|
||||
|
||||
Reference in New Issue
Block a user