Webcam stops working after using Matlab Compiler

8 ビュー (過去 30 日間)
Jerry Lu
Jerry Lu 2016 年 6 月 12 日
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.

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 6 月 13 日
編集済み: Walter Roberson 2016 年 6 月 14 日
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 件のコメント
Jerry Lu
Jerry Lu 2016 年 6 月 14 日
編集済み: Jerry Lu 2016 年 6 月 20 日
Thank you for your answer. However, the issue that I am seeing is somewhat different: no errors were thrown when the code is running, but the preview display is missing.
But if preview after compiling was an issue that was present from 2015a on...It might work if i compiled it on an older version of Matlab...
Brb trying.
Update edit: ...as it turns out, I have no idea how to do most of the stuff I need in previous versions of Matlab...
and upgrading to 2016a didn't resolve the bug either...
Sad :(
Bernard Rivera Camacho
Bernard Rivera Camacho 2020 年 3 月 6 日
Hello Jerry Lu
Did you solve this issue? I'm in the same trouble and i would lke some hints.

サインインしてコメントする。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by