0001 function result = urbiGetNImages(con, n,deviceName)
0002
0003
0004
0005
0006
0007
0008
0009
0010
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
0041 sorted_index = sortrows(T, 2);
0042 for i=1:n
0043 result = [ result ; temp( sorted_index(i, 1) ) ];
0044 end;