Azzera filtri
Azzera filtri

Help with Gui for real time webcam video input

1 visualizzazione (ultimi 30 giorni)
Jia Zhen
Jia Zhen il 27 Apr 2015
Modificato: Jia Zhen il 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.

Risposte (0)

Categorie

Scopri di più su Read, Write, and Modify Image in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by