- AiConfig 모델: AI API 설정 관리 - BusinessCardOcrService: Gemini Vision API 호출 - BusinessCardOcrController: OCR API 엔드포인트 - AiConfigController: AI 설정 CRUD - create.blade.php: 드래그앤드롭 명함 인식 UI - AI 설정 관리 페이지 추가
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);
|
|
}
|
|
}
|
|
}
|