将 ICDAR 2015 的 Ground Truth 标注在图像数据上
因为要标注数据,数据集是 ICDAR 2015 比赛中的 Challenge 4: Incidental Scene Text。
原图及标注的图像,还有给定的 ground truth 文件如下所示:
最左边是原图,中间是标注的图像,右边是 ground truth 文件内容,按顺时针顺序的坐标: x1,y1,x2,y2,x3,y3,x4,y4 x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4,最后是 words,但是如果是 ### 这种表示的,则表示不 care 文字的内容。
用 python 将 ground truth 框住文字,代码如下:
import os
import path
import glob
import Image, ImageDraw# ground truth directory
gt_text_dir = "/home/chenxp/Documents/Hitachi/ICDAR_2015/ICDAR2015_ch4/ch4_training_localization_transcription_gt"# original images directory
image_dir = "/home/chenxp/Documents/Hitachi/ICDAR_2015/ICDAR2015_ch4/*.jpg"
imgDirs = []
imgLists = glob.glob(image_dir)# where to save the images with ground truth boxes
imgs_save_dir = "/home/chenxp/Documents/Hitachi/ICDAR_2015/ICDAR_with_GT"for item in imgLists:imgDirs.append(item)for img_dir in imgDirs:img = Image.open(img_dir)dr = ImageDraw.Draw(img) img_basename = os.path.basename(img_dir)(img_name, temp2) = os.path.splitext(img_basename)# open the ground truth text fileimg_gt_text_name = "gt_" + img_name + ".txt"print img_gt_text_namebf = open(os.path.join(gt_text_dir, img_gt_text_name)).read().decode("utf-8-sig").encode("utf-8").splitlines()for idx in bf:rect = []spt = idx.split(',')rect.append(float(spt[0]))rect.append(float(spt[1]))rect.append(float(spt[2]))rect.append(float(spt[3]))rect.append(float(spt[4]))rect.append(float(spt[5]))rect.append(float(spt[6]))rect.append(float(spt[7]))# draw the polygon with (x_1, y_1, x_2, y_2, x_3, y_3, x_4, y_4)dr.polygon((rect[0], rect[1], rect[2], rect[3], rect[4], rect[5], rect[6], rect[7]), outline="red")img.save(os.path.join(imgs_save_dir, img_basename))
上面代码中间有一句话:
bf = open(os.path.join(gt_text_dir, img_gt_text_name)).read().decode("utf-8-sig").encode("utf-8").splitlines()
如果没有 decode("utf-8-sig").encode("utf-8")
这句话,那么在解析 ground truth 的 txt 文件时,会在首行多处下面的东西,如下所示:
看到了吗?第一行 \xef\xbb\xbf
,这是什么鬼?
Google 一下,在 stackoverflow 上有个问答:Split function add: \xef\xbb\xbf…\n to my list:
原来是 txt 文件编码包含了 UTF-8 BOM。
最后标注的结果如下:
将 ICDAR 2015 的 Ground Truth 标注在图像数据上相关推荐
- <视觉>——Ground truth的含义
机器学习包括有: 监督学习---(supervised learning) 无监督学习---(unsupervised learning) 半监督学习---(semi-supervised learn ...
- ground truth 理解
监督学习:指数据已经被标定了,比如:数据A标定为true,数据B标定为False. 那只有正确标定的数据才为ground truth,比如把数据A标定为true,A也确实为true那A才为ground ...
- 图像中里面的Ground Truth
经常会在一些项目中,遇到Ground Truth,例如把其中的某种图像类型叫做Ground True, 下面介绍一下: 一.Ground True的介绍 下从机器学习说起,什么叫做Ground Tru ...
- 在机器学习中,ground truth是什么意思?
维基百科对Ground Truth在机器学习领域的解释是: 在机器学习中,"ground truth"一词指的是训练集对监督学习技术的分类的准确性.这在统计模型中被用来证明或否定研 ...
- 数据集 —— ground truth 数据集
1. matlab 自带含 ground truth 数据集 %% 加载停车标志数据到内存: data = load('stopSignsAndCars.mat', 'stopSignsAndCars ...
- 论文笔记之:Playing for Data: Ground Truth from Computer Games
Playing for Data: Ground Truth from Computer Games ECCV 2016 Project Page:http://download.visinf.tu- ...
- 图像中里面的Ground Truth是什么意思
图像中里面的Ground Truth是什么意思 文章目录: 一.Ground True的介绍 二.图像中的Ground True的介绍 经常会在一些项目中,遇到Ground Truth,例如把其中的某 ...
- ground truth的含义
ground truth在不同的地方有不同的含义,下面是参考维基百科的解释,ground truth in wikipedia. 1.在统计学和机器学习中 在机器学习中ground truth表示有监 ...
- 深度学习: ground truth 解释
一.解释一 就是参考标准,一般用来做error quantification 比方说要根据历史数据预测某一时间的温度,ground truth就是那个时间的真实温度. error就是(predicte ...
最新文章
- Mac写文件到U盘的方法
- 深度学习核心技术精讲100篇(四十七)-做推荐系统之余,我们该思考什么?
- 修改oracle用户登录密码
- Android Linux内核编译调试
- mysql 故障案例_mysql故障案例
- 科技领袖技术大亨们被指是现代强盗:不仅赚钱还想垄断
- Spark 简介与安装部署
- ES:记录curator+nfs进行索引备份、创建快照的一次实践
- ArchLinux学习之环境变量
- 递归函数合式分解python_零基础学python-18.2 递归函数与分解递归函数的执行步骤
- Android Studio 安装说明
- Android文件资源(raw/data/asset)的存取
- dev cpp的常用快捷键
- 硬件知识:固态硬盘和机械硬盘区别
- apple tv 开发_如何在新的Apple TV上重新排列,配置和删除应用程序和游戏
- 以太坊网络重启并开启rpc
- 微信小程序特殊效果合集第一期
- 小型固定翼无人机集群仿真演示平台
- 社保管理系统连接不上服务器,社保费客户端登录服务器异常
- 移动端键盘弹出后,导致背景图片上移解决方法(MUI)