Skip to content

Commit

Permalink
Fixed freezes
Browse files Browse the repository at this point in the history
  • Loading branch information
rembound committed Apr 8, 2018
1 parent 02f7bef commit 548091e
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 232 deletions.
8 changes: 0 additions & 8 deletions ArenaHelper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@
<Compile Include="Controls\Card.xaml.cs">
<DependentUpon>Card.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\DebugTextBlock.xaml.cs">
<DependentUpon>DebugTextBlock.xaml</DependentUpon>
</Compile>
<Compile Include="Controls\DeckRating.xaml.cs">
<DependentUpon>DeckRating.xaml</DependentUpon>
</Compile>
Expand All @@ -89,7 +86,6 @@
<Compile Include="Controls\ValueOverlay.xaml.cs">
<DependentUpon>ValueOverlay.xaml</DependentUpon>
</Compile>
<Compile Include="Debug.cs" />
<Compile Include="Detection.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Plugins.cs" />
Expand Down Expand Up @@ -117,10 +113,6 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\DebugTextBlock.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Controls\DeckRating.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
Expand Down
5 changes: 2 additions & 3 deletions ArenaWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
<TextBlock TextWrapping="Wrap" VerticalAlignment="Top">Manual card picking<LineBreak />Pick a card in Hearthstone, afterwards, click the card in the Arena Helper window. Don't detect picks automatically.</TextBlock>
</CheckBox>
<CheckBox x:Name="CheckBoxAutoSave" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,8,0,0" Checked="CheckBoxAutoSave_Checked" Unchecked="CheckBoxAutoSave_Unchecked" Content="Automatically save and use the deck" />
<CheckBox x:Name="CheckBoxDebug" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="8,8,0,0" Checked="CheckBoxDebug_Checked" Unchecked="CheckBoxDebug_Unchecked" Content="Enable debug mode" />
</StackPanel>
</controls:Flyout>

Expand Down Expand Up @@ -130,8 +129,8 @@
</WrapPanel>

<WrapPanel Grid.Column="1" VerticalAlignment="Center">
<Button x:Name="Button1" Width="70" Content="New Arena" Margin="0 0 8 0" Click="ButtonNewArena_Click" />
<Button x:Name="Button2" Width="70" Content="Save Deck" Margin="0 0 8 0" Click="ButtonSave_Click" />
<Button x:Name="Button1" Width="74" Content="New Arena" Margin="0 0 8 0" Click="ButtonNewArena_Click" />
<Button x:Name="Button2" Width="74" Content="Save Deck" Margin="0 0 8 0" Click="ButtonSave_Click" />
</WrapPanel>
</Grid>
<Separator Background="{DynamicResource SeparatorBackground}" />
Expand Down
17 changes: 0 additions & 17 deletions ArenaWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public partial class ArenaWindow
public OnCheckbox oncheckboxoverlay = null;
public OnCheckbox oncheckboxmanual = null;
public OnCheckbox oncheckboxautosave = null;
public OnCheckbox oncheckboxdebug = null;

public OnEvent onupdatedownloadclick = null;

Expand Down Expand Up @@ -401,22 +400,6 @@ private void CheckBoxAutoSave_Unchecked(object sender, RoutedEventArgs e)
}
}

private void CheckBoxDebug_Checked(object sender, RoutedEventArgs e)
{
if (oncheckboxdebug != null)
{
oncheckboxdebug(true);
}
}

private void CheckBoxDebug_Unchecked(object sender, RoutedEventArgs e)
{
if (oncheckboxdebug != null)
{
oncheckboxdebug(false);
}
}

private void ConfigureHero_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
// Override hero detection
Expand Down
8 changes: 0 additions & 8 deletions Controls/DebugTextBlock.xaml

This file was deleted.

28 changes: 0 additions & 28 deletions Controls/DebugTextBlock.xaml.cs

This file was deleted.

40 changes: 0 additions & 40 deletions Debug.cs

This file was deleted.

27 changes: 7 additions & 20 deletions Detection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,11 @@ public ulong GetScreenCardHash(int index)
{
CropBitmapRelative(ref capture, cardrect, cardcroprect);

System.Windows.Controls.Image imagecontrol = Debug.debugimages[index];
hash = GetImageHash(capture, ref imagecontrol);
hash = GetImageHash(capture);
}
catch (Exception e)
{
string errormsg = "Error2: " + e.Message + "\n" + e.ToString();
Debug.Log(errormsg);
Log.Info(errormsg);
Log.Error("Error2: " + e.Message);
}
}

Expand All @@ -264,14 +261,11 @@ public ulong GetScreenHeroHash(int index)
{
try
{
System.Windows.Controls.Image imagecontrol = Debug.debugimages[index];
hash = GetImageHash(capture, ref imagecontrol);
hash = GetImageHash(capture);
}
catch (Exception e)
{
string errormsg = "Error3: " + e.Message + "\n" + e.ToString();
Debug.Log(errormsg);
Log.Info(errormsg);
Log.Error("Error3: " + e.Message);
}
}

Expand All @@ -294,22 +288,19 @@ public ulong GetScreenHash(Rectangle rect, int scalewidth, int scaleheight)
{
try
{
System.Windows.Controls.Image imagecontrol = Debug.debugimages[0];
hash = GetImageHash(capture, ref imagecontrol);
hash = GetImageHash(capture);
}
catch (Exception e)
{
string errormsg = "Error4: " + e.Message + "\n" + e.ToString();
Debug.Log(errormsg);
Log.Info(errormsg);
Log.Error("Error4: " + e.Message);
}
}

return hash;
}

// Perceptual hash using the techniques from: http://www.hackerfactor.com/blog/?/archives/432-Looks-Like-It.html
public ulong GetImageHash(Bitmap bitmap, ref System.Windows.Controls.Image imagecontrol)
public ulong GetImageHash(Bitmap bitmap)
{
// Copy the image and convert to grayscale
Bitmap sourcebm = new Bitmap(bitmap);
Expand All @@ -318,10 +309,6 @@ public ulong GetImageHash(Bitmap bitmap, ref System.Windows.Controls.Image image
// Apply a convolution filter of 4x4
CvInvoke.Blur(sourceimage, sourceimage, new Size(4, 4), new Point(-1, -1));

// Show image for debugging
//Image<Bgra, Byte> convimage = Image<Bgra, Byte>.FromIplImagePtr(sourceimage);
//ShowBitmap(convimage.ToBitmap(), ref imagecontrol);

// Resize to 64x64 pixels
Image<Gray, float> resimage = new Image<Gray, float>(new Size(64, 64));
CvInvoke.Resize(sourceimage, resimage, new Size(64, 64));
Expand Down
Loading

0 comments on commit 548091e

Please sign in to comment.