onnxruntime/winml/lib/Api/ImageFeatureValue.h
Paul McDaniel 5350abe19d
LearningModelSession is cleaned up to use the adapter, and parts of b… (#2382)
this is a big PR.    we are going to move it up to layer_dev , which is still a L3 so we are still safe to do work there agile.

we are going to move this into the L3 so that ryan can start doing intergration testing.   

we will pause for a full code review and integration test result prior to going into the L2.

>>>> raw comments from previous commits >>> 

* LearningModelSession is cleaned up to use the adapter, and parts of binding are.
* moved everything in the winmladapter
made it all nano-com using, WRL to construct objects in the ORT side.
base interfaces for everythign for winml to call
cleaned up a bunch of winml to use the base interfaces.
* more pieces
* GetData across the abi.
* renamed some namepsace
cleaned up OrtValue
cleaned up Tensor
cleaned up custom ops.
everything *but* learnignmodel should be clean
* make sure it's building.   winml.dll is still a monolith.
2019-11-14 17:44:07 -08:00

66 lines
2.8 KiB
C++

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
#pragma once
#include "ImageFeatureValue.g.h"
#include "inc/ILotusValueProviderPrivate.h"
namespace winrt::Windows::AI::MachineLearning::implementation {
struct ImageFeatureValue : ImageFeatureValueT<ImageFeatureValue, WinML::ILotusValueProviderPrivate> {
// Metadata about the resource which helps in finding
// compatible cached resources
struct ImageResourceMetadata;
ImageFeatureValue() = delete;
ImageFeatureValue(Windows::Media::VideoFrame const& image);
ImageFeatureValue(winrt::Windows::Foundation::Collections::IVector<Windows::Media::VideoFrame> const& images);
ImageFeatureValue(winrt::Windows::Foundation::Collections::IVectorView<Windows::Media::VideoFrame> const& images);
Windows::Media::VideoFrame VideoFrame();
winrt::Windows::Foundation::Collections::IIterable<Windows::Media::VideoFrame> VideoFrames();
Windows::AI::MachineLearning::LearningModelFeatureKind Kind();
static Windows::AI::MachineLearning::ImageFeatureValue ImageFeatureValue::Create(
uint32_t batchSize,
Windows::Graphics::Imaging::BitmapPixelFormat format,
uint32_t width,
uint32_t height);
static Windows::AI::MachineLearning::ImageFeatureValue CreateFromVideoFrame(Windows::Media::VideoFrame const& image);
std::optional<ImageResourceMetadata> GetInputMetadata(const WinML::BindingContext& context);
// ILotusValueProviderPrivate implementation
STDMETHOD(GetOrtValue)
(WinML::BindingContext& context, _winmla::IOrtValue** mlValue);
STDMETHOD(IsPlaceholder)
(bool* pIsPlaceHolder);
STDMETHOD(UpdateSourceResourceData)
(WinML::BindingContext& context, _winmla::IOrtValue* mlValue);
STDMETHOD(AbiRepresentation)
(winrt::Windows::Foundation::IInspectable& abiRepresentation);
std::vector<uint32_t> Widths() { return m_widths; }
std::vector<uint32_t> Heights() { return m_heights; }
bool IsBatch() { return m_batchSize > 1; }
private:
winrt::Windows::Foundation::Collections::IVector<Windows::Media::VideoFrame> m_videoFrames;
std::vector<uint32_t> m_widths = {};
std::vector<uint32_t> m_heights = {};
uint32_t m_batchSize = 1;
// Crop the image with desired aspect ratio.
// This function does not crop image to desried width and height, but crops to center for desired ratio
Windows::Graphics::Imaging::BitmapBounds CenterAndCropBounds(
uint32_t idx,
uint32_t desiredWidth,
uint32_t desiredHeight);
void Initialize();
};
} // namespace winrt::Windows::AI::MachineLearning::implementation
namespace winrt::Windows::AI::MachineLearning::factory_implementation {
struct ImageFeatureValue : ImageFeatureValueT<ImageFeatureValue, implementation::ImageFeatureValue> {
};
} // namespace winrt::Windows::AI::MachineLearning::factory_implementation