Skip to content

Commit

Permalink
修改对比判定条件
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoweijie committed May 28, 2021
1 parent 5071d2c commit d269b13
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Main/Properties/PublishProfiles/FolderProfile.pubxml.user
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<History>True|2021-05-23T04:45:00.3831182Z;True|2021-05-23T12:44:46.6625739+08:00;True|2021-05-23T12:34:46.2028913+08:00;False|2021-05-23T12:34:32.8229574+08:00;True|2021-05-23T12:33:25.9202742+08:00;True|2021-05-23T12:33:17.0807529+08:00;True|2021-05-23T12:27:07.7653099+08:00;True|2021-05-23T12:16:21.2685328+08:00;True|2021-05-15T12:04:25.7312900+08:00;True|2021-05-15T09:48:24.0285959+08:00;False|2021-05-15T09:48:08.6140819+08:00;True|2021-05-15T09:43:33.6312364+08:00;True|2021-05-15T09:36:09.1553253+08:00;True|2021-05-15T09:32:43.6855729+08:00;True|2021-04-30T08:22:20.1915383+08:00;True|2021-04-29T08:55:13.7356099+08:00;True|2021-04-29T08:50:32.7047139+08:00;True|2021-04-27T15:53:54.9338289+08:00;True|2021-04-27T15:32:11.0129452+08:00;True|2021-04-27T15:17:43.2702869+08:00;True|2021-04-27T15:16:29.5035004+08:00;True|2021-04-27T15:10:57.9547024+08:00;True|2021-04-27T13:33:13.1815046+08:00;True|2021-04-27T13:26:24.7221810+08:00;True|2021-04-27T13:05:01.8883310+08:00;True|2021-04-27T11:54:28.2903342+08:00;</History>
<History>True|2021-05-28T01:44:56.7553044Z;True|2021-05-23T12:45:00.3831182+08:00;True|2021-05-23T12:44:46.6625739+08:00;True|2021-05-23T12:34:46.2028913+08:00;False|2021-05-23T12:34:32.8229574+08:00;True|2021-05-23T12:33:25.9202742+08:00;True|2021-05-23T12:33:17.0807529+08:00;True|2021-05-23T12:27:07.7653099+08:00;True|2021-05-23T12:16:21.2685328+08:00;True|2021-05-15T12:04:25.7312900+08:00;True|2021-05-15T09:48:24.0285959+08:00;False|2021-05-15T09:48:08.6140819+08:00;True|2021-05-15T09:43:33.6312364+08:00;True|2021-05-15T09:36:09.1553253+08:00;True|2021-05-15T09:32:43.6855729+08:00;True|2021-04-30T08:22:20.1915383+08:00;True|2021-04-29T08:55:13.7356099+08:00;True|2021-04-29T08:50:32.7047139+08:00;True|2021-04-27T15:53:54.9338289+08:00;True|2021-04-27T15:32:11.0129452+08:00;True|2021-04-27T15:17:43.2702869+08:00;True|2021-04-27T15:16:29.5035004+08:00;True|2021-04-27T15:10:57.9547024+08:00;True|2021-04-27T13:33:13.1815046+08:00;True|2021-04-27T13:26:24.7221810+08:00;True|2021-04-27T13:05:01.8883310+08:00;True|2021-04-27T11:54:28.2903342+08:00;</History>
</PropertyGroup>
</Project>
47 changes: 17 additions & 30 deletions Main/Service/TaskExcuteService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class TaskExcuteService : ImagePhash
/// <returns></returns>
public bool StartTaskForPHash(List<Bitmap> imageList)
{
int state = 0;
bool state = true;
//比较两张图片的评分
float score;
int count = 0;
Expand All @@ -45,13 +45,15 @@ public bool StartTaskForPHash(List<Bitmap> imageList)
var gameHash = ComputeDigest(imageList[i].ToLuminanceImage());
//string gameHash = SimilarPhoto.GetHash(image);
var hash = GetMainPic(i);
score = ImagePhash.GetCrossCorrelation(gameHash, hash);
state = score >= 0.8f ? 1 : 0;
count += state;
score = GetCrossCorrelation(gameHash, hash);
if(score < 0.8f)
{
state = false;
}
}
//默认值90%
//return score > DEFAULT_THRESHOLD;
return count == imageList.Count;
return state;
}


Expand All @@ -65,7 +67,7 @@ public bool StartTaskForPHash(List<Bitmap> imageList)
/// <returns></returns>
public bool StartTaskForPHash(List<Bitmap> imageList, GameType gameType)
{
int state = 0;
bool state = true;
//比较两张图片的评分
float score;
int count = 0;
Expand All @@ -81,12 +83,14 @@ public bool StartTaskForPHash(List<Bitmap> imageList, GameType gameType)
//string gameHash = SimilarPhoto.GetHash(image);
var hash = GetMainPic(i,gameType);
score = GetCrossCorrelation(gameHash, hash);
state = score >= 0.8f ? 1 : 0;
count += state;
if (score < 0.8f)
{
state = false;
}
}
//默认值90%
//return score > DEFAULT_THRESHOLD;
return count == imageList.Count;
return state;
}

/// <summary>
Expand Down Expand Up @@ -122,28 +126,11 @@ public Digest GetMainPic(int id)
//Image mainImage = null;
//Bitmap bitmap = null;
//第一张
if (id == 0)
{
//mainImage = SimilarPhoto.GetImage(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images\\1.png"));
using var bitmap = (Bitmap)Image.FromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images\\MainImage\\1.png"));
hash = ComputeDigest(bitmap.ToLuminanceImage());
}
if (id == 1)
{
//mainImage = SimilarPhoto.GetImage(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images\\2.png"));
using var bitmap = (Bitmap)Image.FromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images\\MainImage\\2.png"));
hash = ComputeDigest(bitmap.ToLuminanceImage());
}
if (id == 2)
{
//mainImage = SimilarPhoto.GetImage(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images\\3.png"));
using var bitmap = (Bitmap)Image.FromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images\\MainImage\\3.png"));
hash = ComputeDigest(bitmap.ToLuminanceImage());
}
//value = SimilarPhoto.GetHash(mainImage);
//var bitmap = (Bitmap)Image.FromFile(fullPathToImage);


//mainImage = SimilarPhoto.GetImage(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images\\1.png"));
using var bitmap = (Bitmap)Image.FromFile(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"Images\\MainImage\\{id + 1}.png"));
hash = ComputeDigest(bitmap.ToLuminanceImage());

//var score = ImagePhash.GetCrossCorrelation(hash1, hash2);
keyValuePairs.TryAdd(id, hash);
}
Expand Down

0 comments on commit d269b13

Please sign in to comment.