zouyu
2025-09-26 3fbbfcc8f509c352c58dc8a126220b49b72ed5a0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
package com.xindao.ocr.swingui.controller;
 
import com.xindao.ocr.swingui.dto.OcrDTO;
import com.xindao.ocr.swingui.service.OcrService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@RequestMapping("/ocr")
public class OcrController {
 
    @Autowired
    private OcrService ocrService;
 
    @PostMapping("/recognize")
    public String recognizeText(@RequestBody OcrDTO ocrDTO) {
        // 这里应该调用OCR模型进行文本识别
        // 由于具体实现依赖于OCR库,这里仅返回一个空列表作为示例
        return ocrService.ocr(ocrDTO.getImagePath());
    }
 
}