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

11 visualizaciones (últimos 30 días)
MathWorks Support Team
MathWorks Support Team el 10 de Sept. de 2024
Respondida: MathWorks Support Team el 10 de Sept. de 2024

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

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 10 de Sept. de 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

Más respuestas (0)

Categorías

Más información sobre 言語の基礎 en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2017a

Community Treasure Hunt

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

Start Hunting!