Commit f87cba62 by 何阳

new: 1. 开放容忍值设置接口

parent 70be7f7e
using SharpConfig;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FaceServer
{
......@@ -23,6 +18,7 @@ namespace FaceServer
LoginUrl = Api["LoginUrl"].GetValueOrDefault("/api/ucpm/console/token");
Test = Api["Test"].GetValueOrDefault(100);
Roi = Api["Roi"].GetValueOrDefault(420);
Tolerance = Api["Tolerance"].GetValueOrDefault(0.4);
ENCRYPT_PASSWD = Api["ENCRYPT_PASSWD"].GetValueOrDefault(false);
}
......@@ -30,12 +26,13 @@ namespace FaceServer
public static string Passwd { get; set; }
public static string BaseUrl { get; set; }
public static string LoginUrl { get; set; }
public static int Test { get; set; }
public static string OMP_TOKEN { get; internal set; }
public static string TENANT_ID { get; internal set; }
public static int Roi { get; internal set; }
public static bool ENCRYPT_PASSWD { get; internal set; }
public static double Tolerance { get; internal set; }
public static void Set(string section, string key, string value)
{
var sec = settings[section];
......
......@@ -33,6 +33,8 @@
this.tbROI = new System.Windows.Forms.TextBox();
this.label1 = new System.Windows.Forms.Label();
this.btSet = new System.Windows.Forms.Button();
this.tbTolerance = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// tbLog
......@@ -81,12 +83,30 @@
this.btSet.UseVisualStyleBackColor = true;
this.btSet.Click += new System.EventHandler(this.btSet_Click);
//
// tbTolerance
//
this.tbTolerance.Location = new System.Drawing.Point(304, 455);
this.tbTolerance.Name = "tbTolerance";
this.tbTolerance.Size = new System.Drawing.Size(100, 21);
this.tbTolerance.TabIndex = 2;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(179, 458);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(107, 12);
this.label2.TabIndex = 3;
this.label2.Text = "误差(越小越精准):";
//
// Main
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1238, 499);
this.Controls.Add(this.btSet);
this.Controls.Add(this.label2);
this.Controls.Add(this.tbTolerance);
this.Controls.Add(this.label1);
this.Controls.Add(this.tbROI);
this.Controls.Add(this.cbPowerOn);
......@@ -108,6 +128,8 @@
private System.Windows.Forms.TextBox tbROI;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button btSet;
private System.Windows.Forms.TextBox tbTolerance;
private System.Windows.Forms.Label label2;
}
}
......@@ -27,6 +27,7 @@ namespace FaceServer
this.ShowInTaskbar = false;//任务栏中显示标志
Config.Load("config.ini");
tbROI.Text = Config.Roi.ToString();
tbTolerance.Text = Config.Tolerance.ToString();
}
private void TrayIcon_MouseDoubleClick(object sender, MouseEventArgs e)
......@@ -330,6 +331,16 @@ namespace FaceServer
private void btSet_Click(object sender, EventArgs e)
{
Config.Set("Api", "Roi", tbROI.Text);
if (!double.TryParse(tbTolerance.Text, out _))
{
MessageBox.Show("置信度必须是数字");
}
else
{
Config.Set("Api", "Tolerance", tbTolerance.Text);
}
if (Server != null)
{
Server.RoiSize = Convert.ToInt32(tbROI.Text);
......
......@@ -12,6 +12,7 @@ using System.Windows.Media.Imaging;
using System.Text;
using Serilog;
using FaceServer.Util;
using FaceServer;
public class FaceRecognitionServer
{
......@@ -125,7 +126,7 @@ public class FaceRecognitionServer
// Helper method to find best match for a face
string FindBestMatch(FaceEncoding encoding, Dictionary<string, FaceEncoding> knownFaceEncodings)
{
double tolerance = 0.4; // Tolerance level for matching, may need adjustment
double tolerance = Config.Tolerance; // Tolerance level for matching, may need adjustment
string bestMatchName = "Unknown";
double bestMatchDistance = double.MaxValue;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment