vbb格式的annotations转化成txt格式

    1. function read_vbb()  
    2. this function is to convert vbb file to txt  
    3. %by dachao at 2015.11.27  
    4. a = [0 1 2 3 4 5];  
    5. vPath = 'C:\Users\hp\Desktop\annotations\';  
    6. outpath = 'C:\Users\hp\Desktop\annotations\caltechAnnotations';   
    7. if ~isdir(outpath)  
    8.     mkdir(outpath);  
    9. end  
    10. disp('Begin to extract annotations from vbb....')  
    11. for ii = 1:length(a)  
    12.     vName = ['set0',num2str(a(ii))];    
    13.     vbbpath = [vPath vName];  
    14.     str = dir(vbbpath);  
    15.     for k = 3:numel(str)  
    16.         finalpath = [vbbpath,'\',str(k).name];   
    17.         disp(finalpath);  
    18.         A = vbb( 'vbbLoad', finalpath);    
    19.         Path = [outpath,'\',vName];  
    20.         if ~isdir(Path)  
    21.             mkdir(Path);  
    22.         end  
    23.         st = str(k).name;  
    24.         p = findstr(st,'.');  
    25.         st = st(1,1:p(1)-1);  
    26.         fnm = [st,'.txt'];       
    27.         c=fopen([Path,'\',fnm],'w');    
    28.         for i = 1:A.nFrame    
    29.             iframe = A.objLists(1,i);    
    30.             iframe_data = iframe{1,1};    
    31.             n1length = length(iframe_data);    
    32.             for  j = 1:n1length    
    33.                 iframe_dataj = iframe_data(j);    
    34.                 if iframe_dataj.pos(1) ~= 0  %pos  posv    
    35.                     fprintf(c,'%d %f %f %f %f\n', i, iframe_dataj.pos(1),...  
    36.                      iframe_dataj.pos(2),iframe_dataj.pos(3),iframe_dataj.pos(4));    
    37.                 end    
    38.             end    
    39.         end    
    40.     end  
    41. fclose(c);   
    42. end  
    43. disp('Done................')  
    44. end

猜你喜欢

转载自blog.csdn.net/yzxnuaa/article/details/80536882
今日推荐