urbiGetImage

PURPOSE ^

Gets the current image from the urbi server (default device : camera)

SYNOPSIS ^

function [matrix, width, height, time] = urbiGetImage(con,deviceName)

DESCRIPTION ^

 Gets the current image from the urbi server  (default device : camera)
 This function gets the image 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

 This function returns :
   matrix = matrix of the image (display with imshow(matrix);)
   width, height = size of the image
   time = time at which the image was taken by the robot

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [matrix, width, height, time] = urbiGetImage(con,deviceName)
0002 % Gets the current image from the urbi server  (default device : camera)
0003 % This function gets the image 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 % This function returns :
0008 %   matrix = matrix of the image (display with imshow(matrix);)
0009 %   width, height = size of the image
0010 %   time = time at which the image was taken by the robot
0011 
0012 
0013 if (nargin == 1)
0014   deviceName='camera';
0015 end
0016 
0017 io_buffer = 'imageB.jpg';
0018 urbiSend(con, [ deviceName ';']);
0019 type = 'nothing' ;
0020 while ~strcmp(type, 'BIN')
0021     r = pnet(con, 'readline');
0022     if (~isempty(r))
0023         [timeStamp, tag, typeTmp, rnum, rstring] = urbiParse(r) ;
0024         type = typeTmp ;
0025     end;
0026 end;
0027 [timeStamp, tag, type, rnum, rstring] = urbiParse(r) ;
0028 width = sscanf(rstring{5}, '%u');
0029 height = sscanf(rstring{6}, '%u');
0030 nbytes = sscanf(rstring{3}, '%u') ;
0031 pnet(con, 'readtofile', io_buffer, nbytes) ;
0032 matrix = imread(io_buffer) ;
0033 time = timeStamp;

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