Code covered by the BSD License  

Highlights from
deprecated -- Light Field Toolbox v0.2 -- v0.3 now available

image thumbnail

deprecated -- Light Field Toolbox v0.2 -- v0.3 now available

by

 

26 Apr 2013 (Updated )

A set of tools for working with light field (aka plenoptic) imagery in Matlab

LFGatherCamInfo( FilePath, FilenamePattern )
% LFGatherCamInfo - collect metadata from a folder of processed white images or calibrations
%
% Usage: 
% 
%   CamInfo = LFGatherCamInfo( FilePath, FilenamePattern )
% 
% 
% This function is designed to work with one of two sources of information: a folder of Lytro white
% images, as extracted from the calibration data using an LFP tool; or a folder of calibrations, as
% generated by LFUtilCalLenseletCam. 
% 
% Inputs: 
% 
%   FilePath is a path to the folder containing either the white images or the calibration files.
% 
%   FilenamePattern is a pattern, with wildcards, identifying the metadata files to process. Typical
%   values are 'CalInfo*.json' for calibration info, and '*T1CALIB__MOD_*.TXT' for white images.
%   
% Outputs:
% 
%   CamInfo is a struct array containing zoom, focus and filename info for each file. Exposure info
%   is also included for white images.
% 
% See LFUtilProcessCalibrations and LFUtilProcessWhiteImages for example usage.
% 
% See also:  LFUtilProcessWhiteImages, LFUtilProcessCalibrations

% Part of LF Toolbox v0.2 released 27-May-2013
% Copyright (c) 2013, Donald G. Dansereau

function CamInfo = LFGatherCamInfo( FilePath, FilenamePattern )

%---Locate all input files---
fprintf('Locating files matching %s...\n', FilenamePattern);
FileNames = LFFindFilesRecursive( FilePath, FilenamePattern );
if( isempty(FileNames) )
    error('No files found');
end

%---Process each---
fprintf('Filename, Camera Serial, ZoomStep, FocusStep\n');
for( iFile = 1:length(FileNames) )
    CurFname = FileNames{iFile};
    CurFileInfo = LFReadMetadata( fullfile(FilePath, CurFname) );
    
    CurCamInfo = [];
    if( isfield( CurFileInfo, 'CamInfo' ) )
        
        %---Calibration file---
        CurCamInfo = CurFileInfo.CamInfo;
        
    elseif( isfield( CurFileInfo, 'master' ) )
        
        %---Lytro TXT metadata file associated with white image---
        CurCamInfo.ZoomStep = CurFileInfo.master.picture.frameArray.frame.metadata.devices.lens.zoomStep;
        CurCamInfo.FocusStep = CurFileInfo.master.picture.frameArray.frame.metadata.devices.lens.focusStep;
        CurCamInfo.ExposureDuration = CurFileInfo.master.picture.frameArray.frame.metadata.devices.shutter.frameExposureDuration;
        CurCamInfo.CamSerial = CurFileInfo.master.picture.frameArray.frame.privateMetadata.camera.serialNumber;
        
    else
        
        error('Unrecognized file format reading metadata\n');
        
    end

    fprintf('    %s :\t%s, %d, %d\n', CurFname, CurCamInfo.CamSerial, CurCamInfo.ZoomStep, CurCamInfo.FocusStep);
    
    CurCamInfo.Fname = CurFname;
    CamInfo(iFile) = CurCamInfo;
end

Contact us