Former-commit-id: 2848693d23e46a329d594b26662e67c67636c96e
TangShanKaiPing
wanggang 6 years ago
parent df51256949
commit 15066e09ef

@ -27,7 +27,10 @@ namespace FRT.Controllers
var result = 0;
DateTime start;
DateTime end;
this._FaceRecognition = FaceRecognition.Create(Path.Combine(this._env.WebRootPath, "face"));
Console.WriteLine(this._env.WebRootPath == null ? "web root is null" : this._env.WebRootPath);
var basePath = Path.Combine(this._env.WebRootPath, "face");
Console.WriteLine(basePath);
this._FaceRecognition = FaceRecognition.Create(basePath);
//
var path = Path.Combine(this._env.WebRootPath, "TestImages", $"1.jpg");
byte[] data = null;

@ -1,22 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.2</TargetFramework>
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
</PropertyGroup>
<ItemGroup>
<None Include="wwwroot\face\dlib_face_recognition_resnet_model_v1.dat">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="FaceRecognitionDotNet" Version="1.2.3.13" />
<PackageReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="System.Drawing.Common" Version="4.5.1" />
</ItemGroup>
</Project>
</Project>

@ -19,6 +19,8 @@ namespace FRT
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseWebRoot(Path.Combine(Directory.GetCurrentDirectory(), "publish/wwwroot"))
.UseUrls("http://*:5000")
.UseStartup<Startup>();
}
}

@ -130,6 +130,7 @@ namespace UserCenter.Controllers
{
using (var bitmap = new System.Drawing.Bitmap(stream))
{
Console.WriteLine($"face length:{face.Length}");
var userName = this._frs.FindFace(bitmap);
if (!string.IsNullOrEmpty(userName))
{

@ -49,6 +49,7 @@ namespace UserCenter.Services
private FaceEncoding GetFaceImageEncoding(string faceImage)
{
var faceImagePath = Path.Combine(this._env.WebRootPath, faceImage.TrimStart('/'));
Console.WriteLine(faceImage);
using (var img = FaceRecognition.LoadImageFile(faceImagePath))
{
var faceEncodings = this._faceRecognition.FaceEncodings(img).ToArray();
@ -84,6 +85,10 @@ namespace UserCenter.Services
}
}
}
else
{
Console.WriteLine("can't find face from image");
}
foreach (var encoding in encodings)
{
encoding.Dispose();
@ -109,7 +114,7 @@ namespace UserCenter.Services
face.Dispose();
}
private byte[] ToManaged(System.Drawing.Bitmap bitmap)
public byte[] ToManaged(System.Drawing.Bitmap bitmap)
{
var format = bitmap.PixelFormat;
var width = bitmap.Width;
@ -125,9 +130,7 @@ namespace UserCenter.Services
finally
{
if (bitmapData != null)
{
bitmap.UnlockBits(bitmapData);
}
}
return array;

@ -14,6 +14,7 @@
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
<PackageReference Include="Ocelot" Version="13.5.2" />
<PackageReference Include="RavenDB.Embedded" Version="4.2.1" />
<PackageReference Include="System.Drawing.Common" Version="4.5.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />

@ -1,3 +1,3 @@
ldd ./libDlibDotNetNative.so
apt-get install libopenblas-base
apt install libgdiplus-devel
apt install libgdiplus
Loading…
Cancel
Save