i forget to say is running on a GUI and it seems to be a problem between functions, with one button i create the vid object as global then with another push button i'm taking the pictures but when i check just before the snapshot seems that de vid object is empty: vid=[] i solved it putin the creation of the vid object and the snapshot in the same push button function and it works, but now i have another problem. i don't want the GUI to create a vid object everytime i want to take a snapshot so i created a if condition to check if the vid object is already created and it works the first time i run the code and press the push button, but when i click again to take another picture the same erros shows up " Undefined function 'snapshot' for input arguments of type 'double' ", is like the vid object is deleted after the execution of the function. can some anyone help me :D
if exist==0
clear('vid');
maxAttempts = 30;
attempt = 1;
hasProperty = false;
while attempt < maxAttempts
vid = webcam('USB Camera');
hasProperty = max(ismember(properties(vid), 'Exposure'));
if hasProperty
% We got all the properties so we can quit trying.
fprintf('We have all camera properties after %d attempts. Now continuing with program.\n', attempt);
break;
end
fprintf('We do not have all camera properties after %d attempts. Trying again.\n', attempt);
attempt = attempt + 1;
clear('vid');
end
%CONFIGURACION PARAMETROS DE LA CAMARA
vid.Resolution='2048x1536';
vid.WhiteBalanceMode='manual';
vid.ExposureMode='manual';
vid.Exposure=-5.7;
vid.Gain=0;
vid.Hue=0; %-40 40
vid.Gamma=72; %72-500
vid.Contrast=64;
vid.Saturation=35;
vid.Sharpness=1;
vid.Brightness=15; %-64 64
vid.WhiteBalance=6500; %2800-6500
vid.BacklightCompensation=2; %0-2
assignin('base','vid',vid);
exist=1;
end
imagen=snapshot(vid);