필터 지우기
필터 지우기

Help with Gui for real time webcam video input

조회 수: 1 (최근 30일)
Jia Zhen
Jia Zhen 2015년 4월 27일
편집: Jia Zhen 2015년 4월 27일
I had a code for face detection using vision.CascadeObjectDetector in real time and i want to input the code into a gui with 1 start buttona and 1 axes. I had try by editing this code
if true
obj = imaq.VideoDevice('winvideo',1,'YUY2_320x240');
set(obj,'ReturnedColorSpace','rgb');
figure('menubar','none','tag','webcam');
% tell matlab to start the webcam on user request, not automatically
triggerconfig(obj, 'manual');
% we need this to know the image height and width
vidRes = get(obj, 'VideoResolution');
% image width
imWidth = vidRes(1);
% image height
imHeight = vidRes(2);
% number of bands of our image (should be 3 because it's RGB)
nBands = get(obj, 'NumberOfBands');
% create an empty image container and show it on axPreview
hImage = image(zeros(imHeight, imWidth, nBands), 'parent', handles.axPreview);
% begin the webcam preview
preview(obj, hImage);
end
into this
if true
obj = imaq.VideoDevice('winvideo',1,'YUY2_320x240');
set(obj,'ReturnedColorSpace','rgb');
figure('menubar','none','tag','webcam');
% tell matlab to start the webcam on user request, not automatically
triggerconfig(obj, 'manual');
while(true)
frame=step(obj);
%Detect faces.
bboxes = step(faceDetector,frame);
%Annotate detected faces.
IFaces = insertObjectAnnotation(frame,'rectangle',bboxes,'face');
hImage = image(IFaces,'border','tight', handles.axPreview);
% begin the webcam preview
preview(obj, hImage);
end
but failed. Could anyone teach me how to input both the webcam and the bounding box of the face in real time into the same axes? Thanks.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Read, Write, and Modify Image에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by