Acquire Double Rate Image From Photonfocus(TM) Camera using Image Acquisition Toolbox (TM)
17 Apr 2012
18 Apr 2012)
Acquire & demodulate Double Rate Images from Photonfocus camera using Image Acquisition Toolbox
% This is an example of how to use Image Acquisition Toolbox(TM) to acquire
% images from Photonfocus(TM) cameras with Double Rate(TM) technology.
% Specifically, this example shows how to use this feature with the
% DR1-D1312-200-G2-8 camera. For other cameras, the adaptor and the
% specific camera features (and their values) used may be different.
% Read about <http://www.mathworks.com/products/imaq | Image Acquisition Toolbox>.
% To use this example you must have Photonfocus PFInstaller already
% installed. The installer is avalaible at: http://photonfocus.com/html/eng/support/software.php
% Copyright 2012 The MathWorks, Inc.
% Create an Image Acquisition Toolbox videoinput object using the 'gige'
vidObj = videoinput('gige', 1, 'Mono8');
% Enable the Double Rate feature for this camera
srcObj = vidObj.Source;
srcObj.DoubleRate_Enable = 'True';
% Set it to the desired ROI.
% For the DR1-D1312-200-G2-8 camera, the maximum ROI in normal mode is
% 1312x1082, in Double Rate mode, this reduces to 680x1082. Because of its
% ability to send modulated images in Double Rate mode, the ROIPosition
% property of a videoinput object cannot be directly used to set the
% desired ROI. To modify the ROI, the following steps need to be performed:
% 1. Change srcObj.Window_W to the required width (in increments of 32).
% This changes the X Offset value in vidObj.ROIPosition according to the
% requested width. However the width value does not get directly
% 2. Set the width value in vidObj.ROIPosition to that of
% srcObj.WidthInterface. This a revised width calculated by the camera
% based on the requested width and the Double Rate mode.
% For more information on setting the ROI values for this camera, see the
% camera documentation.
roi = vidObj.ROIPosition;
srcObj.Window_W = 1024;
vidObj.ROIPosition = [roi(1) roi(2) srcObj.WidthInterface roi(4)];
% Acquire an image. The image acquired is in modulated form and needs to be
img = getsnapshot(vidObj);
% Load the pfDoubleRate.dll library to demodulate the image. For this
% example, the Photonfocus libraries were installed under
% C:\Program Files\Photonfocus folder.
loadlibrary('C:\Program Files\Photonfocus\PFRemote\pfDoubleRate.dll', ...
% Demodulate the acquired image by calling the function
% pfDoubleRate_DeModulateImage in the pfDoubleRate.
actualWidth = srcObj.Window_W;
modulatedWidth = srcObj.WidthInterface;
height = roi(4);
modImage = libpointer('uint8Ptr', img'); % Transpose the image because
% MATLAB image is stored in terms
% of matrix as [height width]
demodImage = libpointer('uint8Ptr', uint8(zeros(height, actualWidth))');
returnValue = calllib('pfDoubleRate', 'pfDoubleRate_DeModulateImage', ...
demodImage, modImage, int32(actualWidth), int32(height), int32(modulatedWidth));
% The demodulated image is not a normal MATLAB image and can be used like
% any other image in MATLAB.