共用方式為


Windows App SDK 中 AI 影像的 API 參考

重要

Windows App SDK 的最新 實驗通道 版本中提供。

Windows App SDK 實驗通道包含開發初期階段的 API 和功能。 實驗通道中的所有 API 都受限於廣泛的修訂和中斷性變更,而且可以隨時從後續版本中移除。 實驗性功能不支援在生產環境中使用,且使用它們的應用程式無法發佈至Microsoft市集。

  • 影像描述功能不適用於中國大陸。
  • 不支援獨立應用程式。

了解由人工智慧(AI)支援的 Windows App SDK 映像 API,其支援以下功能:

  • 影像超級解析度:縮放和銳化影像
  • 影像描述:產生描述影像的文字
  • 影像分割:識別影像內的物件

如需詳細資訊,請參閱 Windows 應用程式 SDK 中的開始使用 AI 映像。

提示

藉由在 Windows App SDK GitHub 存放庫中建立 新問題(在標題中包括 Imaging)或回應 現有問題,提供這些 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);

從現有的 SotftwareBitmap 建立新的 ImageBuffer,方法是從點陣圖物件取得 IMemoryBufferReference。

參數
軟體位圖

要從中建立 ImageBuffer 的 SoftwareBitmap。

返回

ImageBuffer 或 Null(如果是不支援的格式)。

備註

當異步操作完成並且新的 ImageBuffer 被銷毀之前,SoftwareBitmap 會保持鎖定狀態。

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

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

從現有的 SotftwareBitmap 複製基礎位圖數據,以建立新的 ImageBuffer。

參數
軟體位圖

要從中建立 ImageBuffer 的 SoftwareBitmap。

返回

ImageBuffer 或 Null(如果是不支援的格式)。

備註

當異步操作完成並且新的 ImageBuffer 被銷毀之前,SoftwareBitmap 會保持鎖定狀態。

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);
參數
緩衝區
pixelFormat
寬度
高度
返回

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);
參數
緩衝區
pixelFormat
寬度
高度
步伐
返回

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 類別的新實例。

參數
緩衝區

ImageBuffer。

pixelFormat

影像的像素格式。

寬度

影像的寬度,以像素為單位。

高度

影像的高度,以像素為單位。

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);
參數
軟體位圖
返回

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

public Microsoft.Graphics.Imaging.ImageBuffer GetImageBufferObjectMask (Microsoft.Graphics.Imaging.ImageObjectExtractorHint hint);
參數
提示
返回

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

public Windows.Graphics.Imaging.SoftwareBitmap GetSoftwareBitmapObjectMask (Microsoft.Graphics.Imaging.ImageObjectExtractorHint 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
排除點數

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
寬度
高度
返回

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);
參數
軟體位圖
寬度
高度
返回

PixelFormat 列舉

public enum PixelFormat

指定基礎點陣圖數據的二進位配置類型。

列舉欄位
未定義: 0

二進位格式未定義。

Rgb24: 1

二進位格式為每像素 24 位;每個8位都用於紅色、綠色和藍色元件。

Argb32: 2

每像素 32 位的二進位格式;每個8位都用於Alpha、紅色、綠色和藍色元件。

Rgba32: 3

二進位格式為每像素 32 位;每個8位都用於紅色、綠色、藍色和Alpha元件。 色彩元件會以紅色、綠色、藍色和Alpha順序儲存。

Bgra32: 4

二進位格式為每像素 32 位;每個8位都用於藍色、綠色、紅色和Alpha元件。 色彩元件會以藍色、綠色、紅色和Alpha順序儲存。

灰色8:5

二進位格式為每像素 16 位。 色彩資訊規定 65536 種灰階。