Changeset 1179 for trunk/src/series/rdvision_check_time.m
- Timestamp:
- Mar 23, 2025, 11:13:38 AM (4 weeks ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/series/rdvision_check_time.m
r1178 r1179 243 243 end 244 244 copyfile_modif(filexml,timestamp,newxml) 245 % [nbfield2,msg]=copyfile_modif(filexml,timestamp,newxml); %copy the xml file in the upper folder245 246 246 [XmlData,errormsg]=imadoc2struct(newxml);% check reading of the new xml file 247 247 if ~isempty(errormsg) … … 267 267 268 268 269 270 % check the existence of the expected output image files (from the xml) 271 272 273 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 274 %--------- reads a series of bin files 275 276 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 277 function [BinList,errormsg]=binread_rdv_series(PathDir,SeqData,SqbData,nbfield2,NomTypeNew) 278 % BINREAD_RDV Permet de lire les fichiers bin g???n???r???s par Hiris ??? partir du 279 % fichier seq associ???. 280 % [IMGS,TIMESTAMPS,NB_FRAMES] = BINREAD_RDV(FILENAME,FRAME_IDX) lit 281 % l'image d'indice FRAME_IDX de la s???quence FILENAME. 282 % 283 % Entr???es 284 % ------- 285 % FILENAME : Nom du fichier s???quence (.seq). 286 % FRAME_IDX : Indice de l'image ??? lire. Si FRAME_IDX vaut -1 alors la 287 % s???quence est enti???rement lue. Si FRAME_IDX est un tableau d'indices 288 % alors toutes les images d'incides correspondant sont lues. Si FRAME_IDX 289 % est un tableau vide alors aucune image n'est lue mais le nombre 290 % d'images et tous les timestamps sont renvoy???s. Les indices commencent ??? 291 % 1 et se termines ??? NB_FRAMES. 292 % 293 % Sorties 294 % ------- 295 % IMGS : Images de sortie. 296 % TIMESTAMPS : Timestaps des images lues. 297 % NB_FRAMES : Nombres d'images dans la s???quence. 298 NbBinFile=0; 299 BinSize=0; 300 fid=0; 301 errormsg=''; 302 BinList={}; 303 304 classname=sprintf('uint%d',SeqData.bytesperpixel*8); 305 306 classname=['*' classname]; 307 BitDepth=8*SeqData.bytesperpixel;%needed to write images (8 or 16 bits) 308 binrepertoire=fullfile(PathDir,SeqData.binrepertoire); 309 FileDir=SeqData.sequencename; 310 FileDir=regexprep(FileDir,'_Master_Dalsa_4M180$','');%suppress '_Master_Dalsa_4M180' 311 OutputDir=fullfile(PathDir,FileDir); 312 if ~exist(OutputDir,'dir') 313 % errormsg=[OutputDir ' already exist, delete it first']; 314 % return 315 % end 316 [s,errormsg]=mkdir(OutputDir); 317 318 if s==0 319 disp(errormsg) 320 return%not able to create new image dir 321 end 322 end 323 bin_file_counter=0; 324 for ii=1:SeqData.nb_frames 325 j1=[]; 326 if ~isequal(nbfield2,1) 327 j1=mod(ii-1,nbfield2)+1; 328 end 329 i1=floor((ii-1)/nbfield2)+1; 330 OutputFile=fullfile_uvmat(PathDir,FileDir,'img','.png',NomTypeNew,i1,[],j1);% TODO: set NomTypeNew from SeqData.mode 331 fname=fullfile(binrepertoire,sprintf('%s%.5d.bin',SeqData.binfile,SqbData(ii).file_idx)); 332 if exist(OutputFile,'file')% do not recreate existing image file 333 fid=0; 334 else 335 if fid==0 || ~strcmp(fname,fname_prev) % open the bin file if not in use 336 if fid~=0 337 fclose(fid);%close the previous bin file if relevant 338 end 339 [fid,msg]=fopen(fname,'rb'); 340 if isequal(fid,-1) 341 errormsg=['error in opening ' fname ': ' msg]; 342 return 343 else 344 disp([fname ' opened for reading']) 345 bin_file_counter=bin_file_counter+1; 346 BinList{bin_file_counter}=fname; 347 end 348 fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file 349 NbBinFile=NbBinFile+1;%counter of binary files (for checking purpose) 350 BinSize(NbBinFile)=0;% strat counter for new bin file 351 else 352 fseek(fid,SqbData(ii).offset,-1);%look at the right starting place in the bin file 353 end 354 fname_prev=fname; 355 A=reshape(fread(fid,SeqData.width*SeqData.height,classname),SeqData.width,SeqData.height);%read the current image 356 A=A'; 357 BinSize(NbBinFile)=BinSize(NbBinFile)+SeqData.width*SeqData.height*SeqData.bytesperpixel*8; %record bits read 358 try 359 imwrite(A,OutputFile,'BitDepth',BitDepth) % case of 16 bit images 360 disp([OutputFile ' written']); 361 % [s,errormsg] = fileattrib(OutputFile,'-w','a'); %set images to read only '-w' for all users ('a') 362 % if ~s 363 % % disp_uvmat('ERROR',errormsg,checkrun); 364 % return 365 % end 366 catch ME 367 errormsg=ME.message; 368 return 369 end 370 end 371 end 372 if fid~=0 373 fclose(fid) 374 end 375 376 377 378 269 379 270 function [nbfield2,msg]=copyfile_modif(filexml,timestamp,newxml) 380 271 msg='';
Note: See TracChangeset
for help on using the changeset viewer.