mirror of https://github.com/emgucv/emgucv.git

18 changed files with 253 additions and 88 deletions
-
4Emgu.CV.Example/MAUI/MauiDemoApp/MauiDemoApp.csproj
-
3Emgu.CV.Example/MAUI/MauiDemoApp/Properties/launchSettings.json
-
3Emgu.CV.NativeImage/WriteableBitmapExtension.cs
-
2Emgu.CV.Platform/Emgu.CV.Wpf/Emgu.CV.Wpf.csproj
-
80Emgu.CV.Platform/Maui/UI/ButtonTextImagePage.cs
-
8Emgu.CV.Platform/Maui/UI/CvImageView.cs
-
47Emgu.CV.Platform/Maui/UI/Emgu.CV.Platform.Maui.UI.csproj
-
7Emgu.CV.Platform/Maui/UI/Platforms/Android/PlatformClass1.cs
-
7Emgu.CV.Platform/Maui/UI/Platforms/MacCatalyst/PlatformClass1.cs
-
9Emgu.CV.Platform/Maui/UI/Platforms/Tizen/PlatformClass1.cs
-
92Emgu.CV.Platform/Maui/UI/Platforms/Windows/WritableBitmapExtension.cs
-
7Emgu.CV.Platform/Maui/UI/Platforms/iOS/PlatformClass1.cs
-
0Emgu.CV.Platform/Maui/UI/ProcessAndRenderPage.cs
-
0Emgu.CV.Platform/Maui/UI/apple/AvCaptureSessionPage.cs
-
0Emgu.CV.Platform/Maui/UI/apple/CMSampleBufferExtensions.cs
-
0Emgu.CV.Platform/Maui/UI/apple/OutputRecorder.cs
-
14Solution/Android/Emgu.CV.Android.Example.sln
-
58Solution/CrossPlatform/Emgu.CV.CrossPlatform.sln
@ -0,0 +1,47 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFrameworks>net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks> |
|||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.20348.0</TargetFrameworks> |
|||
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET --> |
|||
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> --> |
|||
<UseMaui>true</UseMaui> |
|||
<SingleProject>true</SingleProject> |
|||
<ImplicitUsings>enable</ImplicitUsings> |
|||
|
|||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion> |
|||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion> |
|||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">21.0</SupportedOSPlatformVersion> |
|||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion> |
|||
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion> |
|||
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion> |
|||
</PropertyGroup> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.20348.0</TargetFrameworks> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' Or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'" Include="..\..\..\Emgu.CV.Platform\NetStandard_iOS\Emgu.CV.Platform.NetStandard.IOS.csproj" /> |
|||
<ProjectReference Condition="!($([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' Or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst')" Include="..\..\..\Emgu.CV.Platform\NetStandard\Emgu.CV.Platform.NetStandard.csproj" /> |
|||
|
|||
<ProjectReference Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' Or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'" Include="..\..\..\Emgu.CV.Models\Emgu.CV.Models.IOS\Emgu.CV.Models.IOS.csproj" /> |
|||
<ProjectReference Condition="!($([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' Or $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst')" Include="..\..\..\Emgu.CV.Models\Emgu.CV.Models.NetStandard\Emgu.CV.Models.NetStandard.csproj" /> |
|||
|
|||
<ProjectReference Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'" Include="..\..\..\Emgu.CV.Platform\Emgu.CV.Bitmap\Emgu.CV.Bitmap.csproj" /> |
|||
<ProjectReference Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'" Include="..\..\..\Emgu.CV.Platform\Emgu.CV.Wpf\Emgu.CV.Wpf.csproj" /> |
|||
<ProjectReference Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'" Include="..\..\..\Emgu.CV.Platform\Maui\Android\Emgu.CV.Platform.Maui.Android.csproj" /> |
|||
<ProjectReference Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'" Include="..\..\..\Emgu.CV.Platform\Maui\iOS\Emgu.CV.Platform.Maui.iOS.csproj" /> |
|||
<ProjectReference Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'" Include="..\..\..\Emgu.CV.Platform\Maui\Mac\Emgu.CV.Platform.Maui.Mac.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<!-- <PackageReference Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'" Include="Microsoft.UI.Xaml" Version="2.7.1" /> --> |
|||
<!-- <PackageReference Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'" Include="Microsoft.WindowsAppSDK" Version="1.1.3" /> --> |
|||
|
|||
<PackageReference Include="System.Drawing.Primitives" Version="4.3.0" /> |
|||
<PackageReference Include="System.Runtime.InteropServices" Version="4.3.0" /> |
|||
<PackageReference Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'" Include="System.Runtime.InteropServices.WindowsRuntime" Version="4.3.0" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
@ -0,0 +1,7 @@ |
|||
namespace Emgu.CV.Platform.Maui.UI |
|||
{ |
|||
// All the code in this file is only included on Android.
|
|||
public class PlatformClass1 |
|||
{ |
|||
} |
|||
} |
@ -0,0 +1,7 @@ |
|||
namespace Emgu.CV.Platform.Maui.UI |
|||
{ |
|||
// All the code in this file is only included on Mac Catalyst.
|
|||
public class PlatformClass1 |
|||
{ |
|||
} |
|||
} |
@ -0,0 +1,9 @@ |
|||
using System; |
|||
|
|||
namespace Emgu.CV.Platform.Maui.UI |
|||
{ |
|||
// All the code in this file is only included on Tizen.
|
|||
public class PlatformClass1 |
|||
{ |
|||
} |
|||
} |
@ -0,0 +1,92 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Runtime.InteropServices; |
|||
using System.Text; |
|||
using System.Threading.Tasks; |
|||
|
|||
using Emgu.CV; |
|||
using Emgu.CV.CvEnum; |
|||
|
|||
namespace Emgu.CV.Platform.Maui.UI |
|||
{ |
|||
|
|||
public static class WriteableBitmapExtension |
|||
{ |
|||
/* |
|||
public static void ToArray(this Microsoft.UI.Xaml.Media.Imaging.WriteableBitmap writeableBitmap, IOutputArray outputArray) |
|||
{ |
|||
byte[] data = new byte[writeableBitmap.PixelWidth * writeableBitmap.PixelHeight * 4]; |
|||
writeableBitmap.PixelBuffer.CopyTo(data); |
|||
|
|||
GCHandle dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned); |
|||
try |
|||
{ |
|||
using (Mat image = new Mat( |
|||
new System.Drawing.Size(writeableBitmap.PixelWidth, writeableBitmap.PixelHeight), |
|||
DepthType.Cv8U, |
|||
4, |
|||
dataHandle.AddrOfPinnedObject(), |
|||
writeableBitmap.PixelWidth * 4 |
|||
)) |
|||
{ |
|||
CvInvoke.CvtColor(image, outputArray, ColorConversion.Bgra2Bgr); |
|||
} |
|||
} |
|||
finally |
|||
{ |
|||
dataHandle.Free(); |
|||
} |
|||
}*/ |
|||
|
|||
|
|||
public static Microsoft.UI.Xaml.Media.Imaging.WriteableBitmap ToWritableBitmap(this IInputArray array) |
|||
{ |
|||
using (InputArray ia = array.GetInputArray()) |
|||
{ |
|||
System.Drawing.Size size = ia.GetSize(); |
|||
Microsoft.UI.Xaml.Media.Imaging.WriteableBitmap bmp = new Microsoft.UI.Xaml.Media.Imaging.WriteableBitmap(size.Width, size.Height); |
|||
byte[] buffer = new byte[bmp.PixelWidth * bmp.PixelHeight * 4]; |
|||
GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); |
|||
|
|||
using (Mat resultImage = new Mat( |
|||
new System.Drawing.Size(bmp.PixelWidth, bmp.PixelHeight), |
|||
DepthType.Cv8U, |
|||
4, |
|||
handle.AddrOfPinnedObject(), |
|||
bmp.PixelWidth * 4)) |
|||
{ |
|||
int channels = ia.GetChannels(); |
|||
switch (channels) |
|||
{ |
|||
case 1: |
|||
CvInvoke.CvtColor(array, resultImage, ColorConversion.Gray2Bgra); |
|||
break; |
|||
case 3: |
|||
CvInvoke.CvtColor(array, resultImage, ColorConversion.Bgr2Bgra); |
|||
break; |
|||
case 4: |
|||
using (Mat m = ia.GetMat()) |
|||
m.CopyTo(resultImage); |
|||
break; |
|||
default: |
|||
throw new NotImplementedException(String.Format( |
|||
"Conversion from {0} channel IInputArray to WritableBitmap is not supported", |
|||
channels)); |
|||
} |
|||
} |
|||
handle.Free(); |
|||
using (Stream resultStream = System.Runtime.InteropServices.WindowsRuntime.WindowsRuntimeBufferExtensions.AsStream(bmp.PixelBuffer)) |
|||
//using (Stream resultStream = bmp.PixelBuffer.AsStream())
|
|||
{ |
|||
resultStream.Write(buffer, 0, buffer.Length); |
|||
} |
|||
|
|||
return bmp; |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|||
|
|||
} |
@ -0,0 +1,7 @@ |
|||
namespace Emgu.CV.Platform.Maui.UI |
|||
{ |
|||
// All the code in this file is only included on iOS.
|
|||
public class PlatformClass1 |
|||
{ |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue