Changed return json response in ocr
This commit is contained in:
@@ -52,15 +52,15 @@ use thiagoalessio\TesseractOCR\TesseractOCR;
|
|||||||
->config(['tessedit_char_whitelist' => '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'])
|
->config(['tessedit_char_whitelist' => '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'])
|
||||||
->run();
|
->run();
|
||||||
|
|
||||||
//return response()->json(['success' => true, 'text' => $text]);
|
return response()->json(['success' => true, 'text' => $text]);
|
||||||
$lines = preg_split('/\r\n|\r|\n/', $text);
|
// $lines = preg_split('/\r\n|\r|\n/', $text);
|
||||||
$serials = array_filter(array_map('trim', $lines), fn($line) => preg_match('/^[A-Z0-9]+$/', $line));
|
// $serials = array_filter(array_map('trim', $lines), fn($line) => preg_match('/^[A-Z0-9]+$/', $line));
|
||||||
|
|
||||||
//return response()->json(['success' => true, 'text' => $serials]);
|
//return response()->json(['success' => true, 'text' => $serials]);
|
||||||
return response()->json([
|
// return response()->json([
|
||||||
'success' => true,
|
// 'success' => true,
|
||||||
'text' => array_values($serials), // send as array
|
// 'text' => array_values($serials), // send as array
|
||||||
]);
|
// ]);
|
||||||
}
|
}
|
||||||
//catch (\Exception $e) {
|
//catch (\Exception $e) {
|
||||||
// return response()->json(['success' => false, 'error' => $e->getMessage()]);
|
// return response()->json(['success' => false, 'error' => $e->getMessage()]);
|
||||||
|
|||||||
Reference in New Issue
Block a user