capture a snapshot and saving it to a matrix variable

조회 수: 2 (최근 30일)
Ana Guerrero Rosario
Ana Guerrero Rosario 2020년 12월 6일
댓글: Ana Guerrero Rosario 2020년 12월 6일
I am trying to use my webcam to record and take snapshots and be able to save it as a matrix variable. This is the best code I found online so far but I keep getting an error. Could someone help me iether with a better code that will work on app designer or how to fix this error?
% Button pushed function: OnButton
function OnButtonPushed(app, event)
clear all; clc; close all
cam = webcam('FaceTime HD Camera');
frame = snapshot(cam);
im = image(app.UIAxes, zeros(size(frame), 'uint8'));
axis(app.UIAxes,'image');
preview(cam,im);
pause;
Reference to a cleared variable app.
Error in Final/OnButtonPushed (line 19)
im = image(app.UIAxes, zeros(size(frame), 'uint8'));
Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 309) Error while evaluating Button PrivateButtonPushedFcn.,

답변 (1개)

Ameer Hamza
Ameer Hamza 2020년 12월 6일
Are you using it inside App designer? Remove the line
clear all; clc; close all
  댓글 수: 7
Ameer Hamza
Ameer Hamza 2020년 12월 6일
You can use the "Enable" property of the lamp to turn it on and off. You can also use the "Color" property to change its color.
Ana Guerrero Rosario
Ana Guerrero Rosario 2020년 12월 6일
Hey, I keep tyring to put a rectangle on the camera plot I have. I added a callback on the plot and put rectangle(app.UIAxes, 'Position', [25,25,50,50])
but nothing shows up when I run the code. Do you know how to fix this?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interactive Control and Callbacks에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by