Skip to content

Commit

Permalink
使用 SkiaSharp.SKBitmap 代替 System.Drawing.Bitmap
Browse files Browse the repository at this point in the history
为了对不特别版的SDK兼容,迁移了SDK文件路径
增加了一个演示用命令行程序
  • Loading branch information
yangjieshao committed Feb 21, 2023
1 parent 4872aa4 commit f57f173
Show file tree
Hide file tree
Showing 31 changed files with 3,754 additions and 680 deletions.
12 changes: 12 additions & 0 deletions ArcSoftFace.Test/ArcSoftFace.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>NET6.0;NET40</TargetFrameworks>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Src\Yj.ArcSoftSDK.4_0.csproj" />
</ItemGroup>

</Project>
104 changes: 104 additions & 0 deletions ArcSoftFace.Test/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
using System;
using System.IO;
using Yj.ArcSoftSDK._4_0;

namespace ArcSoftFace.Test
{
class Program
{
static void Main(string[] args)
{
ArcTestUtil arcTestUtil = new ArcTestUtil();
arcTestUtil.InitEngines();
}
}


public class ArcTestUtil
{
/// <summary>
/// 初始化引擎
/// </summary>
public void InitEngines()
{
int retCode=-1;
try
{
IntPtr _pVideoRGBImageEngine = IntPtr.Zero;

//retCode = ASFFunctions.Activation(appId: "11111"
// , x86SdkKey: ""
// , x64SdkKey: "22222"
// , sox64Key: ""
// , x64ProActiveKey: "33333"
// , x86ProActiveKey: "");
//Console.WriteLine($"Activation: {retCode}");

retCode = ASFFunctions.InitEngine(pEngine: ref _pVideoRGBImageEngine, isImgMode: true, faceMaxNum: 5,
isAngleZeroOnly: false, needFaceInfo: true, needRgbLive: true, needIrLive: true, needFaceFeature: true);
Console.WriteLine($"Init pEngine: {retCode}");

var faceInfos = ASFFunctions.DetectFacesEx(_pVideoRGBImageEngine, File.ReadAllBytes("3.jpg"),
faceMinWith: 0,
needCheckImage: true,
needFaceInfo: true,
needRgbLive: true,
needIrLive: true,
needFeatures: true,
isRegister:false);
var faceInfos2 = ASFFunctions.DetectFacesEx(_pVideoRGBImageEngine, File.ReadAllBytes("003.jpg"),
faceMinWith: 0,
needCheckImage: true,
needFaceInfo: true,
needRgbLive: true,
needIrLive: true,
needFeatures: true,
isRegister: false);

byte[] feature1 = null;// System.IO.File.ReadAllBytes("feature1.dat");
foreach (var faceInfo in faceInfos)
{
if (faceInfo.Feature != null)
{
feature1 = new byte[faceInfo.Feature.Length];
faceInfo.Feature.CopyTo(feature1, 0);
}

Console.WriteLine($"pic1 FaceID:{faceInfo.FaceID} 角度: {faceInfo.FaceOrient}" +
$" 年龄: {faceInfo.Age} 性别: {faceInfo.Gender} 活体: {faceInfo.RgbLive}" +
$" Rect<Left:{faceInfo.Rectangle.Left:0000},Right:{faceInfo.Rectangle.Right:0000},Top:{faceInfo.Rectangle.Top:0000},Bottom:{faceInfo.Rectangle.Bottom:0000}>" +
$" 3DAngle<Roll:{faceInfo.Face3DAngle.Roll:000.000},Yaw:{faceInfo.Face3DAngle.Yaw:000.000},Pitch:{faceInfo.Face3DAngle.Pitch:000.000}>");
}

byte[] feature2 = null;// System.IO.File.ReadAllBytes("feature2.dat");
foreach (var faceInfo in faceInfos2)
{
if (faceInfo.Feature != null)
{
feature2 = new byte[faceInfo.Feature.Length];
faceInfo.Feature.CopyTo(feature2, 0);
}

Console.WriteLine($"pic2 FaceID:{faceInfo.FaceID} 角度: {faceInfo.FaceOrient}" +
$" 年龄: {faceInfo.Age} 性别: {faceInfo.Gender} 活体: {faceInfo.RgbLive}" +
$" Rect<Left:{faceInfo.Rectangle.Left:0000},Right:{faceInfo.Rectangle.Right:0000},Top:{faceInfo.Rectangle.Top:0000},Bottom:{faceInfo.Rectangle.Bottom:0000}>" +
$" 3DAngle<Roll:{faceInfo.Face3DAngle.Roll:000.000},Yaw:{faceInfo.Face3DAngle.Yaw:000.000},Pitch:{faceInfo.Face3DAngle.Pitch:000.000}>");
}

if (feature1 != null
&& feature1.Length > 0
&& feature2 != null
&& feature2.Length > 0)
{
float similarity = ASFFunctions.FaceFeatureCompare(_pVideoRGBImageEngine, feature1, feature2);
Console.WriteLine($"bitmap1 similarity bitmap2: {similarity}");
}
}
catch
{

}

}
}
}
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
版本: So64 v4.0<br/>
版本: x86 x64 v4.0<br/>

商用授权 离线激活 将激活验证文件更名为 ArcFace64.dat ArcFace32.dat
Linux
SDK动态链接库路径 自行复制至 /usr/lib
cp -Rf /mnt/d/Linux_x64/ArcProLib/Sox64/* /usr/lib


````
Expand Down
Loading

0 comments on commit f57f173

Please sign in to comment.