问题描述
对于网络钓鱼检测,我使用模板与 OpenCV 匹配将数千个徽标与潜在网络钓鱼页面的屏幕截图进行比较:
def doShot(file_path,ref_path,results):
colorread = 1
shot = cv2.imread(file_path,colorread)
scale_percent = 40 # percent of original size
width = int(shot.shape[1] * scale_percent / 100)
height = int(shot.shape[0] * scale_percent / 100)
dim = (width,height)
scaled_shot = cv2.resize(shot,dim,interpolation = cv2.INTER_AREA)
matches = []
dir_list = sorted(os.listdir(ref_path))
for f in dir_list:
fpath = os.path.join(ref_path,f)
template = cv2.imread(fpath,colorread)
# Scale the template in varIoUs sizes
for i in [0.9,1,1.1]:
width = int(template.shape[1] * (scale_percent * i) / 100)
height = int(template.shape[0] * (scale_percent * i) / 100)
dim = (width,height)
scaled_template = cv2.resize(template,interpolation = cv2.INTER_AREA)
res = cv2.matchTemplate(scaled_shot,scaled_template,cv2.TM_CCOEFF_norMED)
min_val,max_val,min_loc,max_loc1 = cv2.minMaxLoc(res)
if max_val > 0.92:
return True
return False
为了获得性能,我缩小了图像,但是比较所有徽标需要几分钟时间。如何让算法更快?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)