urbiGetNImages

PURPOSE ^

Gets n successive images from the urbi server (default device : camera)

SYNOPSIS ^

function result = urbiGetNImages(con, n,deviceName)

DESCRIPTION ^

 Gets n successive images from the urbi server  (default device : camera)
 This function gets n images from the specified device, or from the
 device "camera" if it is not specified.
 The parameters for the camera have to set by the user with urbiSend

 The result is an array of structure with images ranked in their time order
 The access to each image is made with
 images(1).matrix, images(1).width, images(1).height, images(1).time
 images(2).matrix, images(2).width, images(2).height, images(2).time ...

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function result = urbiGetNImages(con, n,deviceName)
0002 % Gets n successive images from the urbi server  (default device : camera)
0003 % This function gets n images from the specified device, or from the
0004 % device "camera" if it is not specified.
0005 % The parameters for the camera have to set by the user with urbiSend
0006 %
0007 % The result is an array of structure with images ranked in their time order
0008 % The access to each image is made with
0009 % images(1).matrix, images(1).width, images(1).height, images(1).time
0010 % images(2).matrix, images(2).width, images(2).height, images(2).time ...
0011 
0012 if (nargin == 2)
0013   deviceName='camera';
0014 end
0015 
0016 io_buffer = 'imageB.jpg';
0017 temp = [];
0018 T = [];
0019 result = [];
0020 for index=1:n
0021     urbiSend(con, [ deviceName ';']);
0022     type = 'nothing' ;
0023     while ~strcmp(type, 'BIN')
0024         r = pnet(con, 'readline');
0025         if (~isempty(r))
0026             [timeStamp, tag, typeTmp, rnum, rstring] = urbiParse(r) ;
0027             type = typeTmp ;
0028         end;
0029     end;
0030     [timeStamp, tag, type, rnum, rstring] = urbiParse(r) ;
0031     width = sscanf(rstring{5}, '%u');
0032     height = sscanf(rstring{6}, '%u');
0033     nbytes = sscanf(rstring{3}, '%u') ;
0034     pnet(con, 'readtofile', io_buffer, nbytes) ;
0035     matrix = imread(io_buffer) ;
0036     time = timeStamp;
0037     temp = [temp ; struct('matrix',matrix,'width',width,'height',height, 'time', time)];
0038     T = [T ; [index, time]];
0039 end;
0040 % Sort the images
0041 sorted_index = sortrows(T, 2);
0042 for i=1:n
0043     result = [ result ; temp( sorted_index(i, 1) ) ];
0044 end;

Generated on Tue 20-Dec-2005 19:05:34 by m2html © 2003