Caltech Pedestrian Data 转化程序


首先去 点击打开链接 下载数据


由于下载下来的数据是seq格式的(annotations是vbb格式的),而我想要的是jpg格式的一张张的图片,想要的annotations是txt格式的,官方的意思是你的下载两个工具包转化一下,工具包地址 点击打开链接点击打开链接

无奈觉得 Piotr Dollar 的代码写的有点乱,不知道具体用哪个函数,所以自己写了两个接口(都分别放在两个工具包里面!):


1.main函数放在了 C:\Users\hp\Desktop\piotr_toolbox\toolbox\videos\下,将seq格式转化成jpg格式,代码如下:

function main()
a = [0 1 2 3 4 5];
disp('Begin to extract image from seq file....')
for i = 1:6 
    name = ['C:\Users\hp\Desktop\DATA\caltech\set0',num2str(a(i))];
    Dir = ['C:\Users\hp\Desktop\DATA\caltech\set00',num2str(a(i))];
    
    str = dir(name);
    for j = 3:numel(str)
        Name = [name,'\',str(j).name];
        p1 = findstr(Name,'V');
        p2 = findstr(Name,'.');
        strline = Name(1,p1:p2-1);
        DIR = [Dir,'\',strline];
        mkdir(DIR);
        disp(Name)
        Is = seqIo( Name,'toImgs',DIR );
    end      
end
disp('Done......')
end

2.vbb_read函数放在C:\Users\hp\Desktop\code3.2.1\下,将vbb格式的annotations转化成txt格式的,代码如下:

function read_vbb()
% this function is to convert vbb file to txt
%by dachao at 2015.11.27
a = [0 1 2 3 4 5];
vPath = 'C:\Users\hp\Desktop\annotations\';
outpath = 'C:\Users\hp\Desktop\annotations\caltechAnnotations'; 
if ~isdir(outpath)
    mkdir(outpath);
end
disp('Begin to extract annotations from vbb....')
for ii = 1:length(a)
    vName = ['set0',num2str(a(ii))];  
    vbbpath = [vPath vName];
    str = dir(vbbpath);
    for k = 3:numel(str)
        finalpath = [vbbpath,'\',str(k).name]; 
        disp(finalpath);
        A = vbb( 'vbbLoad', finalpath);  
        Path = [outpath,'\',vName];
        if ~isdir(Path)
            mkdir(Path);
        end
        st = str(k).name;
        p = findstr(st,'.');
        st = st(1,1:p(1)-1);
        fnm = [st,'.txt'];     
        c=fopen([Path,'\',fnm],'w');  
        for i = 1:A.nFrame  
            iframe = A.objLists(1,i);  
            iframe_data = iframe{1,1};  
            n1length = length(iframe_data);  
            for  j = 1:n1length  
                iframe_dataj = iframe_data(j);  
                if iframe_dataj.pos(1) ~= 0  %pos  posv  
                    fprintf(c,'%d %f %f %f %f\n', i, iframe_dataj.pos(1),...
                     iframe_dataj.pos(2),iframe_dataj.pos(3),iframe_dataj.pos(4));  
                end  
            end  
        end  
    end
fclose(c); 
end
disp('Done................')
end




你可能感兴趣的:(matlab)