Resolve repo collisions
@ -1 +0,0 @@
|
||||
Subproject commit ab141dac9c1a811b032598de458b54d518fa0e71
|
63
Camera-Renderer_cs/.gitattributes
vendored
Normal file
@ -0,0 +1,63 @@
|
||||
###############################################################################
|
||||
# Set default behavior to automatically normalize line endings.
|
||||
###############################################################################
|
||||
* text=auto
|
||||
|
||||
###############################################################################
|
||||
# Set default behavior for command prompt diff.
|
||||
#
|
||||
# This is need for earlier builds of msysgit that does not have it on by
|
||||
# default for csharp files.
|
||||
# Note: This is only used by command line
|
||||
###############################################################################
|
||||
#*.cs diff=csharp
|
||||
|
||||
###############################################################################
|
||||
# Set the merge driver for project and solution files
|
||||
#
|
||||
# Merging from the command prompt will add diff markers to the files if there
|
||||
# are conflicts (Merging from VS is not affected by the settings below, in VS
|
||||
# the diff markers are never inserted). Diff markers may cause the following
|
||||
# file extensions to fail to load in VS. An alternative would be to treat
|
||||
# these files as binary and thus will always conflict and require user
|
||||
# intervention with every merge. To do so, just uncomment the entries below
|
||||
###############################################################################
|
||||
#*.sln merge=binary
|
||||
#*.csproj merge=binary
|
||||
#*.vbproj merge=binary
|
||||
#*.vcxproj merge=binary
|
||||
#*.vcproj merge=binary
|
||||
#*.dbproj merge=binary
|
||||
#*.fsproj merge=binary
|
||||
#*.lsproj merge=binary
|
||||
#*.wixproj merge=binary
|
||||
#*.modelproj merge=binary
|
||||
#*.sqlproj merge=binary
|
||||
#*.wwaproj merge=binary
|
||||
|
||||
###############################################################################
|
||||
# behavior for image files
|
||||
#
|
||||
# image files are treated as binary by default.
|
||||
###############################################################################
|
||||
#*.jpg binary
|
||||
#*.png binary
|
||||
#*.gif binary
|
||||
|
||||
###############################################################################
|
||||
# diff behavior for common document formats
|
||||
#
|
||||
# Convert binary document formats to text before diffing them. This feature
|
||||
# is only available from the command line. Turn it on by uncommenting the
|
||||
# entries below.
|
||||
###############################################################################
|
||||
#*.doc diff=astextplain
|
||||
#*.DOC diff=astextplain
|
||||
#*.docx diff=astextplain
|
||||
#*.DOCX diff=astextplain
|
||||
#*.dot diff=astextplain
|
||||
#*.DOT diff=astextplain
|
||||
#*.pdf diff=astextplain
|
||||
#*.PDF diff=astextplain
|
||||
#*.rtf diff=astextplain
|
||||
#*.RTF diff=astextplain
|
365
Camera-Renderer_cs/.gitignore
vendored
Normal file
@ -0,0 +1,365 @@
|
||||
# ---> VisualStudio
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
##
|
||||
## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
|
||||
|
||||
# User-specific files
|
||||
*.rsuser
|
||||
*.suo
|
||||
*.user
|
||||
*.userosscache
|
||||
*.sln.docstates
|
||||
|
||||
# User-specific files (MonoDevelop/Xamarin Studio)
|
||||
*.userprefs
|
||||
|
||||
# Mono auto generated files
|
||||
mono_crash.*
|
||||
|
||||
# Build results
|
||||
[Dd]ebug/
|
||||
[Dd]ebugPublic/
|
||||
[Rr]elease/
|
||||
[Rr]eleases/
|
||||
x64/
|
||||
x86/
|
||||
[Ww][Ii][Nn]32/
|
||||
[Aa][Rr][Mm]/
|
||||
[Aa][Rr][Mm]64/
|
||||
bld/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Oo]ut/
|
||||
[Ll]og/
|
||||
[Ll]ogs/
|
||||
|
||||
# Visual Studio 2015/2017 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# Visual Studio 2017 auto generated files
|
||||
Generated\ Files/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
[Bb]uild[Ll]og.*
|
||||
|
||||
# NUnit
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
nunit-*.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# Benchmark Results
|
||||
BenchmarkDotNet.Artifacts/
|
||||
|
||||
# .NET Core
|
||||
project.lock.json
|
||||
project.fragment.lock.json
|
||||
artifacts/
|
||||
|
||||
# ASP.NET Scaffolding
|
||||
ScaffoldingReadMe.txt
|
||||
|
||||
# StyleCop
|
||||
StyleCopReport.xml
|
||||
|
||||
# Files built by Visual Studio
|
||||
*_i.c
|
||||
*_p.c
|
||||
*_h.h
|
||||
*.ilk
|
||||
*.meta
|
||||
*.obj
|
||||
*.iobj
|
||||
*.pch
|
||||
*.pdb
|
||||
*.ipdb
|
||||
*.pgc
|
||||
*.pgd
|
||||
*.rsp
|
||||
*.sbr
|
||||
*.tlb
|
||||
*.tli
|
||||
*.tlh
|
||||
*.tmp
|
||||
*.tmp_proj
|
||||
*_wpftmp.csproj
|
||||
*.log
|
||||
*.vspscc
|
||||
*.vssscc
|
||||
.builds
|
||||
*.pidb
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
*.VC.db
|
||||
*.VC.VC.opendb
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# Visual Studio Trace Files
|
||||
*.e2e
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
# ReSharper is a .NET coding add-in
|
||||
_ReSharper*/
|
||||
*.[Rr]e[Ss]harper
|
||||
*.DotSettings.user
|
||||
|
||||
# TeamCity is a build add-in
|
||||
_TeamCity*
|
||||
|
||||
# DotCover is a Code Coverage Tool
|
||||
*.dotCover
|
||||
|
||||
# AxoCover is a Code Coverage Tool
|
||||
.axoCover/*
|
||||
!.axoCover/settings.json
|
||||
|
||||
# Coverlet is a free, cross platform Code Coverage Tool
|
||||
coverage*.json
|
||||
coverage*.xml
|
||||
coverage*.info
|
||||
|
||||
# Visual Studio code coverage results
|
||||
*.coverage
|
||||
*.coveragexml
|
||||
|
||||
# NCrunch
|
||||
_NCrunch_*
|
||||
.*crunch*.local.xml
|
||||
nCrunchTemp_*
|
||||
|
||||
# MightyMoose
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# Note: Comment the next line if you want to checkin your web deploy settings,
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# Microsoft Azure Web App publish settings. Comment the next line if you want to
|
||||
# checkin your Azure Web App publish settings, but sensitive information contained
|
||||
# in these scripts will be unencrypted
|
||||
PublishScripts/
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# NuGet Symbol Packages
|
||||
*.snupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
**/[Pp]ackages/*
|
||||
# except build/, which is used as an MSBuild target.
|
||||
!**/[Pp]ackages/build/
|
||||
# Uncomment if necessary however generally it will be regenerated when needed
|
||||
#!**/[Pp]ackages/repositories.config
|
||||
# NuGet v3's project.json files produces more ignorable files
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Windows Store app package directories and files
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
Package.StoreAssociation.xml
|
||||
_pkginfo.txt
|
||||
*.appx
|
||||
*.appxbundle
|
||||
*.appxupload
|
||||
|
||||
# Visual Studio cache files
|
||||
# files ending in .cache can be ignored
|
||||
*.[Cc]ache
|
||||
# but keep track of directories ending in .cache
|
||||
!?*.[Cc]ache/
|
||||
|
||||
# Others
|
||||
ClientBin/
|
||||
~$*
|
||||
*~
|
||||
*.dbmdl
|
||||
*.dbproj.schemaview
|
||||
*.jfm
|
||||
*.pfx
|
||||
*.publishsettings
|
||||
orleans.codegen.cs
|
||||
|
||||
# Including strong name files can present a security risk
|
||||
# (https://github.com/github/gitignore/pull/2483#issue-259490424)
|
||||
#*.snk
|
||||
|
||||
# Since there are multiple workflows, uncomment next line to ignore bower_components
|
||||
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
|
||||
#bower_components/
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
_UpgradeReport_Files/
|
||||
Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
ServiceFabricBackup/
|
||||
*.rptproj.bak
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
*.ndf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
*.rptproj.rsuser
|
||||
*- [Bb]ackup.rdl
|
||||
*- [Bb]ackup ([0-9]).rdl
|
||||
*- [Bb]ackup ([0-9][0-9]).rdl
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
node_modules/
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
|
||||
*.vbw
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
paket-files/
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
# CodeRush personal settings
|
||||
.cr/personal
|
||||
|
||||
# Python Tools for Visual Studio (PTVS)
|
||||
__pycache__/
|
||||
*.pyc
|
||||
|
||||
# Cake - Uncomment if you are using it
|
||||
# tools/**
|
||||
# !tools/packages.config
|
||||
|
||||
# Tabs Studio
|
||||
*.tss
|
||||
|
||||
# Telerik's JustMock configuration file
|
||||
*.jmconfig
|
||||
|
||||
# BizTalk build output
|
||||
*.btp.cs
|
||||
*.btm.cs
|
||||
*.odx.cs
|
||||
*.xsd.cs
|
||||
|
||||
# OpenCover UI analysis results
|
||||
OpenCover/
|
||||
|
||||
# Azure Stream Analytics local run output
|
||||
ASALocalRun/
|
||||
|
||||
# MSBuild Binary and Structured Log
|
||||
*.binlog
|
||||
|
||||
# NVidia Nsight GPU debugger configuration file
|
||||
*.nvuser
|
||||
|
||||
# MFractors (Xamarin productivity tool) working folder
|
||||
.mfractor/
|
||||
|
||||
# Local History for Visual Studio
|
||||
.localhistory/
|
||||
|
||||
# BeatPulse healthcheck temp database
|
||||
healthchecksdb
|
||||
|
||||
# Backup folder for Package Reference Convert tool in Visual Studio 2017
|
||||
MigrationBackup/
|
||||
|
||||
# Ionide (cross platform F# VS Code tools) working folder
|
||||
.ionide/
|
||||
|
||||
# Fody - auto-generated XML schema
|
||||
FodyWeavers.xsd
|
||||
|
7
Camera-Renderer_cs/App.xaml
Normal file
@ -0,0 +1,7 @@
|
||||
<Application
|
||||
x:Class="CameraRendererCS.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:CameraRendererCS">
|
||||
|
||||
</Application>
|
100
Camera-Renderer_cs/App.xaml.cs
Normal file
@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.ApplicationModel;
|
||||
using Windows.ApplicationModel.Activation;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
|
||||
namespace CameraRendererCS
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides application-specific behavior to supplement the default Application class.
|
||||
/// </summary>
|
||||
sealed partial class App : Application
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes the singleton application object. This is the first line of authored code
|
||||
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||
/// </summary>
|
||||
public App()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
this.Suspending += OnSuspending;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when the application is launched normally by the end user. Other entry points
|
||||
/// will be used such as when the application is launched to open a specific file.
|
||||
/// </summary>
|
||||
/// <param name="e">Details about the launch request and process.</param>
|
||||
protected override void OnLaunched(LaunchActivatedEventArgs e)
|
||||
{
|
||||
Frame rootFrame = Window.Current.Content as Frame;
|
||||
|
||||
// Do not repeat app initialization when the Window already has content,
|
||||
// just ensure that the window is active
|
||||
if (rootFrame == null)
|
||||
{
|
||||
// Create a Frame to act as the navigation context and navigate to the first page
|
||||
rootFrame = new Frame();
|
||||
|
||||
rootFrame.NavigationFailed += OnNavigationFailed;
|
||||
|
||||
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
|
||||
{
|
||||
//TODO: Load state from previously suspended application
|
||||
}
|
||||
|
||||
// Place the frame in the current Window
|
||||
Window.Current.Content = rootFrame;
|
||||
}
|
||||
|
||||
if (e.PrelaunchActivated == false)
|
||||
{
|
||||
if (rootFrame.Content == null)
|
||||
{
|
||||
// When the navigation stack isn't restored navigate to the first page,
|
||||
// configuring the new page by passing required information as a navigation
|
||||
// parameter
|
||||
rootFrame.Navigate(typeof(MainPage), e.Arguments);
|
||||
}
|
||||
// Ensure the current window is active
|
||||
Window.Current.Activate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when Navigation to a certain page fails
|
||||
/// </summary>
|
||||
/// <param name="sender">The Frame which failed navigation</param>
|
||||
/// <param name="e">Details about the navigation failure</param>
|
||||
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||
{
|
||||
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when application execution is being suspended. Application state is saved
|
||||
/// without knowing whether the application will be terminated or resumed with the contents
|
||||
/// of memory still intact.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the suspend request.</param>
|
||||
/// <param name="e">Details about the suspend request.</param>
|
||||
private void OnSuspending(object sender, SuspendingEventArgs e)
|
||||
{
|
||||
var deferral = e.SuspendingOperation.GetDeferral();
|
||||
//TODO: Save application state and stop any background activity
|
||||
deferral.Complete();
|
||||
}
|
||||
}
|
||||
}
|
174
Camera-Renderer_cs/Camera Renderer CS.csproj
Normal file
@ -0,0 +1,174 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProjectGuid>{33A294C7-3146-405C-BCCA-C4E36985D0D7}</ProjectGuid>
|
||||
<OutputType>AppContainerExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>CameraDirect</RootNamespace>
|
||||
<AssemblyName>CameraDirect</AssemblyName>
|
||||
<DefaultLanguage>en-US</DefaultLanguage>
|
||||
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.19041.0</TargetPlatformVersion>
|
||||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
|
||||
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
|
||||
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
|
||||
<GenerateAppInstallerFile>False</GenerateAppInstallerFile>
|
||||
<AppxAutoIncrementPackageRevision>True</AppxAutoIncrementPackageRevision>
|
||||
<GenerateTestArtifacts>True</GenerateTestArtifacts>
|
||||
<AppxBundle>Always</AppxBundle>
|
||||
<AppxBundlePlatforms>x86|x64|arm</AppxBundlePlatforms>
|
||||
<HoursBetweenUpdateChecks>0</HoursBetweenUpdateChecks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\ARM64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>ARM64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
|
||||
<OutputPath>bin\ARM64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>ARM64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<NoWarn>;2008</NoWarn>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="App.xaml.cs">
|
||||
<DependentUpon>App.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainPage.xaml.cs">
|
||||
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<AppxManifest Include="Package.appxmanifest">
|
||||
<SubType>Designer</SubType>
|
||||
</AppxManifest>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Properties\Default.rd.xml" />
|
||||
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.scale-200.png" />
|
||||
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||
<Content Include="Assets\StoreLogo.png" />
|
||||
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Page Include="MainPage.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||
<Version>6.2.12</Version>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
</Target>
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
66
Camera-Renderer_cs/MainPage.xaml
Normal file
@ -0,0 +1,66 @@
|
||||
<Page
|
||||
x:Class="CameraRendererCS.MainPage"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="using:CameraRendererCS"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d"
|
||||
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" PointerMoved="Page_PointerMoved">
|
||||
|
||||
<Grid>
|
||||
<Image x:Name="renderTarget" />
|
||||
<Grid x:Name="FlyoutGrid" HorizontalAlignment="Center" VerticalAlignment="Top" PointerEntered="FlyoutGrid_PointerEntered" PointerExited="FlyoutGrid_PointerExited">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.Background>
|
||||
<AcrylicBrush TintColor="#CC000000" TintOpacity="0.75"/>
|
||||
</Grid.Background>
|
||||
<StackPanel x:Name="SourceFlyout" HorizontalAlignment="Center" VerticalAlignment="Top" Padding="20,30,20,20" Margin="0,18,0,0" Grid.RowSpan="1">
|
||||
<TextBlock Text="Input Audio:" TextWrapping="Wrap" Margin="0,10,0,0" Foreground="White"/>
|
||||
<ComboBox x:Name="audioComboBox" Width="120" MinWidth="300"/>
|
||||
<TextBlock Text="Input Capture Device:" TextWrapping="Wrap" Margin="0,10,0,0" Foreground="White"/>
|
||||
<ComboBox x:Name="videoComboBox" Width="120" MinWidth="300" SelectionChanged="videoComboBox_SelectionChanged"/>
|
||||
<TextBlock x:Name="videoStreamLabel" Text="Input Video Stream:" TextWrapping="Wrap" Foreground="White" Padding="20,10,0,0" Visibility="Collapsed"/>
|
||||
<ComboBox x:Name="videoStreamComboBox" MinWidth="280" Padding="39,5,0,7" Margin="20,0,0,0" Visibility="Collapsed"/>
|
||||
<TextBlock Text="Input Stream Format:" TextWrapping="Wrap" Foreground="White" Margin="0,10,0,0"/>
|
||||
<ComboBox x:Name="videoTypeComboBox" Width="120" MinWidth="300" />
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Margin="0,20,0,5">
|
||||
<Button x:Name="startStreamButton" Content="Start Stream" HorizontalContentAlignment="Center" Background="#54FFFFFF" Click="startStreamButton_Click"/>
|
||||
<Button x:Name="stopStream" Content="Stop Stream" HorizontalContentAlignment="Center" Background="#54FFFFFF" Click="startStreamButton_Click" Margin="10,0,0,0"/>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Button x:Name="CollapseButton" Content="" VerticalAlignment="Bottom" HorizontalAlignment="Right" Padding="5,5,5,2" Grid.RowSpan="1" Grid.Row="1" FontFamily="Segoe MDL2 Assets" Click="CollapseButton_Click" FontSize="22"/>
|
||||
<ToggleButton x:Name="PerfStatsView" Content="" Padding="5,5,5,2" Grid.Row="1" FontFamily="Segoe MDL2 Assets" FontSize="22" IsChecked="True" Unchecked="PerfStatsView_Unchecked" Checked="PerfStatsView_Checked"/>
|
||||
</Grid>
|
||||
<Grid x:Name="StatisticsPane" HorizontalAlignment="Left" VerticalAlignment="Top" MinWidth="100" Padding="5,5,5,5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.Background>
|
||||
<AcrylicBrush TintColor="#CC000000" TintOpacity="0.01"/>
|
||||
</Grid.Background>
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Stretch" Grid.ColumnSpan="1" Margin="0,0,2,0">
|
||||
<TextBlock Text="Frame Time:" TextWrapping="Wrap"/>
|
||||
<TextBlock x:Name="timelabel" Text="0.0" TextWrapping="Wrap" HorizontalAlignment="Right"/>
|
||||
<TextBlock x:Name="timelabel_delta" Text="" TextWrapping="Wrap" HorizontalAlignment="Right"/>
|
||||
<TextBlock Text="Max:" TextWrapping="Wrap"/>
|
||||
<TextBlock x:Name="maxTimeLabel" Text="" TextWrapping="Wrap" HorizontalAlignment="Right"/>
|
||||
<TextBlock Text="Processing Time:" TextWrapping="Wrap"/>
|
||||
<TextBlock x:Name="frameProcessingTimeLabel" Text="" TextWrapping="Wrap" HorizontalAlignment="Right"/>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Vertical" VerticalAlignment="Stretch" Grid.ColumnSpan="1" Margin="0,0,2,0" Grid.Column="1">
|
||||
<TextBlock Text="" TextWrapping="Wrap" HorizontalAlignment="Left"/>
|
||||
<TextBlock Text="ms (-- fps)" TextWrapping="Wrap" HorizontalAlignment="Left"/>
|
||||
<TextBlock Text="ms (delta)" TextWrapping="Wrap"/>
|
||||
<TextBlock Text="" TextWrapping="Wrap"/>
|
||||
<TextBlock Text="ms" TextWrapping="Wrap"/>
|
||||
<TextBlock Text="" TextWrapping="Wrap"/>
|
||||
<TextBlock Text="ms" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Page>
|
554
Camera-Renderer_cs/MainPage.xaml.cs
Normal file
@ -0,0 +1,554 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices.WindowsRuntime;
|
||||
using Windows.Foundation;
|
||||
using Windows.Foundation.Collections;
|
||||
using Windows.UI.Xaml;
|
||||
using Windows.UI.Xaml.Controls;
|
||||
using Windows.UI.Xaml.Controls.Primitives;
|
||||
using Windows.UI.Xaml.Data;
|
||||
using Windows.UI.Xaml.Input;
|
||||
using Windows.UI.Xaml.Media;
|
||||
using Windows.UI.Xaml.Navigation;
|
||||
using Windows.UI.Core;
|
||||
using Windows.Media.Capture;
|
||||
using Windows.ApplicationModel;
|
||||
using System.Threading.Tasks;
|
||||
using Windows.System.Display;
|
||||
using Windows.Graphics.Display;
|
||||
using Windows.Media.Capture.Frames;
|
||||
using Windows.Media.Devices;
|
||||
using Windows.Devices.Enumeration;
|
||||
using Windows.Media.Audio;
|
||||
using Windows.Media.Render;
|
||||
using Windows.Media.MediaProperties;
|
||||
using Windows.Graphics.Imaging;
|
||||
using System.Threading;
|
||||
using Windows.UI.Xaml.Media.Imaging;
|
||||
using System.Diagnostics;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
|
||||
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
||||
|
||||
namespace CameraRendererCS
|
||||
{
|
||||
/// <summary>
|
||||
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||
/// </summary>
|
||||
public sealed partial class MainPage : Page
|
||||
{
|
||||
|
||||
MediaCapture mediaCapture;
|
||||
MediaFrameReader frameReader;
|
||||
bool isStreamRunning = false;
|
||||
bool calcPerfStats = true;
|
||||
DisplayRequest displayRequest = new DisplayRequest();
|
||||
bool _taskRunning = false;
|
||||
private SoftwareBitmap _backBuffer = new SoftwareBitmap(BitmapPixelFormat.Rgba8, 1, 1);
|
||||
|
||||
AudioGraph graph;
|
||||
|
||||
// Populated lists
|
||||
DeviceInformationCollection audioDevices;
|
||||
IReadOnlyList<MediaFrameSourceGroup> videoDevices;
|
||||
|
||||
public MainPage()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
visualDecayTimer = new Timer((t) =>
|
||||
{
|
||||
fadeWindow();
|
||||
});
|
||||
}
|
||||
|
||||
protected override async void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
// Grab the list of video media sources and show them to the user
|
||||
await FindVideoSources();
|
||||
await FindAudioSources();
|
||||
// Grab the audio sources too
|
||||
}
|
||||
|
||||
private async Task FindVideoSources()
|
||||
{
|
||||
videoComboBox.Items.Clear();
|
||||
videoDevices = await MediaFrameSourceGroup.FindAllAsync();
|
||||
videoComboBox.Items.Add("-- Pick input device --");
|
||||
foreach (MediaFrameSourceGroup device in videoDevices)
|
||||
{
|
||||
videoComboBox.Items.Add(device.DisplayName);
|
||||
}
|
||||
if (videoComboBox.SelectedIndex == -1 && videoComboBox.Items.Count > 0) videoComboBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
private async Task FindAudioSources()
|
||||
{
|
||||
audioComboBox.Items.Clear();
|
||||
audioDevices = await DeviceInformation.FindAllAsync(MediaDevice.GetAudioCaptureSelector());
|
||||
audioComboBox.Items.Add("-- Pick input device --");
|
||||
foreach (DeviceInformation device in audioDevices)
|
||||
{
|
||||
audioComboBox.Items.Add(device.Name);
|
||||
}
|
||||
if (audioComboBox.SelectedIndex == -1 && audioComboBox.Items.Count > 0) audioComboBox.SelectedIndex = 0;
|
||||
}
|
||||
private async void startStreamButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
|
||||
await CreateVideoReader();
|
||||
await CreateAudioGraph();
|
||||
displayRequest.RequestActive();
|
||||
}
|
||||
|
||||
private async Task CreateAudioGraph()
|
||||
{
|
||||
AudioGraphSettings settings = new AudioGraphSettings(AudioRenderCategory.Media)
|
||||
{
|
||||
//settings.QuantumSizeSelectionMode = QuantumSizeSelectionMode.LowestLatency;
|
||||
PrimaryRenderDevice = await DeviceInformation.CreateFromIdAsync(MediaDevice.GetDefaultAudioRenderId(AudioDeviceRole.Default))
|
||||
};
|
||||
|
||||
CreateAudioGraphResult result = await AudioGraph.CreateAsync(settings);
|
||||
graph = result.Graph;
|
||||
|
||||
if (result.Status != AudioGraphCreationStatus.Success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CreateAudioDeviceOutputNodeResult deviceOutputNodeResult = await graph.CreateDeviceOutputNodeAsync();
|
||||
if (deviceOutputNodeResult.Status != AudioDeviceNodeCreationStatus.Success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
CreateAudioDeviceInputNodeResult deviceInputNodeResult = await graph.CreateDeviceInputNodeAsync(MediaCategory.Other, graph.EncodingProperties, audioDevices[audioComboBox.SelectedIndex - 1]);
|
||||
|
||||
if (deviceInputNodeResult.Status != AudioDeviceNodeCreationStatus.Success)
|
||||
{
|
||||
return;
|
||||
}
|
||||
deviceInputNodeResult.DeviceInputNode.AddOutgoingConnection(deviceOutputNodeResult.DeviceOutputNode);
|
||||
graph.Start();
|
||||
}
|
||||
|
||||
private async Task CreateVideoReader()
|
||||
{
|
||||
MediaFrameFormat format = ((FrameFormatModel)videoTypeComboBox.SelectedItem).Format;
|
||||
MediaFrameSource source = (MediaFrameSource)videoStreamComboBox.SelectedItem;
|
||||
|
||||
|
||||
// Look for a format which the FrameRenderer can render.
|
||||
string requestedSubtype = null;
|
||||
requestedSubtype = GetSubtypeForFrameReader(source.Info.SourceKind, format);
|
||||
if (requestedSubtype != null)
|
||||
{
|
||||
// Tell the source to use the format we can render.
|
||||
await source.SetFormatAsync(format);
|
||||
}
|
||||
if (requestedSubtype == null)
|
||||
{
|
||||
}
|
||||
|
||||
Task t = new Task(async () =>
|
||||
{
|
||||
|
||||
try
|
||||
{
|
||||
frameReader = await mediaCapture.CreateFrameReaderAsync(source, requestedSubtype);
|
||||
frameReader.AcquisitionMode = MediaFrameReaderAcquisitionMode.Realtime;
|
||||
frameReader.FrameArrived += FrameReader_FrameArrived;
|
||||
lastFrameTime = Stopwatch.GetTimestamp();
|
||||
MediaFrameReaderStartStatus status = await frameReader.StartAsync();
|
||||
if (status == MediaFrameReaderStartStatus.Success)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
});
|
||||
try
|
||||
{
|
||||
t.Start();
|
||||
isStreamRunning = true;
|
||||
if (!mouseInside)
|
||||
{
|
||||
_ = visualDecayTimer.Change(15000, Timeout.Infinite);
|
||||
}
|
||||
|
||||
}
|
||||
catch (InvalidOperationException e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
Console.WriteLine("Media Source Info: {0}", source.Info.ToString());
|
||||
}
|
||||
}
|
||||
long lastFrameTime = 0;
|
||||
double averageFrameTime = -1.0;
|
||||
double lastFrameTimeMaximum = 0;
|
||||
// Time taken to process the frame, in delta-ticks
|
||||
long frameProcessingTime = 0;
|
||||
TaskFactory perfTaskFactory = new TaskFactory(TaskCreationOptions.None, TaskContinuationOptions.None);
|
||||
|
||||
// Use a concurrent queue to ensure synchronisation
|
||||
ConcurrentQueue<double> previousFrameTimes = new ConcurrentQueue<double>();
|
||||
|
||||
private void FrameReader_FrameArrived(MediaFrameReader sender, MediaFrameArrivedEventArgs args)
|
||||
{
|
||||
long newTime = Stopwatch.GetTimestamp();
|
||||
if (calcPerfStats)
|
||||
{
|
||||
// Build the new task, to help fire off frames quickly
|
||||
_ = perfTaskFactory.StartNew(() =>
|
||||
{
|
||||
// TODO: Push the calculation onto a different thread, as it isn't needed here. May save some time as this function takes ~6 ms to execute
|
||||
// Most of this time is likely spent converting the bitmap
|
||||
if (previousFrameTimes.Count >= 180)
|
||||
{
|
||||
_ = previousFrameTimes.TryDequeue(out _);
|
||||
}
|
||||
string deltaTime = "";
|
||||
if (averageFrameTime < 0)
|
||||
{
|
||||
averageFrameTime = (newTime - lastFrameTime) / (double)TimeSpan.TicksPerMillisecond;
|
||||
}
|
||||
else
|
||||
{
|
||||
double newVal = (newTime - lastFrameTime) / (double)TimeSpan.TicksPerMillisecond;
|
||||
|
||||
deltaTime = (averageFrameTime - newVal).ToString("N1");
|
||||
previousFrameTimes.Enqueue(newVal);
|
||||
double localMaxIn = previousFrameTimes.Max();
|
||||
_ = Interlocked.Exchange(ref lastFrameTimeMaximum, localMaxIn);
|
||||
double sampledAverage = previousFrameTimes.Sum() / previousFrameTimes.Count();
|
||||
/*double localAvg = averageFrameTime * 9;
|
||||
localAvg += newVal;
|
||||
localAvg /= 10;*/
|
||||
_ = Interlocked.Exchange(ref averageFrameTime, sampledAverage);
|
||||
}
|
||||
string time = averageFrameTime.ToString("N1");
|
||||
_ = Interlocked.Exchange(ref lastFrameTime, newTime);
|
||||
|
||||
var task = renderTarget.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
|
||||
{
|
||||
timelabel.Text = time;
|
||||
timelabel_delta.Text = deltaTime;
|
||||
maxTimeLabel.Text = lastFrameTimeMaximum.ToString("N2");
|
||||
// Delegate the double-precision division till this function
|
||||
frameProcessingTimeLabel.Text = (frameProcessingTime / (double)TimeSpan.TicksPerMillisecond).ToString("N2");
|
||||
});
|
||||
});
|
||||
}
|
||||
// TryAcquireLatestFrame will return the latest frame that has not yet been acquired.
|
||||
// This can return null if there is no such frame, or if the reader is not in the
|
||||
// "Started" state. The latter can occur if a FrameArrived event was in flight
|
||||
// when the reader was stopped.
|
||||
using (MediaFrameReference frame = sender.TryAcquireLatestFrame())
|
||||
{
|
||||
if (frame != null)
|
||||
{
|
||||
SoftwareBitmap result = null;
|
||||
using (SoftwareBitmap inputBitmap = frame.VideoMediaFrame.SoftwareBitmap)
|
||||
{
|
||||
if (inputBitmap != null)
|
||||
{
|
||||
// XAML requires Bgra8 with premultiplied alpha.
|
||||
// We requested Bgra8 from the MediaFrameReader, so all that's
|
||||
// left is fixing the alpha channel if necessary.
|
||||
if (inputBitmap.BitmapPixelFormat != BitmapPixelFormat.Bgra8)
|
||||
{
|
||||
//
|
||||
int i = 0;
|
||||
}
|
||||
else if (inputBitmap.BitmapAlphaMode == BitmapAlphaMode.Premultiplied)
|
||||
{
|
||||
// Already in the correct format.
|
||||
result = SoftwareBitmap.Copy(inputBitmap);
|
||||
//result = inputBitmap;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Convert to premultiplied alpha.
|
||||
result = SoftwareBitmap.Convert(inputBitmap, BitmapPixelFormat.Bgra8, BitmapAlphaMode.Ignore);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (result != null)
|
||||
{
|
||||
// Swap the processed frame to _backBuffer and trigger UI thread to render it
|
||||
result = Interlocked.Exchange(ref _backBuffer, result);
|
||||
|
||||
// UI thread always reset _backBuffer before using it. Unused bitmap should be disposed.
|
||||
result?.Dispose();
|
||||
// Changes to xaml ImageElement must happen in UI thread through Dispatcher
|
||||
var task = renderTarget.Dispatcher.RunAsync(CoreDispatcherPriority.High,
|
||||
async () =>
|
||||
{
|
||||
var imageSource = (SoftwareBitmapSource)renderTarget.Source;
|
||||
// Don't let two copies of this task run at the same time.
|
||||
if (_taskRunning)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_taskRunning = true;
|
||||
|
||||
// Keep draining frames from the backbuffer until the backbuffer is empty.
|
||||
SoftwareBitmap latestBitmap;
|
||||
// About to push a frame; get the delta at this point
|
||||
long thisFrameProcessTime = Stopwatch.GetTimestamp() - newTime;
|
||||
_ = Interlocked.Exchange(ref frameProcessingTime, thisFrameProcessTime);
|
||||
|
||||
while ((latestBitmap = Interlocked.Exchange(ref _backBuffer, null)) != null)
|
||||
{
|
||||
|
||||
await ((SoftwareBitmapSource)renderTarget.Source).SetBitmapAsync(latestBitmap);
|
||||
latestBitmap.Dispose();
|
||||
}
|
||||
|
||||
_taskRunning = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetSubtypeForFrameReader(MediaFrameSourceKind kind, MediaFrameFormat format)
|
||||
{
|
||||
// Note that media encoding subtypes may differ in case.
|
||||
// https://docs.microsoft.com/en-us/uwp/api/Windows.Media.MediaProperties.MediaEncodingSubtypes
|
||||
string subtype = format.Subtype;
|
||||
switch (kind)
|
||||
{
|
||||
// For color sources, we accept anything and request that it be converted to Bgra8.
|
||||
case MediaFrameSourceKind.Color:
|
||||
return MediaEncodingSubtypes.Bgra8;
|
||||
|
||||
// The only depth format we can render is D16.
|
||||
case MediaFrameSourceKind.Depth:
|
||||
return String.Equals(subtype, MediaEncodingSubtypes.D16, StringComparison.OrdinalIgnoreCase) ? subtype : null;
|
||||
|
||||
// The only infrared formats we can render are Nv12, L8, and L16.
|
||||
case MediaFrameSourceKind.Infrared:
|
||||
return (String.Equals(subtype, MediaEncodingSubtypes.Nv12, StringComparison.OrdinalIgnoreCase) ||
|
||||
String.Equals(subtype, MediaEncodingSubtypes.L8, StringComparison.OrdinalIgnoreCase) ||
|
||||
String.Equals(subtype, MediaEncodingSubtypes.L16, StringComparison.OrdinalIgnoreCase)) ? subtype : null;
|
||||
|
||||
// No other source kinds are supported by this class.
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
bool flyOutState = true;
|
||||
private void CollapseButton_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (flyOutState)
|
||||
{
|
||||
FlyoutGrid.RowDefinitions[0].Height = new GridLength(0);
|
||||
FlyoutGrid.Width = CollapseButton.Width;
|
||||
CollapseButton.Content = "";
|
||||
flyOutState = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
FlyoutGrid.RowDefinitions[0].Height = GridLength.Auto;
|
||||
CollapseButton.Content = "";
|
||||
|
||||
FlyoutGrid.Width = double.NaN;
|
||||
flyOutState = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Time taken to decay
|
||||
Timer visualDecayTimer;
|
||||
bool mouseInside = false;
|
||||
|
||||
private void Page_PointerMoved(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
if (isStreamRunning & !mouseInside)
|
||||
{
|
||||
var task = renderTarget.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
|
||||
{
|
||||
ScalarTransition fade = new ScalarTransition
|
||||
{
|
||||
Duration = TimeSpan.FromSeconds(0)
|
||||
};
|
||||
FlyoutGrid.OpacityTransition = fade;
|
||||
FlyoutGrid.Opacity = 1.0;
|
||||
});
|
||||
visualDecayTimer.Change(5000, Timeout.Infinite);
|
||||
}
|
||||
}
|
||||
|
||||
private void fadeWindow()
|
||||
{
|
||||
var task = renderTarget.Dispatcher.RunAsync(CoreDispatcherPriority.Low, () =>
|
||||
{
|
||||
ScalarTransition fade = new ScalarTransition
|
||||
{
|
||||
Duration = TimeSpan.FromSeconds(5)
|
||||
};
|
||||
FlyoutGrid.OpacityTransition = fade;
|
||||
FlyoutGrid.Opacity = 0.01;
|
||||
});
|
||||
}
|
||||
|
||||
private void FlyoutGrid_PointerEntered(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
mouseInside = true;
|
||||
}
|
||||
|
||||
private void FlyoutGrid_PointerExited(object sender, PointerRoutedEventArgs e)
|
||||
{
|
||||
mouseInside = false;
|
||||
}
|
||||
|
||||
private async void videoComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
// Deregister and desroy an existing player
|
||||
if (frameReader != null)
|
||||
{
|
||||
frameReader.FrameArrived -= FrameReader_FrameArrived;
|
||||
frameReader.Dispose();
|
||||
frameReader = null;
|
||||
}
|
||||
|
||||
|
||||
// reset items
|
||||
mediaCapture?.Dispose();
|
||||
mediaCapture = null;
|
||||
if (videoComboBox.SelectedIndex > 0)
|
||||
{
|
||||
// Blank the existing canvas
|
||||
renderTarget.Source = new SoftwareBitmapSource();
|
||||
// Initialise a new MediaCapture
|
||||
mediaCapture = new MediaCapture();
|
||||
MediaCaptureInitializationSettings settings = new MediaCaptureInitializationSettings
|
||||
{
|
||||
SourceGroup = videoDevices[videoComboBox.SelectedIndex - 1],
|
||||
|
||||
// This media capture can share streaming with other apps.
|
||||
SharingMode = MediaCaptureSharingMode.ExclusiveControl,
|
||||
|
||||
// Only stream video and don't initialize audio capture devices.
|
||||
StreamingCaptureMode = StreamingCaptureMode.Video,
|
||||
|
||||
// Set to CPU to ensure frames always contain CPU SoftwareBitmap images
|
||||
// instead of preferring GPU D3DSurface images.
|
||||
MemoryPreference = MediaCaptureMemoryPreference.Cpu
|
||||
};
|
||||
await mediaCapture.InitializeAsync(settings);
|
||||
// Grab the kinds of media source we have
|
||||
HashSet<MediaFrameSourceKind> startedKinds = new HashSet<MediaFrameSourceKind>();
|
||||
|
||||
IEnumerable<MediaFrameSource> mediaFrameSources = mediaCapture.FrameSources.Values.ToArray();
|
||||
videoStreamComboBox.ItemsSource = mediaFrameSources;
|
||||
MediaFrameSource selectedSource;
|
||||
|
||||
// TODO: If the count of streams is greater than 1, allow the user to select the specific stream
|
||||
if (mediaCapture.FrameSources.Values.Count() > 1)
|
||||
{
|
||||
videoStreamComboBox.SelectedIndex = 0;
|
||||
// Add another combobox; allow user to select desired source
|
||||
selectedSource = mediaCapture.FrameSources.Values.First();
|
||||
|
||||
videoStreamLabel.Visibility = Visibility.Visible;
|
||||
videoStreamComboBox.Visibility = Visibility.Visible;
|
||||
}
|
||||
else if (mediaCapture.FrameSources.Values.Count() == 0)
|
||||
{
|
||||
// Error, as camera has no streams
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just the one, continue
|
||||
selectedSource = mediaCapture.FrameSources.Values.First();
|
||||
videoStreamComboBox.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
// Source selected; enumerate formats
|
||||
|
||||
IEnumerable<FrameFormatModel> streamFormats = selectedSource.SupportedFormats
|
||||
.Where(format => GetSubtypeForFrameReader(selectedSource.Info.SourceKind, format) != null)
|
||||
.Select(format => new FrameFormatModel(format));
|
||||
videoTypeComboBox.ItemsSource = streamFormats;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// View model for MediaFrameFormat used in XAML ContentControl.
|
||||
/// </summary>
|
||||
public class FrameFormatModel
|
||||
{
|
||||
public MediaFrameFormat Format { get; }
|
||||
|
||||
public string DisplayName { get; }
|
||||
|
||||
public FrameFormatModel(MediaFrameFormat format)
|
||||
{
|
||||
this.Format = format;
|
||||
this.DisplayName = string.Format("{0} | {1} | {2} x {3} | {4:#.##}fps",
|
||||
format.MajorType,
|
||||
format.Subtype,
|
||||
format.VideoFormat?.Width,
|
||||
format.VideoFormat?.Height,
|
||||
Math.Round((double)format.FrameRate.Numerator / format.FrameRate.Denominator, 2));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return this.DisplayName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares the Format contained by this view model to the given format for equivalency.
|
||||
/// </summary>
|
||||
/// <param name="otherFormat">The MediaFrameFormat to compare to the MediaFrameFormat in this view model.</param>
|
||||
/// <returns></returns>
|
||||
public bool HasSameFormat(MediaFrameFormat otherFormat)
|
||||
{
|
||||
if (otherFormat == null)
|
||||
{
|
||||
return (Format == null);
|
||||
}
|
||||
|
||||
return this.Format.MajorType == otherFormat.MajorType &&
|
||||
this.Format.Subtype == otherFormat.Subtype &&
|
||||
this.Format.FrameRate.Numerator == otherFormat.FrameRate.Numerator &&
|
||||
this.Format.FrameRate.Denominator == otherFormat.FrameRate.Denominator &&
|
||||
this.Format.VideoFormat?.Width == otherFormat.VideoFormat?.Width &&
|
||||
this.Format.VideoFormat?.Height == otherFormat.VideoFormat?.Height;
|
||||
}
|
||||
}
|
||||
|
||||
private void PerfStatsView_Unchecked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
calcPerfStats = false;
|
||||
_ = renderTarget.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
|
||||
{
|
||||
StatisticsPane.Visibility = Visibility.Collapsed;
|
||||
});
|
||||
}
|
||||
|
||||
private void PerfStatsView_Checked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
calcPerfStats = true;
|
||||
_ = renderTarget.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
|
||||
{
|
||||
StatisticsPane.Visibility = Visibility.Visible;
|
||||
timelabel.Text = "0.0";
|
||||
timelabel_delta.Text = "0.0";
|
||||
maxTimeLabel.Text = "";
|
||||
frameProcessingTimeLabel.Text = "";
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
55
Camera-Renderer_cs/Package.appxmanifest
Normal file
@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<Package
|
||||
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||
xmlns:uap6="http://schemas.microsoft.com/appx/manifest/uap/windows10/6"
|
||||
xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
|
||||
IgnorableNamespaces="uap mp uap6 uap3">
|
||||
|
||||
<Identity
|
||||
Name="044f7330-801b-4f95-87f2-a257070b58f5"
|
||||
Publisher="CN=Brych"
|
||||
Version="1.0.0.0" />
|
||||
|
||||
<mp:PhoneIdentity PhoneProductId="044f7330-801b-4f95-87f2-a257070b58f5" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||
|
||||
<Properties>
|
||||
<DisplayName>CameraRendererCS</DisplayName>
|
||||
<PublisherDisplayName>Brych</PublisherDisplayName>
|
||||
<Logo>Assets\StoreLogo.png</Logo>
|
||||
</Properties>
|
||||
|
||||
<Dependencies>
|
||||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||
</Dependencies>
|
||||
|
||||
<Resources>
|
||||
<Resource Language="x-generate"/>
|
||||
</Resources>
|
||||
|
||||
<Applications>
|
||||
<Application Id="App"
|
||||
Executable="$targetnametoken$.exe"
|
||||
EntryPoint="CameraRendererCS.App">
|
||||
<uap:VisualElements
|
||||
DisplayName="Camera Renderer"
|
||||
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||
Square44x44Logo="Assets\Square44x44Logo.png"
|
||||
Description="Camera Renderer"
|
||||
BackgroundColor="transparent">
|
||||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
|
||||
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||
</uap:VisualElements>
|
||||
</Application>
|
||||
</Applications>
|
||||
|
||||
<Capabilities>
|
||||
<Capability Name="internetClient" />
|
||||
<uap6:Capability Name="graphicsCapture"/>
|
||||
<uap3:Capability Name="backgroundMediaPlayback"/>
|
||||
<DeviceCapability Name="webcam"/>
|
||||
<DeviceCapability Name="microphone"/>
|
||||
</Capabilities>
|
||||
</Package>
|
29
Camera-Renderer_cs/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("CameraDirect")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("CameraDirect")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: ComVisible(false)]
|
31
Camera-Renderer_cs/Properties/Default.rd.xml
Normal file
@ -0,0 +1,31 @@
|
||||
<!--
|
||||
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
|
||||
developers. However, you can modify these parameters to modify the behavior of the .NET Native
|
||||
optimizer.
|
||||
|
||||
Runtime Directives are documented at https://go.microsoft.com/fwlink/?LinkID=391919
|
||||
|
||||
To fully enable reflection for App1.MyClass and all of its public/private members
|
||||
<Type Name="App1.MyClass" Dynamic="Required All"/>
|
||||
|
||||
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
|
||||
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
|
||||
|
||||
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
|
||||
<Namespace Name="DataClasses.ViewModels" Serialize="All" />
|
||||
-->
|
||||
|
||||
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
||||
<Application>
|
||||
<!--
|
||||
An Assembly element with Name="*Application*" applies to all assemblies in
|
||||
the application package. The asterisks are not wildcards.
|
||||
-->
|
||||
<Assembly Name="*Application*" Dynamic="Required All" />
|
||||
|
||||
|
||||
<!-- Add your application specific runtime directives here. -->
|
||||
|
||||
|
||||
</Application>
|
||||
</Directives>
|
4
Camera-Renderer_cs/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
# CaptureRenderer
|
||||
|
||||
Renders the web-cam style capture data in a window. Also retrieves sound from the specified device.
|
||||
Intended to be used with HDMI capture cards
|
BIN
Camera-Renderer_cs/assets/LockScreenLogo.scale-200.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
Camera-Renderer_cs/assets/SplashScreen.scale-200.png
Normal file
After Width: | Height: | Size: 7.5 KiB |
BIN
Camera-Renderer_cs/assets/Square150x150Logo.scale-200.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
Camera-Renderer_cs/assets/Square44x44Logo.scale-200.png
Normal file
After Width: | Height: | Size: 1.6 KiB |
After Width: | Height: | Size: 1.2 KiB |
BIN
Camera-Renderer_cs/assets/StoreLogo.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
Camera-Renderer_cs/assets/Wide310x150Logo.scale-200.png
Normal file
After Width: | Height: | Size: 3.1 KiB |