|
1 |
| -<!-- |
2 |
| -This README describes the package. If you publish this package to pub.dev, |
3 |
| -this README's contents appear on the landing page for your package. |
| 1 | +# Ensemble Camera Module |
4 | 2 |
|
5 |
| -For information about how to write a good package README, see the guide for |
6 |
| -[writing package pages](https://dart.dev/guides/libraries/writing-package-pages). |
| 3 | +Ensemble Camera is a Flutter package that extends the capabilities of the [Ensemble](https://github.com/EnsembleUI/ensemble) framework by providing a comprehensive camera module. It simplifies the integration of camera functionalities into your app with features such as photo and video capture, QR code scanning, and face detection. With customizable options and built-in sensor support, Ensemble Camera allows you to create engaging, camera-driven experiences quickly. |
7 | 4 |
|
8 |
| -For general information about developing packages, see the Dart guide for |
9 |
| -[creating packages](https://dart.dev/guides/libraries/create-library-packages) |
10 |
| -and the Flutter guide for |
11 |
| -[developing packages and plugins](https://flutter.dev/developing-packages). |
12 |
| ---> |
| 5 | +## Features |
13 | 6 |
|
14 |
| -TODO: Put a short description of the package here that helps potential users |
15 |
| -know whether this package might be useful for them. |
| 7 | +- **Photo & Video Capture** |
| 8 | + - Capture photos and videos using both a default camera interface and a bespoke, customizable camera view. |
| 9 | + - Supports front/back camera selection, flash control, and camera rotation. |
| 10 | + - Options for gallery image picking and auto-capture intervals. |
16 | 11 |
|
17 |
| -## Features |
| 12 | +- **QR Code Scanning** |
| 13 | + - Integrated QR code scanner using the `qr_code_scanner` package. |
| 14 | + - Customizable overlay, scan area, and scanning actions. |
| 15 | + - Built-in methods to flip the camera, toggle flash, pause, and resume scanning. |
| 16 | + |
| 17 | +- **Face Detection** |
| 18 | + - Face detection support powered by the `face_camera` package. |
| 19 | + - Real-time face detection with auto-capture capabilities. |
| 20 | + - Customizable UI controls and messages to guide users during face capture. |
| 21 | + |
| 22 | +- **Sensor Integration** |
| 23 | + - Utilizes device sensors (accelerometer and geolocation) to assist with camera orientation and to improve capture conditions. |
18 | 24 |
|
19 |
| -TODO: List what your package can do. Maybe include images, gifs, or videos. |
| 25 | +- **Seamless Ensemble Integration** |
| 26 | + - Leverages Ensemble actions and data contexts for streamlined binding and event handling. |
| 27 | + - Easy to configure via provided controllers and setter methods. |
20 | 28 |
|
21 |
| -## Getting started |
| 29 | +## Getting Started |
22 | 30 |
|
23 |
| -TODO: List prerequisites and provide or point to information on how to |
24 |
| -start using the package. |
| 31 | +### Prerequisites |
| 32 | + |
| 33 | +- **Flutter SDK:** >= 3.24.0 |
| 34 | +- **Dart SDK:** >= 3.5.0 |
| 35 | + |
| 36 | +### Installation |
| 37 | + |
| 38 | +Add the following dependency to your `pubspec.yaml`: |
| 39 | + |
| 40 | +```yaml |
| 41 | +dependencies: |
| 42 | + ensemble_camera: |
| 43 | + git: |
| 44 | + url: https://github.com/EnsembleUI/ensemble.git |
| 45 | + ref: main # or a specific version |
| 46 | + path: modules/camera |
| 47 | +``` |
| 48 | +
|
| 49 | +Then run: |
| 50 | +
|
| 51 | +```bash |
| 52 | +flutter pub get |
| 53 | +``` |
| 54 | + |
| 55 | +### Permissions |
| 56 | + |
| 57 | +Make sure to configure the necessary permissions for camera, microphone, and location access in your project for Android and iOS. |
25 | 58 |
|
26 | 59 | ## Usage
|
27 | 60 |
|
28 |
| -TODO: Include short and useful examples for package users. Add longer examples |
29 |
| -to `/example` folder. |
| 61 | +Below are some basic examples to help you get started: |
| 62 | + |
| 63 | +### Photo & Video Capture |
30 | 64 |
|
31 | 65 | ```dart
|
32 |
| -const like = 'sample'; |
| 66 | +import 'package:ensemble_camera/ensemble_camera.dart'; |
| 67 | +
|
| 68 | +// Example: Using the default camera for photo capture |
| 69 | +void openDefaultCamera(BuildContext context, ScopeManager scopeManager) { |
| 70 | + ShowCameraAction cameraAction = ShowCameraAction( |
| 71 | + options: { |
| 72 | + 'mode': 'photo', |
| 73 | + 'initialCamera': 'back', |
| 74 | + 'allowFlashControl': true, |
| 75 | + // Additional options can be configured here |
| 76 | + }, |
| 77 | + onComplete: () { |
| 78 | + // Handle capture completion |
| 79 | + }, |
| 80 | + ); |
| 81 | + CameraManagerImpl().openCamera(context, cameraAction, scopeManager); |
| 82 | +} |
| 83 | +``` |
| 84 | + |
| 85 | +### QR Code Scanner |
| 86 | + |
| 87 | +```dart |
| 88 | +import 'package:ensemble_camera/ensemble_camera.dart'; |
| 89 | +
|
| 90 | +// Example: Instantiating the QR code scanner widget |
| 91 | +final qrScannerWidget = EnsembleQRCodeScannerImpl.build(myQRCodeScannerController); |
| 92 | +``` |
| 93 | + |
| 94 | +### Face Detection |
| 95 | + |
| 96 | +```dart |
| 97 | +import 'package:ensemble_camera/ensemble_camera.dart'; |
| 98 | +
|
| 99 | +// Example: Using the Face Detection Camera widget |
| 100 | +FaceDetectionCamera( |
| 101 | + onCapture: (path) { |
| 102 | + // Process the captured face image path |
| 103 | + }, |
| 104 | + onError: (error) { |
| 105 | + // Handle any errors during face detection |
| 106 | + }, |
| 107 | +); |
| 108 | +``` |
| 109 | + |
| 110 | +## Usage with Ensemble |
| 111 | + |
| 112 | +Ensemble Camera can be easily integrated with the Ensemble framework to create dynamic, camera-driven experiences. Below is an example of how to use Ensemble actions to open the camera with specific options and display the captured image in a dialog: |
| 113 | + |
| 114 | +```yaml |
| 115 | +openCamera: |
| 116 | + id: cameraWithOptions |
| 117 | + options: |
| 118 | + initialCamera: front |
| 119 | + faceDetection: |
| 120 | + enabled: true |
| 121 | + autoCapture: false |
| 122 | + message: "Align your face in the circle" |
| 123 | + messageStyle: |
| 124 | + color: "#FF0000" |
| 125 | + fontSize: 20 |
| 126 | + onCapture: |
| 127 | + showDialog: |
| 128 | + body: |
| 129 | + Image: |
| 130 | + source: ${cameraWithOptions.files[0].path} |
33 | 131 | ```
|
34 | 132 |
|
35 |
| -## Additional information |
| 133 | +## Contributing |
36 | 134 |
|
37 |
| -TODO: Tell users more about the package: where to find more information, how to |
38 |
| -contribute to the package, how to file issues, what response they can expect |
39 |
| -from the package authors, and more. |
| 135 | +Contributions are welcome! If you have ideas for improvements or find any issues, please fork the repository and submit a pull request. For major changes, it’s recommended to open an issue first to discuss your proposed changes. |
0 commit comments