Skip to content

Commit

Permalink
pusblish
Browse files Browse the repository at this point in the history
  • Loading branch information
NAinfini committed Aug 26, 2023
1 parent f48f44b commit aaf4873
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 41 deletions.
4 changes: 2 additions & 2 deletions GameZBDAlchemyStoneTapper.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ Global
{7B54F7B9-2653-40D9-AD76-6928FF466FF9}.Release|ARM32.Build.0 = Release|ARM32
{7B54F7B9-2653-40D9-AD76-6928FF466FF9}.Release|ARM64.ActiveCfg = Release|ARM64
{7B54F7B9-2653-40D9-AD76-6928FF466FF9}.Release|ARM64.Build.0 = Release|ARM64
{7B54F7B9-2653-40D9-AD76-6928FF466FF9}.Release|x64.ActiveCfg = Release|x64
{7B54F7B9-2653-40D9-AD76-6928FF466FF9}.Release|x64.Build.0 = Release|x64
{7B54F7B9-2653-40D9-AD76-6928FF466FF9}.Release|x64.ActiveCfg = Release|Any CPU
{7B54F7B9-2653-40D9-AD76-6928FF466FF9}.Release|x64.Build.0 = Release|Any CPU
{7B54F7B9-2653-40D9-AD76-6928FF466FF9}.Release|x86.ActiveCfg = Release|x86
{7B54F7B9-2653-40D9-AD76-6928FF466FF9}.Release|x86.Build.0 = Release|x86
{3AB215EA-4757-4C60-8681-9B5453AD4738}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
Expand Down
3 changes: 3 additions & 0 deletions GameZBDAlchemyStoneTapper/FodyWeavers.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
<Costura />
</Weavers>
20 changes: 4 additions & 16 deletions GameZBDAlchemyStoneTapper/GameZBDAlchemyStoneTapper.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,19 @@
<OutputPath>bin\x64\Release\</OutputPath>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Emgu.CV">
<Version>4.7.0.5276</Version>
<PackageReference Include="Costura.Fody" Version="5.7.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Emgu.CV.Bitmap">
<Version>4.7.0.5276</Version>
</PackageReference>
<PackageReference Include="Emgu.CV.runtime.windows">
<Version>4.7.0.5276</Version>
</PackageReference>
<PackageReference Include="IronSoftware.System.Drawing" Version="2023.9.2" />
<PackageReference Include="Microsoft.DotNet.UpgradeAssistant.Extensions.Default.Analyzers">
<Version>0.4.421302</Version>
</PackageReference>
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="1.15.1" />
<PackageReference Include="OpenCV">
<Version>2.4.11</Version>
</PackageReference>
<PackageReference Include="SixLabors.Fonts" Version="1.0.0" />
<PackageReference Include="SixLabors.ImageSharp" Version="3.0.1" />
<PackageReference Include="Microsoft.AspNetCore.SystemWebAdapters" Version="1.2.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
<PackageReference Include="System.Collections.NonGeneric" Version="4.3.0" />
<PackageReference Include="NumSharp" Version="0.30.0" />
<PackageReference Include="System.ComponentModel.Composition" Version="7.0.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\..\Downloads\Yolov7net-master\Yolov7net-master\src\Yolov7net\IVilson.AI.Yolov7net.csproj" />
</ItemGroup>
</Project>
5 changes: 1 addition & 4 deletions GameZBDAlchemyStoneTapper/ObjectDetection.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using IronSoftware.Drawing;
using SixLabors.ImageSharp;
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
Expand Down Expand Up @@ -61,7 +59,6 @@ public Bitmap drawRectangles(Bitmap image, List<YoloPrediction> predictions)
new System.Drawing.PointF(x, y));
}
}
image.Save("./temp.png");
return image;
}

Expand Down
5 changes: 2 additions & 3 deletions GameZBDAlchemyStoneTapper/SODForm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using IronSoftware.Drawing;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
Expand Down Expand Up @@ -142,7 +141,7 @@ private void startBtn_Click(object sender, EventArgs e)
this.ScreenHeight = tempArea.Height;
}
}
AnyBitmap tempMap = CaptureScreen.Snip(ScreenX, ScreenY, ScreenWidth, ScreenHeight);
Bitmap tempMap = CaptureScreen.Snip(ScreenX, ScreenY, ScreenWidth, ScreenHeight);

