修改部分方法
This commit is contained in:
parent
eee1f44510
commit
f9d35b1ba8
@ -12,9 +12,10 @@ url_event_list : "http://erpapi.concoai.com/robot/event/page"
|
||||
url_event_detail: "http://erpapi.concoai.com/robot/event/"
|
||||
|
||||
image_save_path: "imagesDownload"
|
||||
image_save_path_ocr: "imagesOcr"
|
||||
|
||||
det_model_dir: "/home/admin-root/haotian/康达瑞贝斯/PaddleOCR-main/output/PP-OCRv4_server_det_inference"
|
||||
rec_model_dir: "/home/admin-root/haotian/康达瑞贝斯/PaddleOCR-main/output/rec_ppocr_v4_hgnet_kangda_inference"
|
||||
det_model_dir: "ocrModel/PP-OCRv4_server_det_inference"
|
||||
rec_model_dir: "ocrModel/rec_ppocr_v4_hgnet_kangda_inference"
|
||||
|
||||
|
||||
DB_HOST: "10.0.0.17"
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
import yaml
|
||||
import os
|
||||
from PIL import Image
|
||||
from paddleocr import PaddleOCR, draw_ocr
|
||||
|
||||
@ -12,7 +13,7 @@ class BadiduOcr():
|
||||
self.ocr = self._init_ocr()
|
||||
|
||||
|
||||
def image_inference(self, img_path, show_result=False):
|
||||
def image_inference(self, img_path, show_result=False, draw_result=False):
|
||||
|
||||
result = self.ocr.ocr(img_path, cls=False)
|
||||
|
||||
@ -22,6 +23,11 @@ class BadiduOcr():
|
||||
for line in res:
|
||||
print(line)
|
||||
|
||||
if draw_result:
|
||||
file_name = img_path.split("/")[-1]
|
||||
self.draw_result(result, img_path, os.path.join(self.config["image_save_path_ocr"], file_name))
|
||||
|
||||
|
||||
return result
|
||||
|
||||
def draw_result(self, result, img_path, save_path):
|
||||
|
||||
@ -10,9 +10,21 @@ class Kangda:
|
||||
|
||||
|
||||
# 获取所有事件列表
|
||||
def get_event_list(self):
|
||||
def get_event_list(self, filter = False):
|
||||
'''
|
||||
filter : true 只返回 日常巡检
|
||||
false 都返回
|
||||
'''
|
||||
token = self._login_gettoken()
|
||||
event_list = self._event_get_list(token)
|
||||
|
||||
if filter:
|
||||
event_list_filted = list()
|
||||
for event in event_list:
|
||||
if event.etypeName == "日常巡检":
|
||||
event_list_filted.append(event)
|
||||
return event_list_filted
|
||||
|
||||
return event_list
|
||||
|
||||
# 获取事件列表详情
|
||||
|
||||
@ -28,17 +28,19 @@
|
||||
|
||||
```
|
||||
├── app/
|
||||
│ ├── api/ # API接口层
|
||||
│ ├── core/ # 核心配置
|
||||
│ ├── models/ # 数据模型
|
||||
│ ├── schemas/ # 数据验证
|
||||
│ ├── services/ # 业务服务
|
||||
│ ├── tasks/ # 定时任务
|
||||
│ ├── config/ # 配置
|
||||
│ ├── core/ # 数据库核心配置
|
||||
│ ├── crud/ # 通用数据库操作
|
||||
│ ├── kandaApi/ # 第三方平台的一些测试接口
|
||||
│ ├── models/ # 数据库模型
|
||||
│ ├── service/ # 同步数据库数据
|
||||
│ └── utils/ # 工具函数
|
||||
├── tests/ # 测试用例
|
||||
├── doc/ # 项目文档
|
||||
├── alembic/ # 数据库迁移
|
||||
├── ocrModel/ # ocr模型
|
||||
├── logs/ # 日志文件
|
||||
└── config/ # 配置文件
|
||||
├── imagesDownload/ # 下载的图片
|
||||
└── imagesOcr/ # ocr结果图片
|
||||
```
|
||||
|
||||
## 3. 详细设计
|
||||
@ -167,6 +169,7 @@ pool_recycle = 1800
|
||||
### 5.2 外部接口
|
||||
|
||||
1. WebSocket接口
|
||||
|
||||
```python
|
||||
@router.websocket("/ws")
|
||||
async def websocket_endpoint(websocket: WebSocket):
|
||||
@ -179,8 +182,8 @@ pool_recycle = 1800
|
||||
except WebSocketDisconnect:
|
||||
pass
|
||||
```
|
||||
|
||||
2. 温度数据查询接口
|
||||
|
||||
```python
|
||||
@router.get("/api/v1/temperatures")
|
||||
async def query_temperatures(
|
||||
@ -190,8 +193,8 @@ pool_recycle = 1800
|
||||
) -> List[TemperatureResponse]:
|
||||
pass
|
||||
```
|
||||
|
||||
3. 处理状态查询接口
|
||||
|
||||
```python
|
||||
@router.get("/api/v1/events/{event_id}/status")
|
||||
async def get_event_status(
|
||||
@ -199,8 +202,8 @@ pool_recycle = 1800
|
||||
) -> EventStatusResponse:
|
||||
pass
|
||||
```
|
||||
|
||||
4. 获取事件列表接口
|
||||
|
||||
```python
|
||||
@router.get("/api/v1/events")
|
||||
async def get_events(
|
||||
@ -211,8 +214,8 @@ pool_recycle = 1800
|
||||
) -> List[EventResponse]:
|
||||
pass
|
||||
```
|
||||
|
||||
5. 搜索事件接口
|
||||
|
||||
```python
|
||||
@router.get("/api/v1/events/search")
|
||||
async def search_events(
|
||||
@ -222,8 +225,8 @@ pool_recycle = 1800
|
||||
) -> List[EventResponse]:
|
||||
pass
|
||||
```
|
||||
|
||||
6. 删除事件接口
|
||||
|
||||
```python
|
||||
@router.delete("/api/v1/events/{event_id}")
|
||||
async def delete_event(
|
||||
@ -231,8 +234,8 @@ pool_recycle = 1800
|
||||
) -> Dict[str, str]:
|
||||
pass
|
||||
```
|
||||
|
||||
7. 查看事件详情接口
|
||||
|
||||
```python
|
||||
@router.get("/api/v1/events/{event_id}")
|
||||
async def get_event_detail(
|
||||
|
||||
@ -12,10 +12,9 @@ from app.util.baiduOcr import BadiduOcr
|
||||
|
||||
#-------------------------测试百度ocr---------------------------------------------
|
||||
ocr = BadiduOcr()
|
||||
result = ocr.image_inference("/home/admin-root/haotian/康达瑞贝斯/imagesKangda/0a7f94b11153fc79ef2dd8b18f9eb8ec.jpeg", True)
|
||||
ocr.draw_result(result,
|
||||
"/home/admin-root/haotian/康达瑞贝斯/imagesKangda/0a7f94b11153fc79ef2dd8b18f9eb8ec.jpeg",
|
||||
"imagesOcr/1.jpeg")
|
||||
result = ocr.image_inference("/home/admin-root/haotian/康达瑞贝斯/imagesKangda/0a7f94b11153fc79ef2dd8b18f9eb8ec.jpeg"
|
||||
, True, True)
|
||||
|
||||
#-------------------------测试百度ocrend-----------------------------------------
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user