"Preview Vid" doesn't work properly after compiling into standalone executable
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I have written a GUI to show four live video streams from HD webcams (Logitech C920). When I run my GUI in MATLAB, it functions flawlessly, press the "Preview" pushbutton and it detects if there are 1-4 cameras and displays their live images in axes in the GUI. After compiling to a standalone executable using the Compiler Application, when the "Preview" pushbutton is pressed, it shows 1 fewer cameras then the number selected, and it doesn't show a live stream, just a still of the first frame they see. The rest of the code seems to function properly (all cameras continue to record after I hit the "Begin" pushbutton. Below is the code for the "Preview" pushbutton (please disregard the sad nested if loop in the for loop, that was a bit of a workaround for an issue I was seeing earlier).
function Preview_Callback(hObject, ~, handles)
% hObject handle to Preview (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
handles.TLI = ceil(handles.expLengthMin/300); %Time between images (timelapse interval)
handles.fileName = [date,'_',handles.Manufacturer,'_',handles.Bandage];
for i=1:handles.numCamera
handles.vid(i) = videoinput('winvideo', i, 'RGB24_1920x1080'); %Video Format
handles.src(i) = getselectedsource(handles.vid(i));
handles.src(i).FrameRate = '5.0000'; %Frame rate
handles.src(i).FocusMode = 'manual'; %Focus mode
handles.src(i).Focus = 50;% Focus length for glass cylinder
handles.frameRate = str2double(handles.src(i).FrameRate);
handles.vid(i).FramesPerTrigger = handles.expLengthMin/handles.TLI;
handles.vid(i).FrameGrabInterval = (handles.frameRate*60)*handles.TLI;
handles.vid(i).LoggingMode = 'disk';
docname = [handles.fileName,'_#',num2str(i),'.avi'];
handles.diskLogger = VideoWriter(docname, 'Uncompressed AVI');
handles.diskLogger.FrameRate = 60/handles.TLI;
handles.vid(i).DiskLogger = handles.diskLogger;
end
vidRes = handles.vid(1).VideoResolution;
nBands = handles.vid(1).NumberOfBands;
for i=1:handles.numCamera
if i == 1;
h(1) = image(zeros(vidRes(2),vidRes(1),nBands),'Parent',handles.axes1);
preview(handles.vid(1),h(1))
elseif i == 2;
h(2) = image(zeros(vidRes(2),vidRes(1),nBands),'Parent',handles.axes2);
preview(handles.vid(2),h(2))
elseif i == 3;
h(3) = image(zeros(vidRes(2),vidRes(1),nBands),'Parent',handles.axes3);
preview(handles.vid(3),h(3))
elseif i == 4;
h(4) = image(zeros(vidRes(2),vidRes(1),nBands),'Parent',handles.axes4);
preview(handles.vid(4),h(4))
end
end
guidata(hObject,handles);
2 Commenti
Walter Roberson
il 21 Gen 2016
Is it always the same camera number that is affected, such as always the 4th one, even if you reorder the cameras? Or is it always the same camera that is affected (according to the detailed identification information) ?
Risposta accettata
Harsheel
il 21 Gen 2016
Seems like a bug to me. To work around the issue, make sure that the main function does not end before the whole application does; you can use the "waitfor" function to accomplish this.
For example if you have a GUIDE GUI myGUI, where somewhere in the callback of this GUI "preview" is actually called, and you used to compile myGUI into myGUI.exe you can work around the issue by writing the following function:
function myMain
waitfor(myGUI)
Use myMain.m as the main function for your standalone.
3 Commenti
cr
il 30 Ago 2017
Modificato: cr
il 19 Set 2017
Instead of creating a wrapper, I just put
uiwait(handles.figure1)
(which appears commented out right after opening function when using Guide) and it worked. waitfor didn't work for me. But this has created another problem: the toolbar buttons like zoom don't work.
shlom41k
il 20 Mar 2019
Thank you so much! It worked:
function myMain
waitfor(myGUI)
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface) in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!