Video recording waiting for start
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
So I am using Matlab 2017b and below code to record two videos from two gige vision cameras. And the problem that I couldn't find on the Internet or in the Matlab forums is that the cameras always record a video with a duration of two minutes and 30 seconds(2:30) erverytime I start the recording procedure. Am I missing something or doing something wrong here? Once the duration hits the 2:30, my preview window doesn't stop but the text filed, which shows: "Logging image xxx" then suddenly turns into: "Waiting for start" again. This topic is really urgent to me because I really need to record videos that are way longer than two minutes.
function varargout = aufnehmen_speichern(varargin)
% AUFNEHMEN_SPEICHERN MATLAB code for aufnehmen_speichern.fig
% AUFNEHMEN_SPEICHERN, by itself, creates a new AUFNEHMEN_SPEICHERN or raises the existing
% singleton*.
%
% H = AUFNEHMEN_SPEICHERN returns the handle to a new AUFNEHMEN_SPEICHERN or the handle to
% the existing singleton*.
%
% AUFNEHMEN_SPEICHERN('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in AUFNEHMEN_SPEICHERN.M with the given input arguments.
%
% AUFNEHMEN_SPEICHERN('Property','Value',...) creates a new AUFNEHMEN_SPEICHERN or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before aufnehmen_speichern_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% save. All inputs are passed to aufnehmen_speichern_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 aufnehmen_speichern
% Last Modified by GUIDE v2.5 16-Apr-2018 13:34:59
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @aufnehmen_speichern_OpeningFcn, ...
'gui_OutputFcn', @aufnehmen_speichern_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 aufnehmen_speichern is made visible.
function aufnehmen_speichern_OpeningFcn(hObject, eventdata, 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 aufnehmen_speichern (see VARARGIN)
% Choose default command line output for aufnehmen_speichern
handles.output = hObject;
hForm = gcf;
h = waitbar(0,'Initializing...');
set(0, 'CurrentFigure', h);
set(0, 'CurrentFigure', hForm); %Ohne diese Zeilen kann man aufnehmen_speichern.m nicht von der main aus starten
clc;
imaqreset;
handles.vid1 = videoinput('gige', 1,'Mono8');
handles.vid2 = videoinput('gige', 2,'Mono8');
waitbar(0.20,h,'Setting Videoinput...');
src1 = getselectedsource(handles.vid1);
src2 = getselectedsource(handles.vid2);
waitbar(0.35,h,'Setting Resources...');
src1.AcquisitionFrameRateAbs = 30.000300003;
src2.AcquisitionFrameRateAbs = 30.000300003;
set(handles.vid1,'FramesPerTrigger',Inf);
set(handles.vid2,'FramesPerTrigger',Inf);
waitbar(0.45,h,'Setting FramesPerTrigger...');
triggerconfig(handles.vid1,'hardware','DeviceSpecific','DeviceSpecific');
triggerconfig(handles.vid2,'hardware','DeviceSpecific','DeviceSpecific');
set(handles.vid1,'TriggerRepeat',inf);
set(handles.vid2,'TriggerRepeat',inf);
waitbar(0.6,h,'Setting Triggerconfig...');
src1.TriggerSelector = 'FrameStart';
src2.TriggerSelector = 'FrameStart';
src1.TriggerSource = 'Line1';
src2.TriggerSource = 'Line1';
waitbar(0.75,h,'Setting TriggerActivation...');
src1.TriggerActivation = 'FallingEdge';
src2.TriggerActivation = 'FallingEdge';
src1.TriggerMode = 'on';
src2.TriggerMode = 'on';
handles.vid1.LoggingMode = 'disk';
handles.vid2.LoggingMode = 'disk';
waitbar(0.80,h,'Setting Image Handle...');
vidRes = handles.vid1.VideoResolution;
imWidth = vidRes(1);
imHeight = vidRes(2);
nBands = handles.vid1.NumberOfBands;
handles.hImage1= image(zeros(imHeight,imWidth,nBands));
setappdata(handles.hImage1,'UpdatePreviewWindowFcn',@mypreview_fcn);
setappdata(handles.hImage1,'HandleToTimestampLabel',handles.text1);
setappdata(handles.hImage1,'HandleToResolutionLabel',handles.text2);
setappdata(handles.hImage1,'HandleToStatusLabel',handles.text3);
setappdata(handles.hImage1,'HandleToFrameRateLabel',handles.text4);
set(handles.save,'Enable','off');
set(handles.restart,'Enable','off');
preview(handles.vid1, handles.hImage1);
waitbar(1,h,'Done...');
delete(h);
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes aufnehmen_speichern wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = aufnehmen_speichern_OutputFcn(hObject, eventdata, 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;
set(gcf, 'units', 'normalized', 'outerposition', [0 0 1 1]);
% --- Executes on button press in back.
function back_Callback(hObject, eventdata, handles)
% hObject handle to back (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
delete(handles.vid1);
clear handles.vid1;
delete(handles.vid2);
clear handles.vid2;
close;
main;
% --- Executes on button press in exit.
function exit_Callback(hObject, eventdata, handles)
% hObject handle to exit (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
delete(handles.vid1);
clear handles.vid1;
delete(handles.vid2);
clear handles.vid2;
close;
% --- Executes on button press in create_files.
function create_files_Callback(hObject, eventdata, handles)
% hObject handle to create_files (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
set(handles.create_files,'Enable','off');
set(handles.back,'Enable','off');
set(handles.exit,'Enable','off');
time = datetime('now','TimeZone','local','Format','dd-MM-yyyy''-T-''HH-mm-ss');
setT = char(time);
[file1,path] = uiputfile(['F:\Aufnahmen\test\' 'Hummel-01_',setT,'_links.avi'],'Select the directory for the left Grayscale AVI');
if(isequal(file1,0) || isequal(path,0))
set(handles.create_files,'Enable','on');
set(handles.back,'Enable','on');
set(handles.exit,'Enable','on');
return;
end
file2 = strrep(file1,'links','rechts');
%diskLogger1 = VideoWriter('D:\Matlab Sciebo\Hummeln 2017\Kalibrierung\Test\links01.avi', 'Grayscale AVI');
%diskLogger2 = VideoWriter('D:\Matlab Sciebo\Hummeln 2017\Kalibrierung\Test\rechts01.avi', 'Grayscale AVI');
disk1 = VideoWriter(fullfile(path,file1), 'Grayscale AVI');
disk2 = VideoWriter(fullfile(path,file2), 'Grayscale AVI');
handles.vid1.DiskLogger = disk1;
handles.vid2.DiskLogger = disk2;
start(handles.vid1);
start(handles.vid2);
set(handles.save,'Enable','on');
% --- Executes on button press in save.
function save_Callback(hObject, eventdata, handles)
% hObject handle to save (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
stoppreview(handles.vid1);
stoppreview(handles.vid2);
while(handles.vid1.FramesAcquired ~= handles.vid1.DiskLoggerFrameCount)
pause(.1);
end
stop(handles.vid1);
while(handles.vid2.FramesAcquired ~= handles.vid2.DiskLoggerFrameCount)
pause(.1);
end
stop(handles.vid2);
set(handles.save,'Enable','off');
set(handles.restart,'Enable','on');
set(handles.back,'Enable','on');
set(handles.exit,'Enable','on');
% --- Executes on button press in restart.
function restart_Callback(hObject, eventdata, handles)
% hObject handle to restart (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if(isrunning(handles.vid1) == 0 && isrunning(handles.vid2) == 0)
choice = questdlg({'Do you really want to restart the acquisition?'},...
'Warning',...
'Yes','No','No');
switch choice
case 'Yes'
set(handles.restart,'Enable','off');
set(handles.create_files,'Enable','on');
set(handles.back,'Enable','on');
set(handles.exit,'Enable','on');
preview(handles.vid1, handles.hImage1);
case 'No'
return;
end
end
function mypreview_fcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
tst = eventdata.Timestamp;
rsl = eventdata.Resolution;
sts = eventdata.Status;
frr = eventdata.FrameRate;
ts1 = getappdata(handles,'HandleToTimestampLabel');
rs1 = getappdata(handles,'HandleToResolutionLabel');
st1 = getappdata(handles,'HandleToStatusLabel');
fr1 = getappdata(handles,'HandleToFrameRateLabel');
ts1.String = tst;
rs1.String = rsl;
st1.String = sts;
fr1.String = frr;
handles.CData = eventdata.Data;
0 comentarios
Respuestas (2)
Han Du
el 9 de Ag. de 2018
There are multiple potential causes of this issue.
What is the memory usage after acquiring data for 2:30 minutes? Sometimes the memory usage can be very high if acquired images haven't been logged on disk which can even cause MATLAB freeze.
You are using hardware trigger. Is the trigger source still providing signal after 2:30 minutes?
It should be easier to troubleshoot the issue by extracting the code for acquiring images from the gui.
1 comentario
Marcel Liphardt
el 14 de Ag. de 2018
Editada: Marcel Liphardt
el 14 de Ag. de 2018
Ver también
Categorías
Más información sobre Acquisition Using Any Hardware en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!