Skip to content

Commit 86d559d

Browse files
Merge branch 'release/1.3.0.1'
2 parents 5230393 + 5151433 commit 86d559d

File tree

101 files changed

+4538
-158
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

101 files changed

+4538
-158
lines changed

ExecuteTest.ps1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
$CodecovVersion = "1.7.1"
2-
$CoverletVersion = "1.4.1"
1+
$CodecovVersion = "1.10.0"
32

43
# check Codecov Token
54
$token = $env:CODECOV_TOKEN
@@ -12,8 +11,9 @@ if ([string]::IsNullOrEmpty($token))
1211
Write-Host "Environmental Value 'CODECOV_TOKEN' is ${token}." -ForegroundColor Green
1312

1413
# install coverlet
15-
dotnet tool install --global coverlet.console --version $CoverletVersion > $null
14+
dotnet tool install --global coverlet.console > $null
1615
dotnet add test\FaceRecognitionDotNet.Tests\FaceRecognitionDotNet.Tests.csproj package coverlet.msbuild > $null
16+
dotnet add test\FaceRecognitionDotNet.Tests\FaceRecognitionDotNet.Tests.csproj package coverlet.collector > $null
1717
# install codecov but it is not used from test project
1818
dotnet add test\FaceRecognitionDotNet.Tests\FaceRecognitionDotNet.Tests.csproj package Codecov --version $CodecovVersion > $null
1919

@@ -22,11 +22,14 @@ Write-Host "Start Test and collect Coverage." -ForegroundColor Green
2222
dotnet test test\FaceRecognitionDotNet.Tests\FaceRecognitionDotNet.Tests.csproj `
2323
/p:CollectCoverage=true `
2424
/p:CoverletOutputFormat=opencover `
25-
/p:Exclude="[DlibDotNet]*" `
26-
-c Release
25+
/p:Exclude="[DlibDotNet]*"
2726
Write-Host "End Test and collect Coverage." -ForegroundColor Green
2827

