My Flutter Package
A Flutter package for image processing that detects and crops faces from images. This package provides a simple and efficient API for face detection and cropping using advanced computer vision algorithms.
Features
- Face Detection: Detects faces in images and returns their bounding boxes.
- Face Cropping: Crops detected faces and returns them as separate image segments.
Installation
To use this package, add it to your pubspec.yaml
file:
Future<void> detectFace() async {
try {
final ByteData data = await rootBundle.load('assets/male.jpg');
final Uint8List imageData = data.buffer.asUint8List();
final result = await FaceAnalyzer.instance.detectFaces(image: imageData);
setState(() {
bytesList = result.cast<Uint8List>();
});
} on PlatformException catch (e) {
debugPrint(e.toString());
}
}
dependencies:
face_analyzer: 0.0.6
# add this line:
$iOSVersion = '15.5'
target 'Runner' do
use_frameworks!
# add this line:
pod 'GoogleMLKit/FaceDetection', '8.0.0'
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
target 'RunnerTests' do
inherit! :search_paths
end
end
post_install do |installer|
# add these lines:
installer.pods_project.build_configurations.each do |config|
config.build_settings["EXCLUDED_ARCHS[sdk=*]"] = "armv7"
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
end
installer.pods_project.targets.each do |target|
flutter_additional_ios_build_settings(target)
# add these lines:
target.build_configurations.each do |config|
if Gem::Version.new($iOSVersion) > Gem::Version.new(config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'])
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = $iOSVersion
end
end
end
end
Let me know if you'd like help updating the usage section, adding example code, or publishing it to pub.dev
.