feat : 代码梳理 移除所有敏感密钥 通过环境变量方式配置
All checks were successful
git commit AiDA python develop 分支构建部署 / scheduled_deploy (push) Has been skipped
All checks were successful
git commit AiDA python develop 分支构建部署 / scheduled_deploy (push) Has been skipped
This commit is contained in:
@@ -1,10 +1,7 @@
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
|
||||
from skimage.morphology import skeletonize
|
||||
import cv2
|
||||
import numpy as np
|
||||
from PIL import Image
|
||||
|
||||
from app.service.utils.new_oss_client import oss_get_image
|
||||
|
||||
@@ -47,26 +44,32 @@ class LoadImage:
|
||||
# else:
|
||||
# result['gray'] = cv2.cvtColor(result['image'], cv2.COLOR_BGR2GRAY)
|
||||
|
||||
result['gray'] = self.get_lines(cv2.cvtColor(result['image'], cv2.COLOR_BGR2GRAY), result['path'])
|
||||
result['gray'] = self.get_lines(cv2.cvtColor(result['image'], cv2.COLOR_BGR2GRAY))
|
||||
result['keypoint'] = self.get_keypoint(result['name'])
|
||||
result['img_shape'] = result['image'].shape
|
||||
result['ori_shape'] = result['image'].shape
|
||||
return result
|
||||
|
||||
def get_lines(self, img, path):
|
||||
@staticmethod
|
||||
def get_lines(img):
|
||||
binary = cv2.adaptiveThreshold(img, 255,
|
||||
cv2.ADAPTIVE_THRESH_GAUSSIAN_C,
|
||||
cv2.THRESH_BINARY_INV,
|
||||
25, 10)
|
||||
binary_bool = binary > 0
|
||||
skeleton = skeletonize(binary_bool, method='zhang')
|
||||
mask = skeleton
|
||||
result = np.ones_like(img) * 255
|
||||
result[mask] = img[mask]
|
||||
|
||||
# 步骤2:细化边缘(可选,让线条更干净)
|
||||
# kernel = np.ones((1, 1), np.uint8)
|
||||
# clean = cv2.morphologyEx(binary, cv2.MORPH_OPEN, kernel)
|
||||
|
||||
thinned = cv2.ximgproc.thinning(binary, thinningType=cv2.ximgproc.THINNING_ZHANGSUEN) # thinning算法细化线条
|
||||
mask = thinned > 0
|
||||
result = np.ones_like(img) * 255
|
||||
result[mask] = img[mask]
|
||||
# thinned = cv2.ximgproc.thinning(binary, thinningType=cv2.ximgproc.THINNING_ZHANGSUEN) # thinning算法细化线条
|
||||
# mask = thinned > 0
|
||||
# result = np.ones_like(img) * 255
|
||||
# result[mask] = img[mask]
|
||||
|
||||
# 步骤3:反转回 白底黑线
|
||||
# lines = cv2.bitwise_not(thinned)
|
||||
|
||||
Reference in New Issue
Block a user