2928
$path = (dotnet nuget locals global-packages --list).Replace('info : global-packages: ', '').Trim()
29+
if ($path)
30+
{
31+
$path = (dotnet nuget locals global-packages --list).Replace('global-packages: ', '').Trim()
32+
}
3033
$path = Join-Path $path "codecov" | `
3134
Join-Path -ChildPath $CodecovVersion
3235

ExecuteTestNuget.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
set PROJECT=test\FaceRecognitionDotNet.Tests\FaceRecognitionDotNet.Tests
22
set PACKAGECPU=FaceRecognitionDotNet
3-
set PACKAGECUDA=FaceRecognitionDotNet.CUDA92
3+
set PACKAGECUDA=FaceRecognitionDotNet.CUDA102
44
set NUGETDIR=%cd%\nuget
55

66
dotnet remove %PROJECT%.csproj package %PACKAGECPU%

FaceRecognitionDotNet.sln

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenderTraining", "tools\Gen
3535
EndProject
3636
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelenTraining", "tools\HelenTraining\HelenTraining.csproj", "{86A8F7D7-E3D6-4478-856E-B0FA91F5ABFA}"
3737
EndProject
38+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlinkDetection", "examples\BlinkDetection\BlinkDetection.csproj", "{29E51D3D-7AEF-419E-9604-49116E28A211}"
39+
EndProject
40+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RgbBgr", "examples\RgbBgr\RgbBgr.csproj", "{13DDB1E7-EF71-48BA-A1E7-365C94783709}"
41+
EndProject
42+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HeadPoseTraining", "tools\HeadPoseTraining\HeadPoseTraining.csproj", "{BB6A1F98-DEF9-475C-A69A-82FE518D1E9E}"
43+
EndProject
44+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HeadPoseEstimationDemo", "examples\HeadPoseEstimationDemo\HeadPoseEstimationDemo.csproj", "{8540B212-5605-4402-BAE4-BEFEBAAD9F97}"
45+
EndProject
3846
Global
3947
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4048
Debug|Any CPU = Debug|Any CPU
@@ -89,6 +97,22 @@ Global
8997
{86A8F7D7-E3D6-4478-856E-B0FA91F5ABFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
9098
{86A8F7D7-E3D6-4478-856E-B0FA91F5ABFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
9199
{86A8F7D7-E3D6-4478-856E-B0FA91F5ABFA}.Release|Any CPU.Build.0 = Release|Any CPU
100+
{29E51D3D-7AEF-419E-9604-49116E28A211}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
101+
{29E51D3D-7AEF-419E-9604-49116E28A211}.Debug|Any CPU.Build.0 = Debug|Any CPU
102+
{29E51D3D-7AEF-419E-9604-49116E28A211}.Release|Any CPU.ActiveCfg = Release|Any CPU
103+
{29E51D3D-7AEF-419E-9604-49116E28A211}.Release|Any CPU.Build.0 = Release|Any CPU
104+
{13DDB1E7-EF71-48BA-A1E7-365C94783709}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
105+
{13DDB1E7-EF71-48BA-A1E7-365C94783709}.Debug|Any CPU.Build.0 = Debug|Any CPU
106+
{13DDB1E7-EF71-48BA-A1E7-365C94783709}.Release|Any CPU.ActiveCfg = Release|Any CPU
107+
{13DDB1E7-EF71-48BA-A1E7-365C94783709}.Release|Any CPU.Build.0 = Release|Any CPU
108+
{BB6A1F98-DEF9-475C-A69A-82FE518D1E9E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
109+
{BB6A1F98-DEF9-475C-A69A-82FE518D1E9E}.Debug|Any CPU.Build.0 = Debug|Any CPU
110+
{BB6A1F98-DEF9-475C-A69A-82FE518D1E9E}.Release|Any CPU.ActiveCfg = Release|Any CPU
111+
{BB6A1F98-DEF9-475C-A69A-82FE518D1E9E}.Release|Any CPU.Build.0 = Release|Any CPU
112+
{8540B212-5605-4402-BAE4-BEFEBAAD9F97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
113+
{8540B212-5605-4402-BAE4-BEFEBAAD9F97}.Debug|Any CPU.Build.0 = Debug|Any CPU
114+
{8540B212-5605-4402-BAE4-BEFEBAAD9F97}.Release|Any CPU.ActiveCfg = Release|Any CPU
115+
{8540B212-5605-4402-BAE4-BEFEBAAD9F97}.Release|Any CPU.Build.0 = Release|Any CPU
92116
EndGlobalSection
93117
GlobalSection(SolutionProperties) = preSolution
94118
HideSolutionNode = FALSE
@@ -106,6 +130,10 @@ Global
106130
{AF7429BE-0747-4E9A-AB2F-17480A8D485E} = {8C8838E0-B002-426F-9B25-4C1F65A6D33D}
107131
{44781AB4-D08C-4FDA-92EF-55C7CE9D5A18} = {8C8838E0-B002-426F-9B25-4C1F65A6D33D}
108132
{86A8F7D7-E3D6-4478-856E-B0FA91F5ABFA} = {8C8838E0-B002-426F-9B25-4C1F65A6D33D}
133+
{29E51D3D-7AEF-419E-9604-49116E28A211} = {FEEAC07F-70D7-4C12-B92C-153CEE0F2539}
134+
{13DDB1E7-EF71-48BA-A1E7-365C94783709} = {FEEAC07F-70D7-4C12-B92C-153CEE0F2539}
135+
{BB6A1F98-DEF9-475C-A69A-82FE518D1E9E} = {8C8838E0-B002-426F-9B25-4C1F65A6D33D}
136+
{8540B212-5605-4402-BAE4-BEFEBAAD9F97} = {FEEAC07F-70D7-4C12-B92C-153CEE0F2539}
109137
EndGlobalSection
110138
GlobalSection(ExtensibilityGlobals) = postSolution
111139
SolutionGuid = {4D44C572-D749-4A76-A199-8C598A08AE8A}

README.md

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ This package supports cross platform, Windows, Linux and MacOSX!!
1919
|FaceRecognitionDotNet for CUDA 10.1|Windows|-||-|-|[![NuGet version](https://img.shields.io/nuget/v/FaceRecognitionDotNet.CUDA101.svg)](https://www.nuget.org/packages/FaceRecognitionDotNet.CUDA101)|
2020
||Linux|-||-|-|[![NuGet version](https://img.shields.io/nuget/v/FaceRecognitionDotNet.CUDA101.svg)](https://www.nuget.org/packages/FaceRecognitionDotNet.CUDA101)|
2121
||OSX|-|-|-|-|[![NuGet version](https://img.shields.io/nuget/v/FaceRecognitionDotNet.CUDA101.svg)](https://www.nuget.org/packages/FaceRecognitionDotNet.CUDA101)|
22+
|FaceRecognitionDotNet for CUDA 10.2|Windows|-||-|-|[![NuGet version](https://img.shields.io/nuget/v/FaceRecognitionDotNet.CUDA102.svg)](https://www.nuget.org/packages/FaceRecognitionDotNet.CUDA102)|
23+
||Linux|-||-|-|[![NuGet version](https://img.shields.io/nuget/v/FaceRecognitionDotNet.CUDA102.svg)](https://www.nuget.org/packages/FaceRecognitionDotNet.CUDA102)|
24+
||OSX|-|-|-|-|[![NuGet version](https://img.shields.io/nuget/v/FaceRecognitionDotNet.CUDA102.svg)](https://www.nuget.org/packages/FaceRecognitionDotNet.CUDA102)|
2225
|FaceRecognitionDotNet for Intel MKL|Windows|-||-|-|[![NuGet version](https://img.shields.io/nuget/v/FaceRecognitionDotNet.MKL.svg)](https://www.nuget.org/packages/FaceRecognitionDotNet.MKL)|
2326
||Linux|-||-|-|[![NuGet version](https://img.shields.io/nuget/v/FaceRecognitionDotNet.MKL.svg)](https://www.nuget.org/packages/FaceRecognitionDotNet.MKL)|
2427
||OSX|-||-|-|[![NuGet version](https://img.shields.io/nuget/v/FaceRecognitionDotNet.MKL.svg)](https://www.nuget.org/packages/FaceRecognitionDotNet.MKL)|
@@ -40,11 +43,13 @@ This package supports cross platform, Windows, Linux and MacOSX!!
4043
|face_locations|FaceLocations||
4144
|load_image_file|LoadImageFile||
4245
|-|CropFaces|Crop image with specified locations|
43-
|-|LoadImage|From memory data|
44-
|-|PredictAge|Use **Adience Benchmark Of Unfiltered Faces For Gender And Age Classification dataset** :warning:|
45-
|-|PredictGender|Use **UTKFace dataset** :warning:|
46-
|-|PredictProbabilityAge|Use **Adience Benchmark Of Unfiltered Faces For Gender And Age Classification dataset** :warning:|
47-
|-|PredictProbabilityGender|Use **UTKFace dataset** :warning:|
46+
|-|EyeBlinkDetect|Detect person is blinking or not<br>Support Large model and **Helen dataset** :warning:|
47+
|-|LoadImage|From memory data or System.Drawing.Bitmap|
48+
|-|PredictAge|Predict human age.<br>Use **Adience Benchmark Of Unfiltered Faces For Gender And Age Classification dataset** :warning:|
49+
|-|PredictGender|Predict human gender.<br>Use **UTKFace dataset** :warning:|
50+
|-|PredictProbabilityAge|Predict probability of human age.<br>Use **Adience Benchmark Of Unfiltered Faces For Gender And Age Classification dataset** :warning:|
51+
|-|PredictProbabilityGender|Predict probability of human gender.<br>Use **UTKFace dataset** :warning:|
52+
|-|PredictHeadPose|Predict human head pose.<br>Use **300W-LP dataset** :warning:|
4853

4954
##### :warning: Warning
5055

@@ -54,23 +59,20 @@ You can check the following examples to train dataset.
5459

5560
* tools/AgeTraining
5661
* tools/GenderTraining
62+
* tools/HeadPoseTraining
5763
* tools/HelenTraining
5864

5965
## Demo
6066

6167
#### Face Recognition
6268

63-
<img src="images/1.png" width="480"/>
69+
<img src="images/1.png" width="480"/> <img src="images/2.png" width="480"/>
6470

65-
<img src="images/2.png" width="480"/>
71+
#### Other Face Functions
6672

67-
#### Face Landmark
68-
69-
<img src="images/3.jpg" width="240"/>
70-
71-
#### Age and Gender Classification
72-
73-
<img src="examples/CustomClassificationDemo/images/result.png" width="240"/>
73+
|Face Landmark|Age and Gender Classification|Head Pose Estimation|
74+
|---|---|---|
75+
|<img src="images/3.jpg" width="240"/>|<img src="examples/CustomClassificationDemo/images/result.png" width="240"/>|<img src="images/4.png" width="240"/>|
7476

7577
## Dependencies Libraries and Products
7678

@@ -112,5 +114,4 @@ You can check the following examples to train dataset.
112114
>
113115
> **Author:** shimat
114116
>
115-
> **Principal Use:** Loading image data by opencv wrapper for example
116-
117+
> **Principal Use:** Loading image data by opencv wrapper for example

examples/Benchmark/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ This sample requires test image and model files.
1414
1. Open command prompt and change to &lt;Benchmark_dir&gt;
1515
1. Type the following command
1616
````
17-
dotnet build -c Release
17+
$ dotnet remove reference ../../src/FaceRecognitionDotNet\FaceRecognitionDotNet.csproj
18+
$ dotnet add package FaceRecognitionDotNet
19+
$ dotnet build -c Release
1820
````
1921
2. Copy ***DlibDotNet.dll***, ***DlibDotNet.Native.dll*** and ***DlibDotNet.Dnn.dll*** to output directory; &lt;Benchmark_dir&gt;\bin\Release\netcoreapp2.0.
2022
* if you use FaceRecognitionDotNet with CUDA, you must copy also cuda libraries.

examples/BlinkDetection/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dlib_face_recognition_resnet_model_v1.dat
2+
mmod_human_face_detector.dat
3+
shape_predictor_5_face_landmarks.dat
4+
shape_predictor_68_face_landmarks.dat
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp2.0</TargetFramework>
6+
<Authors>Takuya Takeuchi</Authors>
7+
<Description>Example of FaceRecognitionDotNet</Description>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.1" />
12+
<PackageReference Include="OpenCvSharp3-AnyCPU" Version="3.4.4.20181118" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\..\src\FaceRecognitionDotNet\FaceRecognitionDotNet.csproj" />
17+
</ItemGroup>
18+
19+
</Project>

examples/BlinkDetection/Program.cs

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Runtime.InteropServices;
5+
using FaceRecognitionDotNet;
6+
using FaceRecognitionDotNet.Extensions;
7+
using Microsoft.Extensions.CommandLineUtils;
8+
using OpenCvSharp;
9+
using Point = FaceRecognitionDotNet.Point;
10+
11+
namespace BlinkDetection
12+
{
13+
14+
internal class Program
15+
{
16+
17+
#region Fields
18+
19+
private const int EyesClosedSeconds = 5;
20+
21+
#endregion
22+
23+
#region Methods
24+
25+
private static void Main(string[] args)
26+
{
27+
var app = new CommandLineApplication(false);
28+
app.Name = nameof(BlinkDetection);
29+
app.Description = "The program for blink detection demo";
30+
app.HelpOption("-h|--help");
31+
32+
app.OnExecute(() =>
33+
{
34+
var closedCount = 0;
35+
var process = true;
36+
37+
using (var fr = FaceRecognition.Create("models"))
38+
using (var videoCapture = new VideoCapture(0))
39+
{
40+
fr.CustomEyeBlinkDetector = new EyeAspectRatioLargeEyeBlinkDetector(0.2, 0.2);
41+
42+
while (true)
43+
{
44+
using (var frame = videoCapture.RetrieveMat())
45+
using (var smallFrame = new Mat())
46+
{
47+
if (process)
48+
{
49+
//Cv2.Resize(frame, smallFrame, Size.Zero, 0.25, 0.25);
50+
Cv2.Resize(frame, smallFrame, Size.Zero, 1, 1);
51+
52+
var cols = smallFrame.Cols;
53+
var rows = smallFrame.Rows;
54+
var elems = smallFrame.ElemSize();
55+
56+
57+
// get the correct face landmarks
58+
var bytes = new byte[rows * cols * elems];
59+
Marshal.Copy(smallFrame.Data, bytes, 0, bytes.Length);
60+
using (var rgbSmallFrame = FaceRecognition.LoadImage(bytes, rows, cols, cols * elems, Mode.Rgb))
61+
{
62+
var faceLandmarksList = fr.FaceLandmark(rgbSmallFrame).ToArray();
63+
64+
// get eyes
65+
foreach (var faceLandmark in faceLandmarksList)
66+
{
67+
var leftEye = faceLandmark[FacePart.LeftEye].ToArray();
68+
var rightEye = faceLandmark[FacePart.RightEye].ToArray();
69+
70+
var color = new Scalar(255, 0, 0);
71+
var thickness = 2;
72+
73+
var lp = new OpenCvSharp.Point(leftEye[0].Point.X, leftEye[0].Point.Y);
74+
var rp = new OpenCvSharp.Point(rightEye[rightEye.Length - 1].Point.X, rightEye[rightEye.Length - 1].Point.Y);
75+
var l = Math.Min(lp.X, rp.X);
76+
var r = Math.Max(lp.X, rp.X);
77+
var t = Math.Min(lp.Y, rp.Y);
78+
var b = Math.Max(lp.Y, rp.Y);
79+
Cv2.Rectangle(smallFrame, new OpenCvSharp.Point(l, t), new OpenCvSharp.Point(r, b), color, thickness);
80+
81+
Cv2.ImShow("Video", smallFrame);
82+
Cv2.WaitKey(1);
83+
84+
fr.EyeBlinkDetect(faceLandmark, out var leftBlink, out var rightBlink);
85+
86+
var closed = leftBlink && rightBlink;
87+
88+
if (closed)
89+
closedCount += 1;
90+
else
91+
closedCount = 0;
92+
93+
if (closedCount >= EyesClosedSeconds)
94+
{
95+
var asleep = true;
96+
while (asleep) // continue this loop until they wake up and acknowledge music
97+
{
98+
Console.WriteLine("EYE CLOSED");
99+
100+
var key = Console.ReadKey();
101+
102+
if (key.Key == ConsoleKey.Spacebar)
103+
asleep = false;
104+
}
105+
106+
closedCount = 0;
107+
}
108+
}
109+
}
110+
}
111+
112+
process = !process;
113+
}
114+
}
115+
}
116+
117+
return 0;
118+
});
119+
120+
app.Execute(args);
121+
}
122+
123+
#endregion
124+
125+
}
126+
127+
}

examples/BlinkDetection/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Blink Detection
2+
3+
This example demonstrate detection of eye blink.
4+
This sample program is ported by C# from https://github.com/ageitgey/face_recognition/blob/master/examples/blink_detection.py
5+
6+
## How to use?
7+
8+
## 1. Preparation
9+
10+
This sample requires model files and webcam.
11+
12+
## 2. Build
13+
14+
1. Open command prompt and change to &lt;BlinkDetection_dir&gt;
15+
1. Type the following command
16+
````
17+
$ dotnet remove reference ../../src/FaceRecognitionDotNet\FaceRecognitionDotNet.csproj
18+
$ dotnet add package FaceRecognitionDotNet
19+
$ dotnet build -c Release
20+
````
21+
22+
## 3. Run
23+
24+
1. Open command prompt and change to &lt;BlinkDetection_dir&gt;
25+
1. Type the following sample command
26+
````
27+
$ dotnet run -c Release
28+
````
29+
1. CameraImage is shown after camera detect face
30+
1. Blue rectangle is drawn if syes are detected
31+
1. Program will be paused if eyes are closing on 5 sec
32+
1. User can restart program by push space button if program is paused

examples/CustomClassificationDemo/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ And you must generate the following model files and copy to &lt;CustomClassifica
2222
1. Open command prompt and change to &lt;CustomClassificationDemo_dir&gt;
2323
1. Type the following command
2424
````
25-
dotnet build -c Release
25+
$ dotnet remove reference ../../src/FaceRecognitionDotNet\FaceRecognitionDotNet.csproj
26+
$ dotnet add package FaceRecognitionDotNet
27+
$ dotnet build -c Release
2628
````
2729
3. Copy ***DlibDotNetNative.dll***, ***DlibDotNetNativeDnn.dll***, ***DlibDotNetNativeDnnAgeClassification.dll*** and ***DlibDotNetNativeDnnGenderClassification.dll*** to output directory; &lt;CustomClassificationDemo_dir&gt;\bin\Release\netcoreapp2.0.
2830
* if you use FaceRecognitionDotNet with CUDA, you must copy also cuda libraries.

0 commit comments

Comments
 (0)