Filter löschen
Filter löschen

Help with Gui for real time webcam video input

1 Ansicht (letzte 30 Tage)
Jia Zhen
Jia Zhen am 27 Apr. 2015
Bearbeitet: Jia Zhen am 27 Apr. 2015
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.

Antworten (0)

Kategorien

Mehr zu Read, Write, and Modify Image finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by