MATLAB の webcam の preview を GUI に含ませるにはどうすればよいですか?

11 visualizzazioni (ultimi 30 giorni)

「MATLAB Support Package for USB Webcams」の webcam を使用して Web カメラから画像を取得しています。
preview 機能では専用のプレビューウィンドウが起動しますがこれをカスタムウィンドウ、GUI、またはアプリに含ませるにはどうすればよいでしょうか。

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 10 Set 2024
以下の例をご参考ください。このコードは figure、axes、および image の要素をプログラムで作成しています。
%% Example WEBCAM custom preview window for MATLAB R2017a
%% List connected webcams
webcamlist
%% Connect to webcam
c = webcam(1);
%% Setup preview window
fig = figure('NumberTitle', 'off', 'MenuBar', 'none');
fig.Name = 'My Camera';
ax = axes(fig);
frame = snapshot(c);
im = image(ax, zeros(size(frame), 'uint8'));
axis(ax, 'image');
%% Start preview
preview(c, im)
setappdata(fig, 'cam', c);
fig.CloseRequestFcn = @closePreviewWindow_Callback;
%% Local functions
function closePreviewWindow_Callback(obj, ~)
c = getappdata(obj, 'cam');
closePreview(c)
delete(obj)
end

Più risposte (0)

Categorie

Scopri di più su 言語の基礎 in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Prodotti


Release

R2017a

Community Treasure Hunt

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

Start Hunting!