Windows 应用 SDK 中 AI 图像的 API 参考

重要

可在 Windows 应用程序 SDK 的最新 实验通道 版本中获得。

Windows 应用 SDK 试验通道包括开发早期阶段的 API 和功能。 试验通道中的所有 API 都可能经过大量修订和中断性变更,并且随时可从后续版本中删除。 在生产环境中不支持使用实验性功能,并且使用这些功能的应用不能发布到 Microsoft Store。

  • 图像处理功能在中国不可用。
  • 不支持解压缩的应用。

了解有关由人工智能 (AI) 提供支持的 Windows 应用 SDK 图像处理 API,它们支持以下功能。

  • 图像超级分辨率:缩放和锐化图像
  • 图像说明:生成描述图像的文本
  • 图像分段:标识图像中的对象

有关详细信息,请参阅Windows 应用 SDK中的 AI 映像入门。

提示

通过在 Windows 应用 SDK GitHub 存储库中创建 新问题(标题中包含 映像),或通过响应 现有问题,来提供关于这些 API 及其功能的反馈。


Microsoft.Graphics.Imaging 命名空间

为缩放和锐化图像的机器学习模型提供 API。

ImageBuffer 类

public sealed class ImageBuffer : System.IDisposable

表示用于高效跨进程封送处理的解压缩位图。

注解

ImageBuffer 可用于需要图像数据的 AI 模型 API,例如 TextRecognizer。 典型用法涉及从现有 SoftwareBitmap 创建 ImageBuffer。

ImageBuffer.Buffer 属性

public Windows.Storage.Streams.IBuffer Buffer { get; }

获取当前图像缓冲区。

属性值

当前图像缓冲区。

ImageBuffer.BufferLength 属性

public uint BufferLength { get; }

获取图像缓冲区的长度。

属性值

图像缓冲区的长度。

ImageBuffer.Close 方法

// This member is not implemented in C#

释放对象和关联的资源。

注解

未在 C# 中实现。

ImageBuffer.CopyToBuffer(System.Byte[]) 方法

public void CopyToBuffer (byte[] values);

将当前缓冲区复制到提供的目标缓冲区。

参数
价值, 价值观

缓冲区中字节的向量。

ImageBuffer.CreateBufferAttachedToBitmap(Windows.Graphics.Imaging.SoftwareBitmap) 方法

public static Microsoft.Graphics.Imaging.ImageBuffer CreateBufferAttachedToBitmap (Windows.Graphics.Imaging.SoftwareBitmap softwareBitmap);

通过从位图对象获取 IMemoryBufferReference,从现有的 SotftwareBitmap 创建新的 ImageBuffer。

参数
softwareBitmap

要从中创建 ImageBuffer 的 SotftwareBitmap。

退货

如果 ImageBuffer 为不受支持的格式,则为 Null。

注解

SoftwareBitmap 将被锁定,直到异步操作完成并且新的 ImageBuffer 被销毁。

ImageBuffer.CreateCopyFromBitmap(Windows.Graphics.Imaging.SoftwareBitmap) 方法

public static Microsoft.Graphics.Imaging.ImageBuffer CreateCopyFromBitmap (Windows.Graphics.Imaging.SoftwareBitmap softwareBitmap);

通过复制底层位图数据,从现有的 SotftwareBitmap 创建新的 ImageBuffer。

参数
softwareBitmap

要从中创建 ImageBuffer 的 SotftwareBitmap。

退货

如果 ImageBuffer 为不受支持的格式,则为 Null。

注解

SoftwareBitmap 将锁定,直到异步操作完成,新的 ImageBuffer 被销毁。

ImageBuffer.CreateFromBuffer(Windows.Storage.Streams.IBuffer,Microsoft.Graphics.Imaging.PixelFormat,System.UInt32,System.UInt32) 方法

public static Microsoft.Graphics.Imaging.ImageBuffer CreateFromBuffer (Windows.Storage.Streams.IBuffer buffer, Microsoft.Graphics.Imaging.PixelFormat pixelFormat, uint width, uint height);
参数
buffer
pixelFormat
width
身高
退货

ImageBuffer.CreateFromBufferWithStride(Windows.Storage.Streams.IBuffer,Microsoft.Graphics.Imaging.PixelFormat,System.UInt32,System.UInt32,System.UInt32) 方法

public static Microsoft.Graphics.Imaging.ImageBuffer CreateFromBufferWithStride (Windows.Storage.Streams.IBuffer buffer, Microsoft.Graphics.Imaging.PixelFormat pixelFormat, uint width, uint height, uint stride);
参数
buffer
pixelFormat
width
身高
stride
退货

ImageBuffer.CreateSoftwareBitmap 方法

public Windows.Graphics.Imaging.SoftwareBitmap CreateSoftwareBitmap ();

从一个 ImageBuffer 中存储的像素数据创建一个新的 BGRA32 类型的 SoftwareBitmap。

退货

像素类型 BGRA32 的新 SoftwareBitmap。

ImageBuffer.Height 属性

public uint Height { get; }

获取图像的高度(以像素为单位)。

属性值

图像的高度(以像素为单位)。

ImageBuffer.#ctor(Windows.Storage.Streams.IBuffer,Microsoft.Graphics.Imaging.PixelFormat,System.UInt32,System.UInt32) 构造函数

public ImageBuffer (Windows.Storage.Streams.IBuffer buffer, Microsoft.Graphics.Imaging.PixelFormat pixelFormat, uint width, uint height);

初始化 ImageBuffer 类的新实例。

参数
buffer

ImageBuffer。

pixelFormat

图像的像素格式。

width

图像的宽度(以像素为单位)。

身高

图像的高度(以像素为单位)。

ImageBuffer.PixelFormat 属性

public Microsoft.Graphics.Imaging.PixelFormat PixelFormat { get; }

获取图像的像素格式。

属性值

图像的像素格式。

ImageBuffer.Width 属性

public uint Width { get; }

获取图像的宽度(以像素为单位)。

属性值

图像的宽度(以像素为单位)。

ImageObjectExtractor 类

public sealed class ImageObjectExtractor : System.IDisposable

ImageObjectExtractor.Close 方法

// This member is not implemented in C#
注解

未在 C# 中实现。

ImageObjectExtractor.CreateWithImageBufferAsync(Microsoft.Graphics.Imaging.ImageBuffer) 方法

public static Windows.Foundation.IAsyncOperation<Microsoft.Graphics.Imaging.ImageObjectExtractor> CreateWithImageBufferAsync (Microsoft.Graphics.Imaging.ImageBuffer imageBuffer);
参数
imageBuffer
退货

ImageObjectExtractor.CreateWithSoftwareBitmapAsync(Windows.Graphics.Imaging.SoftwareBitmap) 方法

public static Windows.Foundation.IAsyncOperation<Microsoft.Graphics.Imaging.ImageObjectExtractor> CreateWithSoftwareBitmapAsync (Windows.Graphics.Imaging.SoftwareBitmap softwareBitmap);
参数
softwareBitmap
退货

ImageObjectExtractor.GetImageBufferObjectMask(Microsoft.Graphics.Imaging.ImageObjectExtractorHint) 方法

public Microsoft.Graphics.Imaging.ImageBuffer GetImageBufferObjectMask (Microsoft.Graphics.Imaging.ImageObjectExtractorHint hint);
参数
hint
退货

ImageObjectExtractor.GetSoftwareBitmapObjectMask(Microsoft.Graphics.Imaging.ImageObjectExtractorHint) 方法

public Windows.Graphics.Imaging.SoftwareBitmap GetSoftwareBitmapObjectMask (Microsoft.Graphics.Imaging.ImageObjectExtractorHint hint);
参数
hint
退货

ImageObjectExtractor.IsAvailable 方法

