Skip to content

Instantly share code, notes, and snippets.



Created Jul 11, 2019
What would you like to do?
camera = webcam; % Connect to the camera
videoFrame = snapshot(camera);
% Create a cascade detector object.
faceDetector = vision.CascadeObjectDetector();
bbox = step(faceDetector, videoFrame);
% Draw the returned bounding box around the detected face.
videoFrame = insertShape(videoFrame, 'Rectangle', bbox);
figure; imshow(videoFrame); title('Detected face');
% Convert the first box into a list of 4 points
% This is needed to be able to visualize the rotation of the object.
bboxPoints = bbox2points(bbox(1, :));
clear camera
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment