给COCO数据集的json标签换行
//针对COCO标签只有单行,打开/修改非常慢的问题(虽然本程序跑起来也不快,但至少以后用Notepad++修改起来会快点)
#include <iostream>
#include <fstream>
#include <string>
#include <vector> using namespace std; int main(){
ifstream src("原.json");
ofstream dst("新.json"); string getall;
getline(src, getall); string space = " ";
size_t count_of_space = ;
size_t n = getall.size();
bool inmark = false;
for (size_t i = ; i < n; ++i){
char c = getall[i];
if (c < )break;
//printf("%c[%d/%d]\n", c, i, n);
if (c == '\"'){
inmark = !inmark;
}
if (inmark){
dst << c;
continue;
}
switch (c){
case '[':
case '{':
count_of_space += ;
dst << c << '\n';
for (size_t j = ; j < count_of_space; ++j)dst << space;
break;
case ']':
count_of_space -= ;
if (count_of_space < )count_of_space = ;
dst << '\n';
for (size_t j = ; j < count_of_space; ++j)dst << space;
dst << ']';
if (i + < n){
if (getall[i + ] != ','&&getall[i + ] != ',')dst << '\n';
}
break;
case '}':
count_of_space -= ;
if (count_of_space < )count_of_space = ;
dst << '\n';
for (size_t j = ; j < count_of_space; ++j)dst << space;
dst << '}';
if (i + < n){
if(getall[i + ] != ','&&getall[i + ] != ',')dst << '\n';
}
break;
case ',':
dst << ',';
case '\n':
dst << '\n';
if (count_of_space < )count_of_space = ;
for (size_t j = ; j < count_of_space; ++j)dst << space;
break;
default:
dst << c;
break;
}
} return ;
}
给COCO数据集的json标签换行的更多相关文章
- COCO 数据集的使用
Windows 10 编译 Pycocotools 踩坑记 COCO数据库简介 微软发布的COCO数据库, 除了图片以外还提供物体检测, 分割(segmentation)和对图像的语义文本描述信息. ...
- coco数据集标注图转为二值图python(附代码)
coco数据集大概有8w张以上的图片,而且每幅图都有精确的边缘mask标注. 后面后分享一个labelme标注的json或xml格式转二值图的源码(以备以后使用) 而我现在在研究显著性目标检测,需要的 ...
- COCO数据集使用
一.简介 官方网站:http://cocodataset.org/全称:Microsoft Common Objects in Context (MS COCO)支持任务:Detection.Keyp ...
- 目标检测coco数据集点滴介绍
目标检测coco数据集点滴介绍 1. COCO数据集介绍 MS COCO 是google 开源的大型数据集, 分为目标检测.分割.关键点检测三大任务, 数据集主要由图片和json 标签文件组成. c ...
- COCO数据集深入理解
TensorExpand/TensorExpand/Object detection/Data_interface/MSCOCO/ 深度学习数据集介绍及相互转换 Object segmentation ...
- COCO 数据集使用说明书
下面的代码改写自 COCO 官方 API,改写后的代码 cocoz.py 被我放置在 Xinering/cocoapi.我的主要改进有: 增加对 Windows 系统的支持: 替换 defaultdi ...
- Pascal VOC & COCO数据集介绍 & 转换
目录 Pascal VOC & COCO数据集介绍 Pascal VOC数据集介绍 1. JPEGImages 2. Annotations 3. ImageSets 4. Segmentat ...
- [PocketFlow]解决TensorFLow在COCO数据集上训练挂起无输出的bug
1. 引言 因项目要求,需要在PocketFlow中添加一套PeleeNet-SSD和COCO的API,具体为在datasets文件夹下添加coco_dataset.py, 在nets下添加pelee ...
- 在ubuntu1604上使用aria2下载coco数据集效率非常高
简单的下载方法: 所以这里介绍一种能照顾大多数不能上外网的同学的一种简单便捷,又不会中断的下载方法:系统环境: Ubuntu 14.04 方法: a. 使用aria2 搭配命令行下载.需要先安装: s ...
随机推荐
- windows下创建.gitignore
网上搜索 .gitignore 的创建,很多linux上的,而且还一样,... 尝试了几次,windows可以这样写 .svn/ .settings/ .buildpath .project
- 关于javascript中的变量对象和活动对象
https://segmentfault.com/a/1190000010339180 https://zhuanlan.zhihu.com/p/26011572 https://www.cnblog ...
- MySQL Server8.0版本时出现Client does not support authentication protocol requested by server
MySQL Server8.0版本时出现Client does not support authentication protocol requested by server 解决方法: 1.roo ...
- python 去掉重复元素 学到再添加
1. python 内置函数 set(可迭代对象) 返回无重复元素的集合.如在分类中,classification为类别数组 set(classification)为类别数 2.numpy np.un ...
- HTTP中Post与Put的区别
PUT请求是向服务器端发送数据的,从而改变信息,该请求就像数据库的update操作一样,用来修改数据的内容,但是不会增加数据的种类等,也就是说无论进行多少次PUT操作,其结果并没有不同. POST请求 ...
- 微信小程序wx.uploadFile 上传文件 的两个坑
fileUpload: function (tempFilePath) { var that = this;//坑1: this需要这么处理 wx.uploadFile({ url: url地址, / ...
- 【VIM】-NO.140.VIM.1 -【VIM】
Style:Mac Series:Java Since:2018-09-10 End:2018-09-10 Total Hours:1 Degree Of Diffculty:5 Degree Of ...
- 多个页面引用公共的头部 header.html 和尾部 footer.html
方法:通过load()函数,引入公共头部和尾部文件; js代码预览: $(".headerPage").load("header.html"); $(" ...
- Cocos Creator 构建发布... APP ABI(选项)
APP ABI 选项对应的是设备的 CPU 架构.勾选不同的值,编译出来的 apk 可以适用于不同的设备.勾选的越多,适配的机器越多.但是相应的 apk 包体越大. 需要根据自己的项目实际情况决定要编 ...
- Roomblock: a Platform for Learning ROS Navigation With Roomba, Raspberry Pi and RPLIDAR(转)
What is this? "Roomblock" is a robot platform consists of a Roomba, a Raspberry Pi 2, a ...