Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions mobile/examples/Maui/MauiVisionSample/MauiVisionSample.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31611.283
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiVisionSample", "MauiVisionSample\MauiVisionSample.csproj", "{B181D00F-FFC0-489C-A59B-27665CD58015}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B181D00F-FFC0-489C-A59B-27665CD58015}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B181D00F-FFC0-489C-A59B-27665CD58015}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B181D00F-FFC0-489C-A59B-27665CD58015}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
{B181D00F-FFC0-489C-A59B-27665CD58015}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B181D00F-FFC0-489C-A59B-27665CD58015}.Release|Any CPU.Build.0 = Release|Any CPU
{B181D00F-FFC0-489C-A59B-27665CD58015}.Release|Any CPU.Deploy.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {61F7FB11-1E47-470C-91E2-47F8143E1572}
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions mobile/examples/Maui/MauiVisionSample/MauiVisionSample/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MauiVisionSample"
x:Class="MauiVisionSample.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
11 changes: 11 additions & 0 deletions mobile/examples/Maui/MauiVisionSample/MauiVisionSample/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace MauiVisionSample;

public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new AppShell();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="MauiVisionSample.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MauiVisionSample"
Shell.FlyoutBehavior="Disabled">

<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

</Shell>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace MauiVisionSample;

public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace MauiVisionSample
{
public enum ExecutionProviders
{
CPU, // CPU execution provider is always available by default
NNAPI, // NNAPI is available on Android
CoreML // CoreML is available on iOS/macOS
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using System.Threading.Tasks;

namespace MauiVisionSample
{
public interface IVisionSample
{
string Name { get; }
string ModelName { get; }
Task InitializeAsync();
Task UpdateExecutionProviderAsync(ExecutionProviders executionProvider);
Task<ImageProcessingResult> ProcessImageAsync(byte[] image);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiVisionSample.MainPage">

<Grid RowSpacing="0" ColumnSpacing="0">

<Grid.RowDefinitions>
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="*" />
<RowDefinition Height="50" />
<RowDefinition Height="50" />
<RowDefinition Height="50" />
</Grid.RowDefinitions>

<Picker
x:Name="Models"
HorizontalTextAlignment="Center"
Grid.Row="0"
Margin="5,5,5,5" />

<Picker
x:Name="ExecutionProviderOptions"
HorizontalTextAlignment="Center"
Grid.Row="1"
Margin="5,0,5,5" />

<Grid Grid.Row="2" Margin="20" VerticalOptions="FillAndExpand" HorizontalOptions="FillAndExpand">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>

<Image
x:Name="OutputImage"
Grid.Row="0"
Aspect="AspectFit"
HorizontalOptions="FillAndExpand"
VerticalOptions="FillAndExpand" />

<Label x:Name="Caption"
Grid.Row="1"
Margin="0,20,0,0"
VerticalTextAlignment="Start"
HorizontalOptions="StartAndExpand"
VerticalOptions="StartAndExpand" />
</Grid>

<Button
x:Name="SamplePhotoButton"
Grid.Row="3"
Text="Sample"
Clicked="AcquireButton_Clicked" />

<Button
x:Name="PickPhotoButton"
Grid.Row="4"
Text="Pick"
Clicked="AcquireButton_Clicked" />

<Button
x:Name="TakePhotoButton"
Grid.Row="5"
Text="Capture"
Clicked="AcquireButton_Clicked" />

<ActivityIndicator
x:Name="BusyIndicator"
Grid.RowSpan="6"
HorizontalOptions="CenterAndExpand"
VerticalOptions="CenterAndExpand"
Color="Black" />
</Grid>


</ContentPage>
Loading