37 lines
867 B
PHP
37 lines
867 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace App\Http\Controllers\Api;
|
||
|
|
|
||
|
|
use App\Http\Controllers\Controller;
|
||
|
|
use App\Services\BusinessCardOcrService;
|
||
|
|
use Illuminate\Http\JsonResponse;
|
||
|
|
use Illuminate\Http\Request;
|
||
|
|
|
||
|
|
class BusinessCardOcrController extends Controller
|
||
|
|
{
|
||
|
|
public function __construct(
|
||
|
|
private BusinessCardOcrService $ocrService
|
||
|
|
) {}
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 명함 이미지 OCR 처리
|
||
|
|
*/
|
||
|
|
public function process(Request $request): JsonResponse
|
||
|
|
{
|
||
|
|
$request->validate([
|
||
|
|
'image' => 'required|string',
|
||
|
|
]);
|
||
|
|
|
||
|
|
try {
|
||
|
|
$result = $this->ocrService->extractFromImage($request->input('image'));
|
||
|
|
|
||
|
|
return response()->json($result);
|
||
|
|
} catch (\Exception $e) {
|
||
|
|
return response()->json([
|
||
|
|
'ok' => false,
|
||
|
|
'error' => $e->getMessage(),
|
||
|
|
], 500);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|