Skip to content

Commit

Permalink
Merge pull request #4 from matlab-deep-learning/bugfix/detectFacesOpt…
Browse files Browse the repository at this point in the history
…ions/3

Adds support for Name Value pairs in detectFaces
  • Loading branch information
justinpinkney committed Jan 22, 2020
2 parents e1d16a1 + cc972fa commit 8bfcbca
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.mltbx
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ detector = mtcnn.Detector();

The detector object accepts the same optional arguments as the `mtcnn.detectFaces` function.

Refer to the MATLAB toolbox documentation or [click here](docs/gettings_started.md) for a complete example.
Refer to the MATLAB toolbox documentation or [click here](docs/getting_started.md) for a complete example.

## About

Expand Down
4 changes: 2 additions & 2 deletions code/mtcnn/+mtcnn/detectFaces.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function [bboxes, scores, landmarks] = detectFaces(im)
function [bboxes, scores, landmarks] = detectFaces(im, varargin)
% detectFaces Use a pretrained model to detect faces in an image.
%
% Args:
Expand Down Expand Up @@ -34,6 +34,6 @@

% Copyright 2019 The MathWorks, Inc.

detector = mtcnn.Detector();
detector = mtcnn.Detector(varargin{:});
[bboxes, scores, landmarks] = detector.detect(im);
end
2 changes: 1 addition & 1 deletion code/mtcnn/Contents.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% MTCNN
% Version 1.0 (R2019b) 02-December-2019
% Version 1.0.1 (R2019b) 22-January-2020
%
% Files
% mtcnn.detectFaces - Use a pretrained model to detect faces in an image.
Expand Down
3 changes: 1 addition & 2 deletions mtcnn.prj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<param.description>This repository implements deep learning based face detection and facial landmark localisation using Multi-Task Cascaded CNNs.
For more details see the GitHub repository: https://github.com/matlab-deep-learning/mtcnn-face-detection</param.description>
<param.screenshot>${PROJECT_ROOT}\doc\logo.png</param.screenshot>
<param.version>1.0</param.version>
<param.version>1.0.1</param.version>
<param.output>${PROJECT_ROOT}\MTCNN Face Detection.mltbx</param.output>
<param.products.name>
<item>Computer Vision Toolbox</item>
Expand Down Expand Up @@ -55,7 +55,6 @@ For more details see the GitHub repository: https://github.com/matlab-deep-learn
<param.additional.sw.mac.url />
<param.additional.sw.linux.url />
<unset>
<param.version />
<param.output />
<param.platforms />
<param.exclude.filters />
Expand Down
15 changes: 15 additions & 0 deletions test/+tests/DetectFacesTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,21 @@ function testDefaultDetect(test)
test.assertEqual(scores, test.Reference.scores, "RelTol", 1e-6);
test.assertEqual(landmarks, test.Reference.landmarks, "RelTol", 1e-6);
end

function testDetectWithOptions(test)
% We should be able to pass name value paris to detect faces
opts = {"MinSize", 20, ...
"MaxSize", 100, ...
"PyramidScale", 1.5, ...
"ConfidenceThresholds", [0.6, 0.6, 0.6], ...
"NmsThresholds", [0.6, 0.6, 0.6]};

[bboxes, scores, landmarks] = mtcnn.detectFaces(test.Image, opts{:});

test.assertEqual(size(bboxes), [6, 4]);
test.assertEqual(size(scores), [6, 1]);
test.assertEqual(size(landmarks), [6, 5, 2]);
end
end

end

0 comments on commit 8bfcbca

Please sign in to comment.