public static bool IsAvailable ();
退货

ImageObjectExtractor.MakeAvailableAsync 方法

public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
退货

ImageObjectExtractorHint 类

public sealed class ImageObjectExtractorHint

ImageObjectExtractorHint.ExcludePoints 属性

public System.Collections.Generic.IReadOnlyList<Windows.Graphics.PointInt32> ExcludePoints { get; }
属性值

ImageObjectExtractorHint.#ctor(Windows.Foundation.Collections.IVector{Windows.Graphics.RectInt32},Windows.Foundation.Collections.IVector{Windows.Graphics.PointInt32},Windows.Foundation.Collections.IVector{Windows.Graphics.PointInt32}) 构造函数

public ImageObjectExtractorHint (System.Collections.Generic.IList<Windows.Graphics.RectInt32> includeRects, System.Collections.Generic.IList<Windows.Graphics.PointInt32> includePoints, System.Collections.Generic.IList<Windows.Graphics.PointInt32> excludePoints);
参数
includeRects
includePoints
excludePoints

ImageObjectExtractorHint.IncludePoints 属性

public System.Collections.Generic.IReadOnlyList<Windows.Graphics.PointInt32> IncludePoints { get; }
属性值

ImageObjectExtractorHint.IncludeRects 属性

public System.Collections.Generic.IReadOnlyList<Windows.Graphics.RectInt32> IncludeRects { get; }
属性值

ImageScaler 类

public sealed class ImageScaler : System.IDisposable

ImageScaler.Close 方法

// This member is not implemented in C#
注解

未在 C# 中实现。

ImageScaler.CreateAsync 方法

public static Windows.Foundation.IAsyncOperation<Microsoft.Graphics.Imaging.ImageScaler> CreateAsync ();
退货

ImageScaler.IsAvailable 方法

public static bool IsAvailable ();
退货

ImageScaler.MakeAvailableAsync 方法

public static Windows.Foundation.IAsyncOperationWithProgress<Microsoft.Windows.Management.Deployment.PackageDeploymentResult,Microsoft.Windows.Management.Deployment.PackageDeploymentProgress> MakeAvailableAsync ();
退货

ImageScaler.MaxSupportedScaleFactor 属性

public int MaxSupportedScaleFactor { get; }
属性值

ImageScaler.ScaleImageBuffer(Microsoft.Graphics.Imaging.ImageBuffer,System.Int32,System.Int32) 方法

public Microsoft.Graphics.Imaging.ImageBuffer ScaleImageBuffer (Microsoft.Graphics.Imaging.ImageBuffer imageBuffer, int width, int height);
参数
imageBuffer
width
身高
退货

ImageScaler.ScaleSoftwareBitmap(Windows.Graphics.Imaging.SoftwareBitmap,System.Int32,System.Int32) 方法

public Windows.Graphics.Imaging.SoftwareBitmap ScaleSoftwareBitmap (Windows.Graphics.Imaging.SoftwareBitmap softwareBitmap, int width, int height);
参数
softwareBitmap
width
身高
退货

PixelFormat 枚举

public enum PixelFormat

指定基础位图数据的二进制布局类型。

枚举字段
未定义:0

二进制格式未定义。

Rgb24: 1

二进制格式为每像素 24 位;每个 8 位用于红色、绿色和蓝色组件。

Argb32:2

二进制格式为每像素 32 位;alpha、红色、绿色和蓝色组件各使用 8 位。

Rgba32: 3

二进制格式为每像素 32 位;每个 8 位用于红色、绿色、蓝色和 alpha 组件。 颜色组件以红色、绿色、蓝色和 alpha 顺序存储。

Bgra32: 4

二进制格式为每像素 32 位;蓝色、绿色、红色和 alpha 组件各使用 8 位。 颜色组件以蓝色、绿色、红色和 alpha 顺序存储。

Gray8:5

二进制格式为每像素 16 位。 颜色信息指定 65536 个灰色色阶。