Giter Club home page Giter Club logo

buyaka / camerawesome Goto Github PK

View Code? Open in Web Editor NEW

This project forked from apparence-io/camerawesome

0.0 0.0 0.0 101.55 MB

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

Home Page: https://pub.dev/packages/camerawesome

License: MIT License

Shell 0.35% Ruby 0.78% C 0.45% Objective-C 26.00% Java 2.63% MATLAB 0.02% Kotlin 20.59% Dart 49.10% Swift 0.08%

camerawesome's Introduction


CamerAwesome

๐Ÿ“ธ 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.

System Android iOS
๐Ÿ”– Ask permissions โœ… โœ…
๐ŸŽฅ Record video โœ… โœ…
๐Ÿ”ˆ Enable/disable audio โœ… โœ…
๐ŸŽž Take photos โœ… โœ…
๐ŸŒ† Photo live filters โœ… โœ…
๐ŸŒค Exposure level โœ… โœ…
๐Ÿ“ก Broadcast live image stream โœ… โœ…
๐Ÿ‘ Zoom โœ… โœ…
๐Ÿ“ธ Device flash support โœ… โœ…
โŒ›๏ธ Auto focus โœ… โœ…
๐Ÿ“ฒ Live switching camera โœ… โœ…
๐Ÿ˜ตโ€๐Ÿ’ซ Camera rotation stream โœ… โœ…
๐Ÿค Background auto stop โœ… โœ…
๐Ÿ”€ Sensor type switching โ›”๏ธ โœ…

๐Ÿ“–ย  Installation and usage

Add the package in your pubspec.yaml

dependencies:
  camerawesome: ^1.2.0
  ...

Set permissions

  • iOS add these on ios/Runner/Info.plist file
<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

รฌf 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>

Import the package in your Flutter app

import 'package:camerawesome/camerawesome_plugin.dart';

๐Ÿ‘Œ Awesome build-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);
    },
),

๐ŸŽจ Creating a custom interface

Our builder provides a custom factory.
Now you have access to the builder property and can create your own camera experience.
The camera preview will be visible behind what you will provide to our builder.

Note
Only the camera preview is not customizable yet

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 camerAwesome states works ?

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 ๐Ÿคฉ

You can check examples using MLKit inside the example directory. ai_analysis_faces.dart is used to detect faces and ai_analysis_barcode.dart to read barcodes.

CameraAwesomeBuilder.awesome(
    saveConfig: SaveConfig.image(
        pathBuilder: _path(),
    ),
onImageForAnalysis: analyzeImage,
imageAnalysisConfig: AnalysisConfig(
outputFormat: InputAnalysisImageFormat.nv21, // choose between jpeg / nv21 / yuv_420 / bgra8888
width: 1024,
maxFramesPerSecond
:
30
,
)
,
),

MLkit recommands to use nv21 format for Android.
bgra8888 is the iOS format For machine learning you don't need full resolution images (1024 or lower should be enough and makes computation easier)

See more in documentation


๐Ÿฝ Setting sensors settings

Through state you can access to a SensorConfig class.

Function Comment
setZoom changing zoom
setFlashMode changing flash between NONE,ON,AUTO,ALWAYS
setBrightness change brightness level manually (better to let this auto)

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.


camerawesome's People

Contributors

acoutts avatar apalala-dev avatar dimapparence avatar g-apparence avatar iadept avatar istornz avatar jo-apparence avatar liquidiert avatar mdpe-ir avatar mr- avatar snimm avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.