OBJ = new ObjectDetection();
OBJ.loadLists(selectedAlchemyStone, selectedMaterial);
Expand Down
5 changes: 2 additions & 3 deletions GameZBDAlchemyStoneTapper/SOLForm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using IronSoftware.Drawing;
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
Expand Down Expand Up @@ -148,7 +147,7 @@ private void startBtn_Click(object sender, EventArgs e)
this.ScreenHeight = tempArea.Height;
}
}
AnyBitmap tempMap = CaptureScreen.Snip(ScreenX, ScreenY, ScreenWidth, ScreenHeight);
Bitmap tempMap = CaptureScreen.Snip(ScreenX, ScreenY, ScreenWidth, ScreenHeight);

OBJ = new ObjectDetection();
OBJ.loadLists(selectedAlchemyStone, selectedMaterial);
Expand Down
5 changes: 2 additions & 3 deletions GameZBDAlchemyStoneTapper/SOPForm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using IronSoftware.Drawing;
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
Expand Down Expand Up @@ -147,7 +146,7 @@ private void startBtn_Click(object sender, EventArgs e)
this.ScreenHeight = tempArea.Height;
}
}
AnyBitmap tempMap = CaptureScreen.Snip(ScreenX, ScreenY, ScreenWidth, ScreenHeight);
Bitmap tempMap = CaptureScreen.Snip(ScreenX, ScreenY, ScreenWidth, ScreenHeight);

OBJ = new ObjectDetection();
OBJ.loadLists(selectedAlchemyStone, selectedMaterial);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<Authors>ivilson.com</Authors>
<Version>1.0.3</Version>
<Description>yolov7 onnx interface for .net 6</Description>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
</PropertyGroup>

<ItemGroup>
Expand Down
14 changes: 4 additions & 10 deletions GameZBDAlchemyStoneTapper/Yolov7net/Yolov8.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ public class Yolov8 : IDisposable

public Yolov8(string modelPath, bool useCuda = false)
{

if (useCuda)
{
SessionOptions opts = SessionOptions.MakeSessionOptionWithCudaProvider();
Expand Down Expand Up @@ -47,7 +46,7 @@ public void SetupYoloDefaultLabels()
SetupLabels(s);
}

public List<YoloPrediction> Predict(Image image, float conf_thres = 0, float iou_thres = 0,bool useNumpy = false)
public List<YoloPrediction> Predict(Image image, float conf_thres = 0, float iou_thres = 0, bool useNumpy = false)
{
if (conf_thres > 0f)
{
Expand Down Expand Up @@ -137,9 +136,9 @@ private List<YoloPrediction> ParseDetect(DenseTensor<float> output, Image image)
{
var result = new ConcurrentBag<YoloPrediction>();

var (w, h) = (image.Width, image.Height);
var (w, h) = (image.Width, image.Height);
var (xGain, yGain) = (_model.Width / (float)w, _model.Height / (float)h);
var gain = Math.Min(xGain, yGain);
var gain = Math.Min(xGain, yGain);

var (xPad, yPad) = ((_model.Width - w * gain) / 2, (_model.Height - h * gain) / 2);

Expand Down Expand Up @@ -178,7 +177,6 @@ private List<YoloPrediction> ParseDetect(DenseTensor<float> output, Image image)
return result.ToList();
}


private List<YoloPrediction> ParseDetectNumpy(DenseTensor<float> output, Image image)
{
float[] outputArray = output.ToArray();
Expand Down Expand Up @@ -209,10 +207,8 @@ private List<YoloPrediction> ProcessResult(NDArray data, Image image)
return result.ToList();
}


private int[] nms(NDArray boxes, NDArray scores, float iou_threshold = .5f)
{

// Sort by score
var sortedIndices = np.argsort<float>(scores)["::-1"];

Expand Down Expand Up @@ -275,7 +271,6 @@ public NDArray Xywh2Xyxy(NDArray x)

private NDArray rescale_boxes(NDArray boxes, int width, int height)
{

NDArray inputShape = np.array(new float[] { _model.Width, _model.Height, _model.Width, _model.Height });
NDArray resizedBoxes = np.divide(boxes, inputShape);
resizedBoxes = np.multiply(resizedBoxes, new float[] { width, height, width, height });
Expand All @@ -285,7 +280,6 @@ private NDArray rescale_boxes(NDArray boxes, int width, int height)
private void prepare_input(Image img)
{
Bitmap bmp = Utils.ResizeImage(img, _model.Width, _model.Height);

}

private void get_input_details()
Expand All @@ -306,4 +300,4 @@ public void Dispose()
_inferenceSession.Dispose();
}
}
}
}

0 comments on commit aaf4873

Please sign in to comment.