A flutter plugin to integrate awesome Android / iOS camera experience

CamerAwesome

Awesome FlutterStar on GithubStar on Github

๐Ÿ“ธ Embedding a camera experience within your own app shouldโ€™t be that hard. A flutter plugin to integrate awesome Android / iOS camera experience.


This packages provides you a fully customizable camera experience that you can use within your app. Use our awesome built in interface or customize it as you want.


Native features

Hereโ€™s all native features that cameraAwesome provides to the flutter side.

SystemAndroidiOS๐Ÿ”– Ask permissionsโœ…โœ…๐ŸŽฅ Record videoโœ…โœ…๐Ÿ”ˆ Enable/disable audioโœ…โœ…๐ŸŽž Take photosโœ…โœ…๐ŸŒ† Photo live filtersโœ…โœ…๐ŸŒค Exposure levelโœ…โœ…๐Ÿ“ก Broadcast live image streamโœ…โœ…๐Ÿงช Image analysis (barcode scan & more.)โœ…โœ…๐Ÿ‘ Zoomโœ…โœ…๐Ÿ“ธ Device flash supportโœ…โœ…โŒ›๏ธ Auto focusโœ…โœ…๐Ÿ“ฒ Live switching cameraโœ…โœ…๐Ÿ˜ตโ€๐Ÿ’ซ Camera rotation streamโœ…โœ…๐Ÿค Background auto stopโœ…โœ…๐Ÿ”€ Sensor type switchingโ›”๏ธโœ…๐Ÿชž Enable/disable front camera mirroringโœ…โœ…


๐Ÿ“– Installation and usage

Add the package in your pubspec.yaml

dependencies:
  camerawesome: ^1.3.0
  ...

Platform specific setup

  • iOS

Add these on ios/Runner/Info.plist:

<key>NSCameraUsageDescription</key>
<string>Your own description</string>

<key>NSMicrophoneUsageDescription</key>
<string>To enable microphone access when recording video</string>

<key>NSLocationWhenInUseUsageDescription</key>
<string>To enable GPS location access for Exif data</string>
  • Android

Change the minimum SDK version to 21 (or higher) in android/app/build.gradle:

minSdkVersion 21

In order to be able to take pictures or record videos, you may need additional permissions depending on the Android version and where you want to save them. Read more about it in the official documentation.

WRITE_EXTERNAL_STORAGE is not included in the plugin starting with version 1.4.0.

If you want to record videos with audio, add this permission to your AndroidManifest.xml:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
        package="com.example.yourpackage">
  <uses-permission android:name="android.permission.RECORD_AUDIO" />

  <!-- Other declarations -->
</manifest>

You may also want to save location of your pictures in exif metadata. In this case, add below permissions:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.yourpackage">
  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

  <!-- Other declarations -->
</manifest>

โš ๏ธ Overriding Android dependencies


Import the package in your Flutter app

import 'package:camerawesome/camerawesome_plugin.dart';

๐Ÿ‘Œ Awesome built-in interface

Just use our builder. Thatโ€™s all you need to create a complete camera experience within you app.

CameraAwesomeBuilder.awesome(
  saveConfig: SaveConfig.image(
    pathBuilder: _path(),
  ),
  onMediaTap: (mediaCapture) {
    OpenFile.open(mediaCapture.filePath);
  },
),

CamerAwesome default UI

This builder can be customized with various settings:

  • a theme
  • builders for each part of the screen
  • initial camera setup
  • preview positioning
  • additional preview decoration
  • and more!

Here is an example:

Customized UI

Check the full documentation to learn more.


๐ŸŽจ Creating a custom interface

If the awesome() factory is not enough, you can use custom() instead.


It provides a builder property that lets you create your own camera experience.


The camera preview will be visible behind what you will provide to the builder.

CameraAwesomeBuilder.custom(
  saveConfig: SaveConfig.image(pathBuilder: _path()),
  builder: (state, previewSize, previewRect) {
    // create your interface here
  },
)
See more in documentation

Working with the custom builder

Here is the definition of our builder method.

typedef CameraLayoutBuilder = Widget Function(CameraState cameraState, PreviewSize previewSize, Rect previewRect);

The only thing you have access to manage the camera is the cameraState. Depending on which state is our camera experience you will have access to some different method. `previewSize` and `previewRect` might be used to position your UI around or on top of the camera preview.

How do CamerAwesome states work ?

Using the state you can do anything you need without having to think about the camera flow

  • On app start we are in PreparingCameraState
  • Then depending on the initialCaptureMode you set you will be PhotoCameraState or VideoCameraState
  • Starting a video will push a VideoRecordingCameraState
  • Stopping the video will push back the VideoCameraState
  • Also if you want to use some specific function you can use the when method so you can write like this.
state.when(
  onPhotoMode: (photoState) => photoState.start(),
  onVideoMode: (videoState) => videoState.start(),
  onVideoRecordingMode: (videoState) => videoState.pause(),
);
See more in documentation

