convert domainCheck to regular directory

This commit is contained in:
Your Name
2026-04-16 13:33:06 +08:00
parent e406d73334
commit d37c444929
107 changed files with 254185 additions and 1 deletions

View File

@@ -0,0 +1,53 @@
# -*- coding: utf-8 -*-
import base64,re
import time, os,datetime, sched
import cv2
from io import BytesIO
from PIL import Image, ImageDraw, ImageFont
import requests,re
import numpy as np
class quekou():
def __init__(self):
self.t = int(time.time() * 1000)
pass
def save_png(self,path,con):
with open(path, "wb") as fp:
fp.write(con)
def get_distance2(self,bg,tp):
bg = base64.b64decode(bg) # base64转二进制
tp = base64.b64decode(tp) # base64转二进制
res = self.det.slide_match(tp, bg, simple_target=True)
res=res['target'][0]
return res
def get_distance(self, bg, tp):
bg = base64.b64decode(bg) # base64转二进制
tp = base64.b64decode(tp) # base64转二进制
''' bg: 背景图片 tp: 缺口图片 out:输出图片 '''
# 读取背景图片和缺口图片
bg_img = Image.open(BytesIO(bg)) # 背景图片
tp_img = Image.open(BytesIO(tp)) # 缺口图片
bg_edge = cv2.Canny(np.array(bg_img), 100, 200)
tp_edge = cv2.Canny(np.array(tp_img), 100, 200)
# 转换图片格式
bg_pic = cv2.cvtColor(bg_edge, cv2.COLOR_GRAY2RGB)
tp_pic = cv2.cvtColor(tp_edge, cv2.COLOR_GRAY2RGB)
# 缺口匹配
res = cv2.matchTemplate(bg_pic, tp_pic, cv2.TM_CCOEFF_NORMED)
min_val, max_val, min_loc, max_loc = cv2.minMaxLoc(res) # 寻找最优匹配
# 绘制方框
tl = max_loc # 左上角点的坐标
return tl[0]