Ignore:
Timestamp:
Feb 6, 2017, 11:29:01 AM (7 years ago)
Author:
sommeria
Message:

various updates

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/readCineHeader.m

    r979 r993  
    1 function [CineFileHeader, BitmapInfoHeader, CameraSetup, imageLocations,  annotationSize] = readCineHeader(filePath)
     1function [CineFileHeader, BitmapInfoHeader, CameraSetup, TimeOnlyBlock, ExposureOnlyBlock, TimeCodeBlock, imageLocations,  annotationSize] = readCineHeader(filePath)
    22
    33fid = fopen(filePath);
     
    2828BitmapInfoHeader.biClrUsed = fread(fid, 1, 'uint32');
    2929BitmapInfoHeader.biClrImportant = fread(fid, 1, 'uint32');
     30
     31fseek(fid, hex2dec('00E2'), 'bof');
     32CameraSetup.Length = fread(fid, 1, 'uint16');
     33
     34fseek(fid, hex2dec('0370'), 'bof');
     35CameraSetup.FirmwareVersion = fread(fid, 1, 'uint32');
     36
     37fseek(fid, hex2dec('0374'), 'bof');
     38CameraSetup.SoftwareVersion = fread(fid, 1, 'uint32');
    3039
    3140fseek(fid, hex2dec('0354'), 'bof');
     
    6069
    6170
     71%% Tagged Information Blocks
     72% AnalogDigitalSignals (ADS) -> not contained in MIRO cine-files
     73% ImageTimeTaggedBlock (ITTB) -> not contained in MIRO cine-files
     74
     75% TimeOnlyBlock (TOB) -> Type should be 1002
     76PositionTOB = CineFileHeader.OffSetup + CameraSetup.Length;
     77fseek(fid, PositionTOB , 'bof');
     78TimeOnlyBlock.Length = fread(fid, 1, 'uint32');
     79TimeOnlyBlock.Type = fread(fid, 1, 'uint16');
     80TimeOnlyBlock.Reserved = fread(fid, 1, 'uint16');
     81TimeOnlyBlock.Data = transpose([1:CineFileHeader.ImageCount ; fread(fid,[2,CineFileHeader.ImageCount], 'uint32')]); % Framenumber combined with Data contained in TOB
     82TimeOnlyBlock.TimestampsDatetime = datetime(TimeOnlyBlock.Data(:,3), 'ConvertFrom', 'posixtime');  % Timestamp as Datetime
     83% TimeOnlyBlock.TimestampsDatestr = datestr(TimeOnlyBlock.TimestampsDatetime);  % Timestamp as String
     84TimeOnlyBlock.TimestampsMillisec = TimeOnlyBlock.Data(:,2)./(2^32);    % Milliseconds of the Timestamp
     85TimeOnlyBlock.ExposureTimeDelays = [0 ; TimeOnlyBlock.TimestampsMillisec(2:end)-TimeOnlyBlock.TimestampsMillisec(1:end-1)]; % Timedifference between two frames. First frame is set to have no timedifference
     86
     87% ExposureOnlyBlock (EOB) -> Type should be 1003
     88PositionEOB = PositionTOB + TimeOnlyBlock.Length;
     89fseek(fid, PositionEOB , 'bof');
     90ExposureOnlyBlock.Length = fread(fid, 1, 'uint32');
     91ExposureOnlyBlock.Type = fread(fid, 1, 'uint16');
     92ExposureOnlyBlock.Reserved = fread(fid, 1, 'uint16');
     93ExposureOnlyBlock.Data = fread(fid,CineFileHeader.ImageCount, 'uint32');
     94ExposureOnlyBlock.ExposureTimesMillisec = ExposureOnlyBlock.Data ./(2^32) .*1000;
     95ExposureOnlyBlock.test1 = fread(fid, 1, 'uint32');
     96ExposureOnlyBlock.test2 = fread(fid, 1, 'uint16');
     97ExposureOnlyBlock.test3 = fread(fid, 1, 'uint16');
     98
     99% RangeDataBlock (RDB) -> not contained in MIRO cine-files
     100% BinSigBlock (BSB) -> not contained in MIRO cine-files
     101% AnaSigBlock (ASB) -> not contained in MIRO cine-files
     102
     103% TimeCodeBlock (TCB)  -> Type should be 1007
     104PositionTCB = PositionEOB + ExposureOnlyBlock.Length;
     105fseek(fid, PositionTCB , 'bof');
     106TimeCodeBlock.Length = fread(fid, 1, 'uint32');
     107TimeCodeBlock.Type = fread(fid, 1, 'uint16');
     108TimeCodeBlock.Reserved = fread(fid, 1, 'uint16');
     109TimeCodeBlock.Data = fread(fid, 1, 'uint8');
     110
     111
     112%% Image Locations and their Annotations
    62113fseek(fid, CineFileHeader.OffImageOffsets, 'bof');
    63114imageBlockLocations = fread(fid, CineFileHeader.ImageCount, 'int64');
    64 
    65115
    66116fseek(fid, imageBlockLocations(1), 'bof');
    67117annotationSize = fread(fid, 1, 'uint32');
    68118
    69 
    70119imageLocations = imageBlockLocations + annotationSize;
    71120
     121
     122%%
    72123fclose(fid);
Note: See TracChangeset for help on using the changeset viewer.