๐Ÿ”ฌ Analysis mode

Use this to achieve:

  • QR-Code scanning.
  • Facial recognition.
  • AI object detection.
  • Realtime video chats. And much more ๐Ÿคฉ

Face AI

You can check examples using MLKit inside the example directory. The above example is from ai_analysis_faces.dart. It detects faces and draw their contours.

Itโ€™s also possible to use MLKit to read barcodes:

Barcode scanning

Check ai_analysis_barcode.dart and preview_overlay_example.dart for examples or the documentation.

How to use it

CameraAwesomeBuilder.awesome(
  saveConfig: SaveConfig.image(
    pathBuilder: _path(),
  ),
  onImageForAnalysis: analyzeImage,
  imageAnalysisConfig: AnalysisConfig(
        // Android specific options
        androidOptions: const AndroidAnalysisOptions.nv21(
            // Target width (CameraX will chose the closest resolution to this width)
            width: 250,
        ),
        // Wether to start automatically the analysis (true by default)
        autoStart: true,
        // Max frames per second, null for no limit (default)
        maxFramesPerSecond: 20,
    ),
MLkit recommands to use nv21 format for Android. bgra8888 is the iOS format For machine learning you donโ€™t need full resolution images (720 or lower should be enough and makes computation easier)

Learn more about the image analysis configuration in the documentation .


Check also detailed explanations on how to use MLKit to read barcodes and detect faces.


โš ๏ธ On Android, some devices donโ€™t support video recording and image analysis at the same time.

  • If they donโ€™t, image analysis will be ignored.
  • You can check if a device has this capability by using CameraCharacteristics .isVideoRecordingAndImageAnalysisSupported(Sensors.back).

๐Ÿฝ Updating Sensor configuration

Through state you can access to a SensorConfig class.

FunctionCommentsetZoomchanging zoomsetFlashModechanging flash between NONE,ON,AUTO,ALWAYSsetBrightnesschange brightness level manually (better to let this auto)setMirrorFrontCameraset mirroring for front camera

All of this configurations are listenable through a stream so your UI can automatically get updated according to the actual configuration.

๐ŸŒ† Photo live filters

Apply live filters to your pictures using the built-in interface:

Built-in live filters

You can also choose to use a specific filter from the start:

CameraAwesomeBuilder.awesome(
  // other params
  filter: AwesomeFilter.AddictiveRed,
)

Or set the filter programmatically:

CameraAwesomeBuilder.custom(
  builder: (cameraState, previewSize, previewRect) {
    return cameraState.when(
      onPreparingCamera: (state) =>
      const Center(child: CircularProgressIndicator()),
      onPhotoMode: (state) =>
          TakePhotoUI(state, onFilterTap: () {
            state.setFilter(AwesomeFilter.Sierra);
          }),
      onVideoMode: (state) => RecordVideoUI(state, recording: false),
      onVideoRecordingMode: (state) =>
          RecordVideoUI(state, recording: true),
    );
  },
)

See all available filters in the documentation.

GitHub

View Github

Related Posts

Popular Posts

BrowserVideoEdit: A feature-rich video editor created using fabric.js and Next.js, all within the convenience of your web browser

A weather app that allows users to view real-time weather information based on their locations

Add Login and Register page into your Nuxt 3 project using Supabase authentication

A powerful Flutter package that allows you to easily create and control glitch effects

เด’เดฐเต‡เดฆเดฟเดตเดธเด‚ เดฐเดฃเตเดŸเตเดชเต‡เดฐเต†เดฏเตเด‚ เดชเต†เดฃเตเดฃเตเด•เดฃเตเดŸเต, เด•เต‹เดŸเตเดŸเดฏเด‚ เดชเต‚เดžเตเดžเดพเดฐเตโ€ เดธเตเดตเดฆเต‡เดถเดฟเดฏเดพเดฏ เดฆเดจเตเดคเดกเต‹เด•เตเดŸเดฑเตเดฎเดพเดฏเดฟ เดตเดฟเดตเดพเดนเด‚ เดฐเดœเดฟเดธเตเดฑเตเดฑเตผ เดšเต†เดฏเตเดคเต , เดชเดฟเดจเตเดจเต€เดŸเต เดตเต‡เดฃเตเดŸเต†เดจเตเดจเตเดตเต†เดšเตเดšเต.

A Library for Rendering 3D Models in React.js and Next.js Views

Recent Posts

เด‡เดŸเตเด•เตเด•เดฟเดฏเดฟเดฒเต† เดฎเดฒเดฏเต‹เดฐ เดฎเต‡เด–เดฒเด•เดณเดฟเตฝ เดฐเดพเดคเตเดฐเดฟเดฏเดพเดคเตเดฐ เดจเดฟเดฐเต‹เดงเดฟเดšเตเดšเต. เดฐเดพเดคเตเดฐเดฟ เดเดดเต เดฎเตเดคเตฝ เดฐเดพเดตเดฟเดฒเต† เด†เดฑเต เดตเดฐเต†เดฏเดพเดฃเต เดจเดฟเดฐเต‹เดงเดจเด‚

เดเดจเตเดคเดฏเดพเตผ เดˆเดธเตเดฑเตเดฑเดฟเตฝ เดชเตเดฐเดณเดฏเดคเตเดคเดฟเตฝ เดคเด•เตผเดจเตเดจ เดชเดพเดฒเดคเตเดคเดฟเดจเต เดชเด•เดฐเด‚ เดชเตเดคเดฟเดฏ เดชเดพเดฒเด‚ เดจเดฟเตผเดฎเตเดฎเดฟเด•เตเด•เตเดตเดพเตป เดคเดพเดคเตเด•เตเด•เดพเดฒเดฟเด• เดชเดพเดฒเด‚ เดชเตŠเดณเดฟเดšเตเดšเต เดจเต€เด•เตเด•เดฟ

Explore the Investment Opportunities: A Comprehensive Guide to Different Types of Mutual Funds

Title: Understanding Mutual Funds: A Beginner's Guide to Investing

เดคเต€เดตเตเดฐเดฎเดด เดฎเตเดจเตเดจเดฑเดฟเดฏเดฟเดชเตเดชเดฟเดจเตเดฑเต† เดชเดถเตเดšเดพเดคเดฒเดคเตเดคเดฟเตฝ เดธเด‚เดธเตเดฅเดพเดจเด‚ เดœเดพเด—เตเดฐเดคเดฏเดฟเตฝ

250,000 เด…เดชเต‡เด•เตเดทเด•เตพ เดตเตผเดฆเตเดงเดฟเดšเตเดšเดคเดฟเดจเดพเตฝ เดŸเตเดฐเดพเตปเดธเตโ€Œเดชเต‹เตผเดŸเตเดŸเต เด•เดฎเตเดฎเต€เดทเดฃเตผ เดชเดฐเดฟเดถเต‹เดงเดจ เดชเตเดจเดฐเดพเดฐเด‚เดญเดฟเด•เตเด•เตเด‚

เดเดฒเด•เตเด•เดฏเดฟเตฝ เด•เต€เดŸเดจเดพเดถเดฟเดจเดฟ เดธเดพเดจเตเดจเดฟเดงเตเดฏเด‚; เด†เดฑเดฐ เดฒเด•เตเดทเดคเตเดคเดฟเดฒเดงเดฟเด•เด‚ เดŸเดฟเตป เด…เดฐเดตเดฃ เดจเดถเดฟเดชเตเดชเดฟเด•เตเด•เดพเตป เดŸเต†เตปเดกเตผ เด•เตเดทเดฃเดฟเดšเตเดšเต เดฆเต‡เดตเดธเตเดตเด‚ เดฌเต‹เตผเดกเตโ€Œ

เดญเต€เดฎเตป เดชเดพเดฑเด•เตเด•เดทเดฃเด™เตเด™เตพ เด…เดŸเตผเดจเตเดจเต เดฆเต‡เดถเต€เดฏ เดชเดพเดคเดฏเดฟเดฒเต‡เด•เตเด•เต เดตเต€เดดเตเดจเตเดจเดคเต เดชเดคเดฟเดตเดพเด•เตเดจเตเดจเต. เด•เตเดŸเตเดŸเดฟเด•เตเด•เดพเดจเดคเตเดคเดฟเดจเตเด‚ เดฎเตเดฃเตเดŸเด•เตเด•เดฏเดคเตเดคเดฟเดจเตเดฎเดฟเดŸเดฏเดฟเตฝ เดจเดฟเดฒเดจเดฟเตฝเด•เตเด•เตเดจเตเดจเดคเต เดตเตป เด…เดชเด•เดŸ เดญเต€เดทเดฃเดฟ

เดšเด•เตเดฐเดตเดพเดคเดšเตเดšเตเดดเดฟ:เด…เดคเดฟเดถเด•เตเดคเดฎเดพเดฏ เดฎเดด เดตเดฐเตเดจเตเดจเต

เดชเตเดฒเดธเต เดตเตบ เดชเตเดฐเดตเต‡เดถเดจเด‚. เด…เด•เตเดทเดฏเดฏเดฟเตฝ เดคเดฟเด•เตเด•เดฟ เดคเดฟเดฐเด•เตเด•เต‡เดฃเตเดŸ, เดจเต†เดฑเตเดฑเดฟเดตเดฟเดฑเตเดฑเดฟ/เดœเดพเดคเดฟ เดคเต†เดณเดฟเดฏเดฟเด•เตเด•เดพเตป เดชเดคเตเดคเดพเด‚เดคเดฐเด‚ เดธเตผเดŸเตเดŸเดฟเดซเดฟเด•เตเด•เดฑเตเดฑเต เดฎเดคเดฟ