selenium-Javaloading
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了selenium-Javaloading相关的知识,希望对你有一定的参考价值。
参考技术A 等待之一。线程等待:Thread.sleep(xxxx)只要在case中加入sleep就会强制等待设置的时间后才会执行之后的命令,这种等待一般适用于调试脚本的时候。隐试等待:driver.manage().timeouts().implicitlyWait(xx,TimeUnit.SECONDS)隐式等待,是设置的全局等待。显示等待:newWebDriverWait(driver,xx).until(ExpectedConditions.presenceOfElementLocated(By))。
ctd数据格式转普通坐标点
ctd_label2pt.py
import numpy as np
import cv2
import random
import os
def get_absolute_path(p):
if p.startswith('~'):
p = os.path.expanduser(p)
return os.path.abspath(p)
def read_lines(p):
"""return the text in a file in lines as a list """
p = get_absolute_path(p)
f = open(p,'r')
return f.readlines()
def replace_all(s, old, new, reg = False):
if reg:
import re
targets = re.findall(old, s)
for t in targets:
s = s.replace(t, new)
else:
s = s.replace(old, new)
return s
def remove_all(s, sub):
return replace_all(s, sub, '')
def split(s, splitter, reg = False):
if not reg:
return s.split(splitter)
import re
return re.split(splitter, s)
def get_bboxes(img, gt_path, save_path):
h, w = img.shape[0:2]
lines = read_lines(gt_path)
bboxes = []
tags = []
for line in lines:
line = line.strip()
line = remove_all(line, '\xef\xbb\xbf')
gt = split(line, ',')
x1 = np.int(gt[0])
y1 = np.int(gt[1])
bbox = [np.int(gt[i]) for i in range(4, 32)]
bbox = np.asarray(bbox) + ([x1 * 1.0, y1 * 1.0] * 14)
with open(save_path,'a') as fw:
for cnt,val in enumerate(bbox):
val = int(val)
if cnt != len(bbox)-1:
fw.write(str(val))
fw.write(",")
else:
fw.write(str(val))
fw.write('\n')
# def get_bboxes(img, gt_path, save_path):
# h, w = img.shape[0:2]
# lines = util.io.read_lines(gt_path)
# bboxes = []
# tags = []
# for line in lines:
# line = line.strip()
# line = util.str.remove_all(line, '\xef\xbb\xbf')
# gt = util.str.split(line, ',')
#
# x1 = np.int(gt[0])
# y1 = np.int(gt[1])
#
# bbox = [np.int(gt[i]) for i in range(4, 32)]
# bbox = np.asarray(bbox) + ([x1 * 1.0, y1 * 1.0] * 14)
# with open(save_path,'a') as fw:
# for cnt,val in enumerate(bbox):
# val = int(val)
# if cnt != len(bbox)-1:
# fw.write(str(val))
# fw.write(",")
# else:
# fw.write(str(val))
# fw.write('\n')
path_text_image = "/media/data_1/2019_project_test/PSENet/data/CTW1500/train/text_image/"
path_text_label_curve = "/media/data_1/2019_project_test/PSENet/data/CTW1500/train/text_label_curve/"
path_save_txt = os.path.dirname(os.path.dirname(path_text_image)) + '/ctd2general/'
if not os.path.exists(path_save_txt):
os.makedirs(path_save_txt)
list_img = os.listdir(path_text_image)
cnt = 0
for img_name in list_img:
cnt += 1
print("cnt=%d,img=%s"%(cnt,img_name))
img_path = path_text_image + img_name
img = cv2.imread(img_path)
txt_path = path_text_label_curve + img_name.replace('.jpg','.txt')
txt_save = path_save_txt + img_name.replace('.jpg','.txt')
get_bboxes(img, txt_path, txt_save)
以上是关于selenium-Javaloading的主要内容,如果未能解决你的问题,请参考以下文章