Webcam stops working after using Matlab Compiler
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I'm trying to display a webcam video in a Gui and placing it into a standalone exe. While the program works perfectly when I run it within Matlab, the webcam would refuse to play any live video and only show a static image.
I suspect that something is wrong with the "preview()" function, since other webcam related functions down the line still works: for example, an "img=getsnapshot(vid);" would still capture a picture, and the subsequent "imshow(img, 'parent', handles.axes1);" can display the aforementioned image without any issues either. Also, I tested the compiler on the simplest webcam function i can write:
vid = videoinput('winvideo');
preview(vid);
As in, those actual two lines of code in a .m, and even that doesn't work after compiling (they work fine under the matlab environment).
Is there any way for me use the preview function? I did not pass any parameters into the MCC, should I have? Replacements for preview are also welcomed, but the simple ones that I have attempted, such as a while(1) loop with a img=getsnapshot(vid), tends to be too slow and clashes with other image aq commands.
btw, the actual code that displays the vid is
%sets up the webcam
vid = videoinput('winvideo',1,'MJPG_848x480');
handles.vid=vid;
guidata(hObject, handles);
%sets up the webcam display
vidRes=get(handles.vid,'VideoResolution');
nBands=get(handles.vid,'NumberOfBands');
himage=image(zeros(vidRes(2),vidRes(1), nBands),'parent',handles.axes1);
handles.himage=himage;
guidata(hObject, handles);
%starts the webcam display
preview(handles.vid,handles.himage);
I'm using Matlab 2015b.
0 commentaires
Réponses (1)
Walter Roberson
le 13 Juin 2016
Modifié(e) : Walter Roberson
le 14 Juin 2016
There was an R2015a bug like that; see https://www.mathworks.com/support/bugreports/search_results?utf8=%E2%9C%93&search_executed=1&keyword=webcam&release_filter=Exists+in&release=0&selected_products=&commit=Search
bug 1232445
It would be worth checking to see if your symptoms match what is there, and double-checking whether you are compiling with R2015a or R2015b
2 commentaires
Bernard Rivera Camacho
le 6 Mar 2020
Hello Jerry Lu
Did you solve this issue? I'm in the same trouble and i would lke some hints.
Voir également
Catégories
En savoir plus sur Matrox Hardware dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!