Skip to content

Commit

Permalink
testing pose example
Browse files Browse the repository at this point in the history
  • Loading branch information
Knightro63 committed Jun 17, 2023
1 parent 61c51c6 commit 797f43c
Show file tree
Hide file tree
Showing 83 changed files with 3,475 additions and 85 deletions.
4 changes: 4 additions & 0 deletions packages/apple_vision_face/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.2

* Updates to example files, and fixed point offset

## 0.0.1

* Initial release
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
D53CDF0BE50D8A4A82BA0FB0 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2231C9E897DCA82F63DDFB9 /* Pods_Runner.framework */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -31,6 +32,7 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
15759B7B9EE8B5E0F9376312 /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand All @@ -42,19 +44,34 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
B2231C9E897DCA82F63DDFB9 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
B47C4615E30568CA78C1721F /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
F16CF9E090209CB26C926411 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
97C146EB1CF9000F007C117D /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D53CDF0BE50D8A4A82BA0FB0 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
8DB7914B28396890100C9AD2 /* Pods */ = {
isa = PBXGroup;
children = (
15759B7B9EE8B5E0F9376312 /* Pods-Runner.debug.xcconfig */,
B47C4615E30568CA78C1721F /* Pods-Runner.release.xcconfig */,
F16CF9E090209CB26C926411 /* Pods-Runner.profile.xcconfig */,
);
name = Pods;
path = Pods;
sourceTree = "<group>";
};
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
Expand All @@ -72,6 +89,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
8DB7914B28396890100C9AD2 /* Pods */,
AFA65C4728E67AA1212749AB /* Frameworks */,
);
sourceTree = "<group>";
};
Expand All @@ -98,19 +117,29 @@
path = Runner;
sourceTree = "<group>";
};
AFA65C4728E67AA1212749AB /* Frameworks */ = {
isa = PBXGroup;
children = (
B2231C9E897DCA82F63DDFB9 /* Pods_Runner.framework */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
97C146ED1CF9000F007C117D /* Runner */ = {
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
AC46063BBFC0F20ABA1A538C /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
F27430CED429190282143D58 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -199,6 +228,45 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
AC46063BBFC0F20ABA1A538C /* [CP] Check Pods Manifest.lock */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputFileListPaths = (
);
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
F27430CED429190282143D58 /* [CP] Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
);
name = "[CP] Embed Pods Frameworks";
outputFileListPaths = (
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 59 additions & 16 deletions packages/apple_vision_face/example/lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'dart:typed_data';
import 'package:apple_vision_face/apple_vision_face.dart';
import 'package:flutter/material.dart';
Expand All @@ -8,6 +9,8 @@ import 'package:camera_macos/camera_macos_file.dart';
import 'package:camera_macos/camera_macos_platform_interface.dart';
import 'package:camera_macos/camera_macos_view.dart';

import 'package:camera/camera.dart';

void main() {
runApp(const MyApp());
}
Expand All @@ -31,7 +34,7 @@ class MyApp extends StatelessWidget {
class VisionFace extends StatefulWidget {
const VisionFace({
Key? key,
this.size = const Size(750,750),
this.size = const Size(640,480),
this.onScanned
}):super(key: key);

Expand All @@ -47,7 +50,9 @@ class _VisionFace extends State<VisionFace>{
late AppleVisionFaceController cameraController;
late List<CameraMacOSDevice> _cameras;
CameraMacOSController? controller;
CameraController? iosCameraController;
String? deviceId;
bool loading = true;

FaceData? faceData;
late double deviceWidth;
Expand All @@ -56,10 +61,17 @@ class _VisionFace extends State<VisionFace>{
@override
void initState() {
cameraController = AppleVisionFaceController();
CameraMacOS.instance.listDevices(deviceType: CameraMacOSDeviceType.video).then((value){
_cameras = value;
deviceId = _cameras.first.deviceId;
});

if(Platform.isMacOS){
CameraMacOS.instance.listDevices(deviceType: CameraMacOSDeviceType.video).then((value){
_cameras = value;
deviceId = _cameras.first.deviceId;
});
}
else{


}
super.initState();
}
@override
Expand Down Expand Up @@ -87,8 +99,8 @@ class _VisionFace extends State<VisionFace>{
return Stack(
children:<Widget>[
SizedBox(
width: 640,
height: 480,
width: widget.size.width,
height: widget.size.height,
child: _getScanWidgetByPlatform()
),
]+showPoints()
Expand Down Expand Up @@ -116,7 +128,7 @@ class _VisionFace extends State<VisionFace>{
widgets.add(
Positioned(
left: points[j].x,
top: 480-points[j].y,
top: points[j].y,
child: Container(
width: 10,
height: 10,
Expand All @@ -132,20 +144,43 @@ class _VisionFace extends State<VisionFace>{
return widgets;
}

Future<bool> onCameraInizialized() async{
Completer<bool> c = Completer<bool>();

await availableCameras().then((value) async{
iosCameraController = CameraController(value[0], ResolutionPreset.max);
print('here');
await iosCameraController!.initialize().then((value){
setState(() {
loading = false;
});
c.complete(true);
}).onError((error, stackTrace){
c.complete(false);
});
});

return c.future;
}

Widget loadingWidget(){
return Container(
width: widget.size.width,
height: widget.size.height,
color: Theme.of(context).canvasColor,
alignment: Alignment.center,
child: const CircularProgressIndicator(color: Colors.blue)
);
}

Widget _getScanWidgetByPlatform() {
return CameraMacOSView(
return Platform.isMacOS?CameraMacOSView(
key: cameraKey,
fit: BoxFit.fill,
cameraMode: CameraMacOSMode.photo,
enableAudio: false,
onCameraLoading: (ob){
return Container(
width: 640,
height: 480,
color: Theme.of(context).canvasColor,
alignment: Alignment.center,
child: const CircularProgressIndicator(color: Colors.blue)
);
return loadingWidget();
},
onCameraInizialized: (CameraMacOSController controller) {
setState(() {
Expand All @@ -155,6 +190,14 @@ class _VisionFace extends State<VisionFace>{
});
});
},
):FutureBuilder<bool>(
future: onCameraInizialized(),
builder: (BuildContext context, AsyncSnapshot<bool> snapshot) {
return loading?loadingWidget():CameraPreview(
iosCameraController!,
key: cameraKey,
);
}
);
}
}
Loading

0 comments on commit 797f43c

Please sign in to comment.