Skip to content

Commit

Permalink
add hand 3d
Browse files Browse the repository at this point in the history
  • Loading branch information
Knightro63 committed Mar 9, 2024
1 parent 0fffa79 commit fb66913
Show file tree
Hide file tree
Showing 23 changed files with 1,851 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class AppleVisionFaceMeshPlugin: NSObject, FlutterPlugin {
if #available(iOS 14.0, *) {
return result(convertImage(Data(data.data),CGSize(width: width , height: height),CIFormat.BGRA8,orientation))
} else {
return result(FlutterError(code: "INVALID OS", message: "requires version 13.0", details: nil))
return result(FlutterError(code: "INVALID OS", message: "requires version 14.0", details: nil))
}
#elseif os(macOS)
return result(convertImage(Data(data.data),CGSize(width: width , height: height),CIFormat.ARGB8,orientation))
Expand All @@ -57,7 +57,7 @@ public class AppleVisionFaceMeshPlugin: NSObject, FlutterPlugin {
}

#if os(iOS)
@available(iOS 13.0, *)
@available(iOS 14.0, *)
#endif
func convertImage(_ data: Data,_ imageSize: CGSize,_ format: CIFormat,_ oriString: String) -> [String:Any?]{
var event:[String:Any?] = ["name":"noData"];
Expand Down Expand Up @@ -132,7 +132,7 @@ public class AppleVisionFaceMeshPlugin: NSObject, FlutterPlugin {
"mesh": meshData,
"croppedImage": nsImage,
"origin": ["x": croppedImage.1?.origin.x, "y": croppedImage.1?.origin.y],
"imageSize": ["width":192 ,"height":192]
"imageSize": ["width":croppedImage.1?.width ,"height":croppedImage.1?.height]
]
}
})
Expand Down
28 changes: 22 additions & 6 deletions packages/apple_vision_face_mesh/lib/src/face_mesh_data.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import 'dart:typed_data';

import 'package:flutter/cupertino.dart';

/// The coordinate points of the face
///
/// [x] X location
Expand All @@ -11,6 +13,18 @@ class FacePoint{
final double z;
}

class FaceImage{
FaceImage({
required this.croppedImage,
required this.size,
required this.origin,
});

final Size size;
final Uint8List croppedImage;
final FacePoint origin;
}

/// A class that has all the information on the face detected
///
/// [mesh] The marks found in the image.
Expand All @@ -19,16 +33,15 @@ class FaceMesh{
FaceMesh({
required this.mesh,
this.confidence,
this.croppedImage,
this.origin,
required this.image,
required this.raw
});

final List<FacePoint> mesh;
final List<double> raw;
final double? confidence;
final Uint8List? croppedImage;
final FacePoint? origin;
final FaceImage image;


factory FaceMesh.fromJson(Map json){
List<FacePoint> points = [];
Expand All @@ -40,8 +53,11 @@ class FaceMesh{
return FaceMesh(
mesh: points,
confidence: json['confidence'],
croppedImage: json['croppedImage'],
origin: FacePoint(json['origin']["x"],json['origin']["y"],0),
image: FaceImage(
croppedImage: json['croppedImage'],
origin: FacePoint(json['origin']["x"],json['origin']["y"],0),
size: Size(json['imageSize']["width"],json['imageSize']["height"])
),
raw: raw
);
}
Expand Down
139 changes: 139 additions & 0 deletions packages/apple_vision_hand_3d/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
# Miscellaneous
*.class
*.lock
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Visual Studio Code related
.classpath
.project
.settings/
.vscode/*

*/macos
*/ios
*/windows
*/linux
*/android
*/web
# Flutter repo-specific
/bin/cache/
/bin/internal/bootstrap.bat
/bin/internal/bootstrap.sh
/bin/mingit/
/dev/benchmarks/mega_gallery/
/dev/bots/.recipe_deps
/dev/bots/android_tools/
/dev/devicelab/ABresults*.json
/dev/docs/doc/
/dev/docs/flutter.docs.zip
/dev/docs/lib/
/dev/docs/pubspec.yaml
/dev/integration_tests/**/xcuserdata
/dev/integration_tests/**/Pods
/packages/flutter/coverage/
version
analysis_benchmark.json

# packages file containing multi-root paths
.packages.generated

# Flutter/Dart/Pub related
**/doc/api/
.dart_tool/
.flutter-plugins
.flutter-plugins-dependencies
**/generated_plugin_registrant.dart
.packages
.pub-preload-cache/
.pub/
build/
flutter_*.png
linked_*.ds
unlinked.ds
unlinked_spec.ds

# Android related
**/android/**/gradle-wrapper.jar
.gradle/
**/android/captures/
**/android/gradlew
**/android/gradlew.bat
**/android/local.properties
**/android/**/GeneratedPluginRegistrant.java
**/android/key.properties
*.jks

# iOS/XCode related
**/ios/**/*.mode1v3
**/ios/**/*.mode2v3
**/ios/**/*.moved-aside
**/ios/**/*.pbxuser
**/ios/**/*.perspectivev3
**/ios/**/*sync/
**/ios/**/.sconsign.dblite
**/ios/**/.tags*
**/ios/**/.vagrant/
**/ios/**/DerivedData/
**/ios/**/Icon?
**/ios/**/Pods/
**/ios/**/.symlinks/
**/ios/**/profile
**/ios/**/xcuserdata
**/ios/.generated/
**/ios/Flutter/.last_build_id
**/ios/Flutter/App.framework
**/ios/Flutter/Flutter.framework
**/ios/Flutter/Flutter.podspec
**/ios/Flutter/Generated.xcconfig
**/ios/Flutter/ephemeral
**/ios/Flutter/app.flx
**/ios/Flutter/app.zip
**/ios/Flutter/flutter_assets/
**/ios/Flutter/flutter_export_environment.sh
**/ios/ServiceDefinitions.json
**/ios/Runner/GeneratedPluginRegistrant.*

# macOS
**/Flutter/ephemeral/
**/Pods/
**/macos/Flutter/GeneratedPluginRegistrant.swift
**/macos/Flutter/ephemeral
**/xcuserdata/

# Windows
**/windows/flutter/generated_plugin_registrant.cc
**/windows/flutter/generated_plugin_registrant.h
**/windows/flutter/generated_plugins.cmake

# Linux
**/linux/flutter/generated_plugin_registrant.cc
**/linux/flutter/generated_plugin_registrant.h
**/linux/flutter/generated_plugins.cmake

# Coverage
coverage/

# Symbols
app.*.symbols

# Exceptions to above rules.
!**/ios/**/default.mode1v3
!**/ios/**/default.mode2v3
!**/ios/**/default.pbxuser
!**/ios/**/default.perspectivev3
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
!/dev/ci/**/Gemfile.lock
!.vscode/settings.json
3 changes: 3 additions & 0 deletions packages/apple_vision_hand_3d/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
## 0.0.1

* Initial release
21 changes: 21 additions & 0 deletions packages/apple_vision_hand_3d/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Knightro63.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit fb66913

Please sign in to comment.