pip安装icdaru工具
icdar-tools的Python项目详细描述
这些工具是为了让研究人员努力创造自己的工作环境 这是关于处理{icdar}数据的 它为您提供了培训和测试数据的初始处理工具。 它提供了使用shapely的多边形计算文本区域的工具。 将图像和文本位置的结果保存为计算精度的前奏。 以及其他一些工具,我们将尝试“更多的例子来解释以后的使用。”
这些工具是由{east}引用和编写的。 你可以在这里看到原始文件。 https://github.com/argman/EAST/
这些工具依赖于使用前必须提供的几个库。 例如:
-opencv-3.x.x
-numpy
-scipy
-matplotlib
-shapely
使用模块!
importicdar_tools
或
fromicdar_toolsimporticdarfromicdar_toolsimporticd_utilfromicdar_toolsimportlocality_aware_nmsfromicdar_toolsimportdata_util
- icdar.py
从加载数据和定位图像中的文本和其他一些东西。 下面是使用示例。
1:get_batch()
get_batch(num_workers,**kwargs)
函数用于获取图像中文本的坐标 以相同的路径通过文本文件 然后返回这些几何坐标, 图像名称,以及仅从文本位置指定的训练图像派生的图像。
使用:
data_generator=icdar.get_batch(num_workers=num_readers,training_data_path='path/to_data/icdar15/train/'input_size=input_size,batch_size=batch_size_per_gpu*len(gpus))
路透社
yieldimages,image_fns,score_maps,geo_maps,training_masks
2:加载annoataion()
text_polys,text_tags=icdar.load_annoataion(txt_file-name)
3:还原矩形框(R)
text_box_restored=icdar.restore_rectangle_rbox(origin,geometry)
:
- icd_util.py
1-获取图像() 输入路径应为images
images_list_fullName=icd_util.get_images(path/data/images/)
重复是输入路径中所有图像的列表
2-调整图像大小()
im_resized,(ratio_h,ratio_w)=icd_util.resize_image(image)
'''
resize image to a size multiple of 32 which is required by the network
:param im: the resized image
:param max_side_len: limit of max image size to avoid out of memory in gpu
:return: the resized image and the resize ratio
'''
- 函数的默认设置
icd_util.resize_image(image,max_side_len=2400)
3-检测()
以下是在坐标和分数的几何图中表示的模型的结论
使用阈值筛选看起来错误的结果 然后重新绘制文本框的边框
返回这些框和实现此进程的时间。
boxes,timer=icd_util.detect(score_map=score,geo_map=geometry,timer=timer)
'''
restore text boxes from score map and geo map
:param score_map:
:param geo_map:
:param timer:
:param score_map_thresh: threshhold for score map
:param box_thresh: threshhold for boxes
:param nms_thres: threshold for nms
:return: boxes and time out
'''
- The default setting of the function
icd_util.detect(score_map,geo_map,timer,score_map_thresh=0.8,box_thresh=0.1,nms_thres=0.2):
- 写入结果()
此函数获取图像及其名称
文件名作为图像中的文本位置写入
您将得到该图像所需的文本框
在文本文件中写入文本位置
在图片中的文本周围画正方形
查看框的字体大小和字体颜色的传递过程
color, thickness
最后,将写入“output_path/”
图像和文本文件被写入单个文件夹。
icd_util.write_result(img,boxes,output_dir,res_file,img_fn)
- 函数的默认设置
icd_util.write_result(img,boxes,output_dir,res_file,img_fn,color=(255,255,0),thickness=1,skip=True)
…