Caltech Pedestrian Detection数据的预处理
参考博客链接:
- https://blog.csdn.net/a2008301610258/article/details/45873867
- https://github.com/hizhangp/caltech-pedestrian-converter
- http://www.kanadas.com/program-e/2015/06/converting_caltech_pedestrian.html
需要实现的功能:
- 将seq格式的视频文件提取图片,保存为.jpg格式的图片。
- 将vbb格式的bounding box标注文件转换为txt文件,供darknet,caffe-ssd等模型进行训练。
目的:训练yolov3和yolo-v3-tiny,需要大规模的行人检测数据集,因此就选到了Caltech Pedestrian Detection这个数据集。
从seq格式文件提取图片并保存
#-*-coding:utf-8-*-
import os
import numpy as np
import cv2
import os.path
import fnmatch
import shutildef open_save(file,savepath):# read .seq file, and save the images into the savepathf = open(file,'rb')string = str(f.read())splitstring = "\xFF\xD8\xFF\xE0\x00\x10\x4A\x46\x49\x46"# split .seq file into segment with the image prefixstrlist=string.split(splitstring)f.close()count = 0# delete the image folder path if it existsif os.path.exists(savepath):shutil.rmtree(savepath)# create the image folder pathif not os.path.exists(savepath):os.mkdir(savepath)# deal with file segment, every segment is an image except the first onefor img in strlist:filename = str(count)+'.jpg'filenamewithpath=os.path.join(savepath, filename)# abandon the first one, which is filled with .seq headerif count > 0:i=open(filenamewithpath,'wb+')i.write(splitstring)i.write(img)i.close()count += 1if __name__=="__main__":for i in range(11):rootdir = "./set{:02}/".format(i)print rootdir# walk in the rootdir, take down the .seq filename and filepathfor parent, dirnames, filenames in os.walk(rootdir):for filename in filenames:# check .seq file with suffixif fnmatch.fnmatch(filename,'*.seq'):# take down the filename with path of .seq filethefilename = os.path.join(parent, filename)# create the image folder by combining .seq file path with .seq filenamethesavepath = os.path.join(parent, filename.split('.')[0])print("Filename=" + thefilename)print("Savepath=" + thesavepath)open_save(thefilename,thesavepath)
效果:提取出set00/V000/1.jpg这样命令的图片,这里的图片id和下面生成的bbx的id是一一对应的
从vbb格式文件提取出bounding box
clear
clc
root_dir = 'E:/唐圣钦/person/annotations/';
path1 = dir(root_dir);
for i=3:length(path1)dir1 = path1(i).name;path2 = dir([ root_dir , dir1])for j=3:length(path2)ful_path = [root_dir, dir1, '/', path2(j).name]temp = strsplit(ful_path, '.');save_path = strcat(temp(1), '.txt');save_path = save_path{1}A = vbb('vbbLoad', ful_path );c=fopen(save_path, 'w');for i = 1:A.nFrameiframe = A.objLists(1,i);iframe_data = iframe{1,1};n1length = length(iframe_data);for j = 1:n1lengthiframe_dataj = iframe_data(j);if iframe_dataj.pos(1) ~= 0 %pos posvfprintf(c,'%d %f %f %f %f\n', i, iframe_dataj.pos(1),iframe_dataj.pos(2),iframe_dataj.pos(3),iframe_dataj.pos(4));endendendfclose(c);end
end
效果:生成annotations/set00/V000.txt这样的txt文件, 格式:id, x, y, w, h (x,y为左上角坐标)
Caltech Pedestrian Detection数据的预处理相关推荐
- 行人检测(Pedestrian Detection)资源
行人检测(Pedestrian Detection)资源 原文链接 http://hi.baidu.com/susongzhi/item/085983081b006311eafe38e7 一.论文 C ...
- 【计算机视觉】论文笔记:Ten years of pedestrian detection, what have we learned?
最近正在研究行人检测,学习了一篇2014年发表在ECCV上的一篇综述性的文章,是对行人检测过去十年的一个回顾,从dataset,main approaches的角度分析了近10年的40多篇论文提出的方 ...
- 行人检测(Pedestrian Detection)资源与更新
行人检测相关的网站链接: [1].Caltech Pedestrian Detection Benchmark: http://www.vision.caltech.edu/Image_Da ...
- Pedestrian Detection paper
一.论文 综述类的文章 [1]P.Dollar, C. Wojek,B. Schiele, et al. Pedestrian detection: an evaluation of the stat ...
- NMS by Representative Region: Towards Crowded Pedestrian Detection by Proposal Pairing
NMS by Representative Region: Towards Crowded Pedestrian Detection by Proposal Pairing Abstract 1. I ...
- 转:行人检测(Pedestrian Detection)资源
.论文 CVPR 2012 与行人检测相关的论文 [1] Contextual Boost for Pedestrian Detection YuanyuanDing, Jing Xiao [2] ...
- F2DNet: Fast Focal Detection Network for Pedestrian Detection
F2DNet 论文标题:F2DNet: Fast Focal Detection Network for Pedestrian Detection 论文地址:https://arxiv.org/abs ...
- 行人检测--What Can Help Pedestrian Detection?
What Can Help Pedestrian Detection? CVPR2017 本文主要分析 extra features 对于 基于CNN 的行人检测有什么帮助,设计了一个行人检测网络 H ...
- Crosstalk Cascades for Frame-Rate Pedestrian Detection 阅读笔记
Crosstalk Cascades for Frame-Rate Pedestrian Detection (目的:逐步减少输入检测框数量) 1 介绍 (说明已存在方法很慢,引出本文的算法.略... ...
最新文章
- 技术图文:如何利用C#实现Huffman编码?
- 邮箱@topgrid.cn是什么网站_典 藏 网 站 !
- 【 Notes 】INS Preliminary Introduction
- JZOJ 4910. 【NOIP2017模拟12.3】子串
- HTML 5 Web 存储-localStorage
- 某狸子订单系统豪华版/商城/前台程序/会员模块/增加分销模块
- 添加的oracle语句,Oracle中Insert语句的总结
- JSP 九大内置对象及作用域(源码刨析,建议收藏)
- 第一次个人项目【词频统计】——PSP表格
- android 开发套件_Android套件
- WEB前端、后端的说明
- Qt Building the android package failed! 构建失败
- OBS录制的时候黑屏怎么办
- EcShop二次开发学习方法和Ecshop二次开发必备基础
- markdowm快捷键学习
- 测试结果OK、NG、NT、POK的意思
- Ubuntu系统shipyard安装
- 关于Linux中的SIGABRT信号
- 数据库基本知识-总结
- OpenCV cvBoundingRect应用举例