-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
使用 SkiaSharp.SKBitmap 代替 System.Drawing.Bitmap
为了对不特别版的SDK兼容,迁移了SDK文件路径 增加了一个演示用命令行程序
- Loading branch information
1 parent
4872aa4
commit f57f173
Showing
31 changed files
with
3,754 additions
and
680 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
||
} | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.