Skip to content

Commit

Permalink
Updated Emgu TF MAUI demo to use Emgu CV MAUI 4.8 mini runtime.
Browse files Browse the repository at this point in the history
  • Loading branch information
emgucv committed Sep 12, 2023
1 parent 3605569 commit d988574
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 15 deletions.
8 changes: 4 additions & 4 deletions Emgu.TF.Example/CVInterop/CVInterop.NetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<TargetFramework>net7.0-windows</TargetFramework>
<UseWindowsForms>true</UseWindowsForms>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
Expand All @@ -14,9 +14,9 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Emgu.CV" Version="4.7.0.5276" />
<PackageReference Include="Emgu.CV.runtime.windows" Version="4.7.0.5276" />
<PackageReference Include="Emgu.CV.UI" Version="4.7.0.5276" />
<PackageReference Include="Emgu.CV" Version="4.8.0.5324" />
<PackageReference Include="Emgu.CV.runtime.windows" Version="4.8.0.5324" />
<PackageReference Include="Emgu.CV.UI" Version="4.8.0.5324" />
<PackageReference Include="Google.Protobuf" Version="3.21.9" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AssemblyName>Inception.Console.NetCore</AssemblyName>
<Platforms>AnyCPU;x64</Platforms>
Expand Down
6 changes: 6 additions & 0 deletions Emgu.TF.Example/Maui/InceptionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Size = System.Drawing.Size;
using Emgu.CV.CvEnum;
using System.Runtime.InteropServices;
using Emgu.CV.Models;

namespace Emgu.TF.Maui.Demo
{
Expand Down Expand Up @@ -59,6 +60,11 @@ public bool Initialized
}
}

public RenderType RenderMethod
{
get { return Emgu.CV.Models.RenderType.Update; }
}

public InceptionModel(Model model)
{
_model = model;
Expand Down
5 changes: 3 additions & 2 deletions Emgu.TF.Example/Maui/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ namespace Emgu.TF.Maui.Demo
{
public partial class MainPage : ContentPage
{
int count = 0;
//int count = 0;

public MainPage()
{
Expand Down Expand Up @@ -91,7 +91,8 @@ public MainPage()
buttonList.Add(stylizeButton);
}

if (Device.RuntimePlatform != Device.Android)
//if (Device.RuntimePlatform != Device.Android)
if (Microsoft.Maui.Devices.DeviceInfo.Platform != DevicePlatform.Android)
{
//LoadSavedModel is not available for Android
Button resnetButton = new Button();
Expand Down
2 changes: 1 addition & 1 deletion Emgu.TF.Example/Maui/Maui.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Emgu.CV.runtime.maui.mini" Version="4.7.0.5276" />
<PackageReference Include="Emgu.CV.runtime.maui.mini" Version="4.8.0.5324" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="7.0.0" />
</ItemGroup>

Expand Down
7 changes: 6 additions & 1 deletion Emgu.TF.Example/Maui/MultiboxDetectionModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Runtime.InteropServices;
using Emgu.CV.Structure;
using static Emgu.CV.DISOpticalFlow;
using Emgu.CV.Models;

namespace Emgu.TF.Maui.Demo
{
Expand All @@ -48,6 +49,10 @@ public MultiboxDetectionModel()
{
}

public RenderType RenderMethod
{
get { return Emgu.CV.Models.RenderType.Update; }
}

public void Clear()
{
Expand Down Expand Up @@ -143,7 +148,7 @@ public string ProcessAndRender(IInputArray imageIn, IInputOutputArray imageOut)
using (InputArray iaImage = imageIn.GetInputArray())
{
var imgSize = iaImage.GetSize();
iaImage.CopyTo(imageOut);
//iaImage.CopyTo(imageOut);

foreach (Emgu.Models.Annotation annotation in annotations)
{
Expand Down
8 changes: 5 additions & 3 deletions Emgu.TF.Example/Maui/ResnetModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Size = System.Drawing.Size;
using Emgu.CV.CvEnum;
using System.Runtime.InteropServices;
using Emgu.CV.Models;

namespace Emgu.TF.Maui.Demo
{
Expand All @@ -46,6 +47,10 @@ public ResnetModel()
{
}

public RenderType RenderMethod
{
get { return Emgu.CV.Models.RenderType.Update; }
}

public void Clear()
{
Expand Down Expand Up @@ -130,15 +135,12 @@ public string ProcessAndRender(IInputArray imageIn, IInputOutputArray imageOut)
resizedMat.ConvertTo(tensorMat, DepthType.Cv32F, 1.0f / 255.0f, 0.0);
}


//Here we are trying to time the execution of the graph after it is loaded
//If we are not interest in the performance, we can skip the following 3 lines
Stopwatch sw = Stopwatch.StartNew();
Resnet.RecognitionResult[] result = _resnet.Recognize(_inputTensor)[0];
sw.Stop();



String msg = String.Format(
"Object is {0} with {1}% probability. Recognized in {2} milliseconds.",
result[0].Label, result[0].Probability * 100, sw.ElapsedMilliseconds);
Expand Down
6 changes: 5 additions & 1 deletion Emgu.TF.Example/Maui/StylizeModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Size = System.Drawing.Size;
using Emgu.CV.CvEnum;
using System.Runtime.InteropServices;
using Emgu.CV.Models;

namespace Emgu.TF.Maui.Demo
{
Expand Down Expand Up @@ -47,7 +48,10 @@ public StylizeModel()
{
}


public RenderType RenderMethod
{
get { return Emgu.CV.Models.RenderType.Overwrite; }
}
public void Clear()
{
if (_stylizeGraph != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Xamarin.Essentials" Version="1.7.5" />
<PackageReference Include="Xamarin.Forms.Platform.WPF" Version="5.0.0.2578" />
<PackageReference Include="Xamarin.Essentials" Version="1.8.0" />
<PackageReference Include="Xamarin.Forms.Platform.WPF" Version="5.0.0.2612" />
<PackageReference Include="WpfLightToolkit">
<Version>1.0.3</Version>
</PackageReference>
Expand Down

0 comments on commit d988574

Please sign in to comment.