Undefined function or method 'getCameraInfo'

I am trying to capture a frame from webcam,for hat i used the coding below
a = imaqhwinfo;
[camera_name, camera_id, format] = getCameraInfo(a);
vid = videoinput(camera_name, camera_id, format);
% Set the properties of the video object
set(vid, 'FramesPerTrigger', Inf);
set(vid, 'ReturnedColorspace', 'rgb')
function [camera_name, camera_id, resolution] = getCameraInfo(a)
camera_name = char(a.InstalledAdaptors(end));
camera_info = imaqhwinfo(camera_name);
camera_id = camera_info.DeviceInfo.DeviceID(end);
resolution = char(camera_info.DeviceInfo.SupportedFormats(end));
i get the below error
??? Undefined function or method 'getCameraInfo' for input arguments of type
'struct'
please tell how to rectify it

 Respuesta aceptada

Wayne King
Wayne King el 24 de En. de 2013
Editada: Wayne King el 24 de En. de 2013
Where have you saved your function getCameraInfo?
Once you create the getCameraInfo.m file, you have to save it in a folder and then add that folder to the MATLAB path, so that MATLAB knows how to find the function.
Use addpath or pathtool to add the folder to the MATLAB path.
For example, assume that you have saved getCameraInfo.m in a folder called
mfiles, use
>>addpath 'c:\mfiles'
Obviously the above command is slightly different on linux or Mac.
Or simply enter
>>pathtool
and add the folder using the GUI.

7 comentarios

kash
kash el 24 de En. de 2013
my file is in
E:\Documents and Settings\User\My Documents\MATLAB\getCameraInfo
I HAVE SAVED AS FILE,not as a folder
Walter Roberson
Walter Roberson el 24 de En. de 2013
You did not save it as getCameraInfo.m ? The ".m" is required.
kash
kash el 24 de En. de 2013
walter its.m file only i just missed.m
Walter Roberson
Walter Roberson el 24 de En. de 2013
Please use pathtool inside MATLAB to ensure that "E:\Documents and Settings\User\My Documents\MATLAB" is on your MATLAB path.
Also, please double-check the spelling of the file name and the spelling of the function in the file, and the spelling the function is called by, as capital-I can look like digit-1 and lower-case-L
kash
kash el 24 de En. de 2013
thanks walter
i tried another code ,because the above code returns erro some times
imaqhwinfo
dev_info=imaqhwinfo('winvideo',1)
%info=imaqhwinfo('winvideo')
celldisp(dev_info.SupportedFormats)
vid=videoinput('winvideo',1,'YUY2_320x240');
%Open Figure
hFigure=figure(1);
%set parameters for video
%Acquire only one frame each time
triggerconfig(vid,'Manual');
set(vid,'framespertrigger',1);
%Go on forever untill stopped
set(vid,'triggerrepeat',Inf);
%Get a grayscale image
set(vid,'ReturnedColorSpace','grayscale');
start(vid);
preview(vid);
for i=1:5
trigger(vid);
im=getdata(vid);
figure,imshow(im(:,:,:,i));
end
stop(vid),delete(vid),clear(vid)
here i get error
??? Error using ==> clear
Argument must contain a string.
Error in ==> fg at 21
stop(vid),delete(vid),clear(vid)
I am using inbuilt cam in my lap
Walter Roberson
Walter Roberson el 24 de En. de 2013
clear('vid')

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 24 de En. de 2013

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by