Skip to content

Instantly share code, notes, and snippets.

@smzn
Created July 11, 2019 03:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smzn/13eb46115a39329c19de34c3acca592a to your computer and use it in GitHub Desktop.
Save smzn/13eb46115a39329c19de34c3acca592a to your computer and use it in GitHub Desktop.
顔認識
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