-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(windows_ai): add MachineLearning APIs (#255)
- Loading branch information
1 parent
bfc65a0
commit c1c1eca
Showing
97 changed files
with
9,444 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
125 changes: 125 additions & 0 deletions
125
packages/windows_ai/lib/src/machinelearning/iimagefeaturedescriptor.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
// ignore_for_file: constant_identifier_names, non_constant_identifier_names | ||
// ignore_for_file: unnecessary_import, unused_import | ||
|
||
import 'dart:async'; | ||
import 'dart:ffi'; | ||
|
||
import 'package:ffi/ffi.dart'; | ||
import 'package:win32/win32.dart' hide DocumentProperties; | ||
import 'package:windows_foundation/internal.dart'; | ||
import 'package:windows_foundation/windows_foundation.dart'; | ||
import 'package:windows_graphics/windows_graphics.dart'; | ||
|
||
/// @nodoc | ||
const IID_IImageFeatureDescriptor = '{365585a5-171a-4a2a-985f-265159d3895a}'; | ||
|
||
class IImageFeatureDescriptor extends IInspectable { | ||
// vtable begins at 6, is 4 entries long. | ||
IImageFeatureDescriptor.fromPtr(super.ptr); | ||
|
||
factory IImageFeatureDescriptor.from(IInspectable interface) => | ||
IImageFeatureDescriptor.fromPtr( | ||
interface.toInterface(IID_IImageFeatureDescriptor)); | ||
|
||
BitmapPixelFormat get bitmapPixelFormat { | ||
final retValuePtr = calloc<Int32>(); | ||
|
||
try { | ||
final hr = ptr.ref.vtable | ||
.elementAt(6) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function( | ||
VTablePointer lpVtbl, Pointer<Int32> retValuePtr)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, | ||
Pointer<Int32> retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); | ||
|
||
if (FAILED(hr)) throw WindowsException(hr); | ||
|
||
return BitmapPixelFormat.from(retValuePtr.value); | ||
} finally { | ||
free(retValuePtr); | ||
} | ||
} | ||
|
||
BitmapAlphaMode get bitmapAlphaMode { | ||
final retValuePtr = calloc<Int32>(); | ||
|
||
try { | ||
final hr = ptr.ref.vtable | ||
.elementAt(7) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function( | ||
VTablePointer lpVtbl, Pointer<Int32> retValuePtr)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, | ||
Pointer<Int32> retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); | ||
|
||
if (FAILED(hr)) throw WindowsException(hr); | ||
|
||
return BitmapAlphaMode.from(retValuePtr.value); | ||
} finally { | ||
free(retValuePtr); | ||
} | ||
} | ||
|
||
int get width { | ||
final retValuePtr = calloc<Uint32>(); | ||
|
||
try { | ||
final hr = ptr.ref.vtable | ||
.elementAt(8) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function(VTablePointer lpVtbl, | ||
Pointer<Uint32> retValuePtr)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, | ||
Pointer<Uint32> retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); | ||
|
||
if (FAILED(hr)) throw WindowsException(hr); | ||
|
||
return retValuePtr.value; | ||
} finally { | ||
free(retValuePtr); | ||
} | ||
} | ||
|
||
int get height { | ||
final retValuePtr = calloc<Uint32>(); | ||
|
||
try { | ||
final hr = ptr.ref.vtable | ||
.elementAt(9) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function(VTablePointer lpVtbl, | ||
Pointer<Uint32> retValuePtr)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, | ||
Pointer<Uint32> retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); | ||
|
||
if (FAILED(hr)) throw WindowsException(hr); | ||
|
||
return retValuePtr.value; | ||
} finally { | ||
free(retValuePtr); | ||
} | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
packages/windows_ai/lib/src/machinelearning/iimagefeaturedescriptor2.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
// ignore_for_file: constant_identifier_names, non_constant_identifier_names | ||
// ignore_for_file: unnecessary_import, unused_import | ||
|
||
import 'dart:async'; | ||
import 'dart:ffi'; | ||
|
||
import 'package:ffi/ffi.dart'; | ||
import 'package:win32/win32.dart' hide DocumentProperties; | ||
import 'package:windows_foundation/internal.dart'; | ||
import 'package:windows_foundation/windows_foundation.dart'; | ||
|
||
import 'learningmodelpixelrange.dart'; | ||
|
||
/// @nodoc | ||
const IID_IImageFeatureDescriptor2 = '{2b27cca7-d533-5862-bb98-1611b155b0e1}'; | ||
|
||
class IImageFeatureDescriptor2 extends IInspectable { | ||
// vtable begins at 6, is 1 entries long. | ||
IImageFeatureDescriptor2.fromPtr(super.ptr); | ||
|
||
factory IImageFeatureDescriptor2.from(IInspectable interface) => | ||
IImageFeatureDescriptor2.fromPtr( | ||
interface.toInterface(IID_IImageFeatureDescriptor2)); | ||
|
||
LearningModelPixelRange get pixelRange { | ||
final retValuePtr = calloc<Int32>(); | ||
|
||
try { | ||
final hr = ptr.ref.vtable | ||
.elementAt(6) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function( | ||
VTablePointer lpVtbl, Pointer<Int32> retValuePtr)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, | ||
Pointer<Int32> retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); | ||
|
||
if (FAILED(hr)) throw WindowsException(hr); | ||
|
||
return LearningModelPixelRange.from(retValuePtr.value); | ||
} finally { | ||
free(retValuePtr); | ||
} | ||
} | ||
} |
56 changes: 56 additions & 0 deletions
56
packages/windows_ai/lib/src/machinelearning/iimagefeaturevalue.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
// ignore_for_file: constant_identifier_names, non_constant_identifier_names | ||
// ignore_for_file: unnecessary_import, unused_import | ||
|
||
import 'dart:async'; | ||
import 'dart:ffi'; | ||
|
||
import 'package:ffi/ffi.dart'; | ||
import 'package:win32/win32.dart' hide DocumentProperties; | ||
import 'package:windows_foundation/internal.dart'; | ||
import 'package:windows_foundation/windows_foundation.dart'; | ||
import 'package:windows_media/windows_media.dart'; | ||
|
||
/// @nodoc | ||
const IID_IImageFeatureValue = '{f0414fd9-c9aa-4405-b7fb-94f87c8a3037}'; | ||
|
||
class IImageFeatureValue extends IInspectable { | ||
// vtable begins at 6, is 1 entries long. | ||
IImageFeatureValue.fromPtr(super.ptr); | ||
|
||
factory IImageFeatureValue.from(IInspectable interface) => | ||
IImageFeatureValue.fromPtr(interface.toInterface(IID_IImageFeatureValue)); | ||
|
||
VideoFrame? get videoFrame { | ||
final retValuePtr = calloc<COMObject>(); | ||
|
||
final hr = ptr.ref.vtable | ||
.elementAt(6) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function(VTablePointer lpVtbl, | ||
Pointer<COMObject> retValuePtr)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, | ||
Pointer<COMObject> retValuePtr)>()(ptr.ref.lpVtbl, retValuePtr); | ||
|
||
if (FAILED(hr)) { | ||
free(retValuePtr); | ||
throw WindowsException(hr); | ||
} | ||
|
||
if (retValuePtr.ref.isNull) { | ||
free(retValuePtr); | ||
return null; | ||
} | ||
|
||
return VideoFrame.fromPtr(retValuePtr); | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
packages/windows_ai/lib/src/machinelearning/iimagefeaturevaluestatics.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// Copyright (c) 2023, Dart | Windows. Please see the AUTHORS file for details. | ||
// All rights reserved. Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// THIS FILE IS GENERATED AUTOMATICALLY AND SHOULD NOT BE EDITED DIRECTLY. | ||
|
||
// ignore_for_file: constant_identifier_names, non_constant_identifier_names | ||
// ignore_for_file: unnecessary_import, unused_import | ||
|
||
import 'dart:async'; | ||
import 'dart:ffi'; | ||
|
||
import 'package:ffi/ffi.dart'; | ||
import 'package:win32/win32.dart' hide DocumentProperties; | ||
import 'package:windows_foundation/internal.dart'; | ||
import 'package:windows_foundation/windows_foundation.dart'; | ||
import 'package:windows_media/windows_media.dart'; | ||
|
||
import 'imagefeaturevalue.dart'; | ||
|
||
/// @nodoc | ||
const IID_IImageFeatureValueStatics = '{1bc317fd-23cb-4610-b085-c8e1c87ebaa0}'; | ||
|
||
class IImageFeatureValueStatics extends IInspectable { | ||
// vtable begins at 6, is 1 entries long. | ||
IImageFeatureValueStatics.fromPtr(super.ptr); | ||
|
||
factory IImageFeatureValueStatics.from(IInspectable interface) => | ||
IImageFeatureValueStatics.fromPtr( | ||
interface.toInterface(IID_IImageFeatureValueStatics)); | ||
|
||
ImageFeatureValue? createFromVideoFrame(VideoFrame? image) { | ||
final retValuePtr = calloc<COMObject>(); | ||
final imagePtr = image == null ? nullptr : image.ptr.ref.lpVtbl; | ||
|
||
final hr = | ||
ptr.ref.vtable | ||
.elementAt(6) | ||
.cast< | ||
Pointer< | ||
NativeFunction< | ||
HRESULT Function( | ||
VTablePointer lpVtbl, | ||
VTablePointer image, | ||
Pointer<COMObject> retValuePtr)>>>() | ||
.value | ||
.asFunction< | ||
int Function(VTablePointer lpVtbl, VTablePointer image, | ||
Pointer<COMObject> retValuePtr)>()( | ||
ptr.ref.lpVtbl, imagePtr, retValuePtr); | ||
|
||
if (FAILED(hr)) { | ||
free(retValuePtr); | ||
throw WindowsException(hr); | ||
} | ||
|
||
if (retValuePtr.ref.isNull) { | ||
free(retValuePtr); | ||
return null; | ||
} | ||
|
||
return ImageFeatureValue.fromPtr(retValuePtr); | ||
} | ||
} |
Oops, something went wrong.