Does someone know why i am having this error? - *Unable to allocate memory for an incoming image frame due to insufficient free physical memory*. I am recording video and my GUI just record a minute then the error appears
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
jorge alejandro guerrero díaz
am 7 Jun. 2017
Kommentiert: jorge alejandro guerrero díaz
am 8 Jun. 2017
function varargout = untitled2(varargin)
% UNTITLED2 MATLAB code for untitled2.fig
% UNTITLED2, by itself, creates a new UNTITLED2 or raises the existing
% singleton*.
%
% H = UNTITLED2 returns the handle to a new UNTITLED2 or the handle to
% the existing singleton*.
%
% UNTITLED2('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in UNTITLED2.M with the given input arguments.
%
% UNTITLED2('Property','Value',...) creates a new UNTITLED2 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before untitled2_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to untitled2_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help untitled2
% Last Modified by GUIDE v2.5 02-Jun-2017 18:42:41
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @untitled2_OpeningFcn, ...
'gui_OutputFcn', @untitled2_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before untitled2 is made visible.
function untitled2_OpeningFcn(hObject, ~, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to untitled2 (see VARARGIN)
% Choose default command line output for untitled2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes untitled2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = untitled2_OutputFcn(~, ~, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in configuracion.
function configuracion_Callback(~, ~, handles)
% hObject handle to configuracion (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global IA DeviceID Format
IAHI=imaqhwinfo;
IA=(IAHI.InstalledAdaptors);
D=menu('Seleccione dispositivos de Entrada de video instalado:',IA);
if isempty(IA)||D==0
msgbox({'no hay ningun adaptador de entrada de video instalado!',...
'O',...
'Intente de Nuevo y seleccione el adaptador apropiado.'})
return
end
IA=char(IA);
IA=IA(D,:);
IA(IA==' ')=[];
x=imaqhwinfo(IA);
try
DeviceID=menu('seleccione ID de Dispositivo',x.DeviceIDs);
F=x.DeviceInfo(DeviceID).SupportedFormats;
nF=menu('seleccione el Formato',F);
Format=F{nF};
catch e
warndlg({'intente con otro dispositivo ';...
'No esta instalado el dispositivo de enetrada de video'})
return
end
set(handles.v_previa, 'enable', 'on');
set(handles.control, 'enable', 'off');
% --- Executes on button press in v_previa.
function v_previa_Callback(hObject, eventdata, handles)
% hObject handle to v_previa (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global IA DeviceID Format VidObj cam
try
VidObj= videoinput(IA, DeviceID, Format);
handles.VidObj=VidObj;
vidRes = get(handles.VidObj, 'VideoResolution');
nBands = get(handles.VidObj, 'NumberOfBands');
set(handles.PRW,'Visible','off')
axes(handles.PRW)
hImage = image( zeros(vidRes(2), vidRes(1), nBands) );
preview(handles.VidObj, hImage)
catch E
msgbox({'configure corectamente la camara!',' ',E.message},'CAM INFO')
end
guidata(hObject, handles);
set(handles.control, 'enable','on');
cam=0;
% --- Executes on button press in control.
function control_Callback(~, ~, handles)
% hObject handle to control (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global VidObj cam vid aviobj
if cam == 0
[na,ca]=uiputfile({'*.avi'});
% nom = datestr(now, 'local');
% nombre = strcat(nom, '.avi');
vid = VidObj;
aviobj = VideoWriter(fullfile(ca,na));
vid.LoggingMode = 'disk&memory';
vid.DiskLogger = aviobj;
vid.TriggerRepeat = 300;
start(vid);
set(handles.control, 'String', 'PARAR');
set(handles.control, 'ForegroundColor','black');
set(handles.configuracion, 'enable', 'off');
set(handles.v_previa, 'enable', 'off');
cam = 1;
else
stop(vid);
% aviobj =
close(vid.DiskLogger);
delete(vid);
clear vid;
clear aviobj;
set(handles.control, 'String', 'GRABAR');
set(handles.control,'ForegroundColor', 'red');
set(handles.configuracion, 'enable','on');
set(handles.v_previa, 'enable', 'on');
cam = 0;
end
% --- Executes on button press in salir.
function salir_Callback(~, ~, ~)
% hObject handle to salir (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
clear all
close all
2 Kommentare
Akzeptierte Antwort
Jan
am 7 Jun. 2017
The problem does not concern the GUI, therefore it would be esier, if you post the relevant part of the code only and the complete error message. Currently we have to spend some time to guess, where the error occurres.
But actually the error message is clear: The computer does not have enough free memory to import the movie into the RAM. How many data does 1 minute of capturing import? Remember that the data might be stored without compression in the RAM.
The standard solutions for memory problems are:
- Install more RAM
- Close other applications
- Free RAM by clearing unused large variables
- Never let arrays grow iteratively
- Install more RAM
- Use the smallest possible data type, e.g. single instead of double.
- Think twice if it is really useful to store all the data simlutaneously.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Preview and Device Configuration finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!