Git Product home page Git Product logo

camera_awesome's Introduction

camerawesome_logo

Awesome Flutter

๐Ÿš€ย  Overview

Flutter plugin to add Camera support inside your project.

CamerAwesome include a lot of useful features like:

  • ๐Ÿ“ฒ Live camera flip ( switch between rear & front camera without rebuild ).
  • โšก๏ธ No init needed, just add CameraAwesome widget !
  • โŒ›๏ธ Instant focus.
  • ๐Ÿ“ธ Device flash support.
  • ๐ŸŽš Zoom.
  • ๐Ÿ–ผ Fullscreen or SizedBox preview support.
  • ๐ŸŽฎ Complete example.
  • ๐ŸŽž Taking a picture ( of course ๐Ÿ˜ƒ ).

๐Ÿ“–ย  Installation and usage

Set permissions

  • iOS add these on ios/Runner/Info.plist file
<key>NSCameraUsageDescription</key>
<string>Your own description</string>
  • Android

    • Set permissions before <application>

    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    • Change the minimum SDK version to 21 (or higher) in android/app/build.gradle

    minSdkVersion 21
    

Import the package

import 'package:camerawesome/camerawesome_plugin.dart';

Define notifiers (if needed) & controller

ValueNotifier is a usefull change notifier from Flutter framework. It fires an event on all listener when value changes. Take a look here for ValueNotifier doc

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> with TickerProviderStateMixin {
  // [...]
  // Notifiers
  ValueNotifier<CameraFlashes> _switchFlash = ValueNotifier(CameraFlashes.NONE);
  ValueNotifier<Sensors> _sensor = ValueNotifier(Sensors.BACK);
  ValueNotifier<Size> _photoSize = ValueNotifier(null);

  // Controller
  PictureController _pictureController = new PictureController();
  // [...]
}

If you want to change a config, all you need is setting the value. CameraAwesome will handle the rest.

Example:

_switchFlash.value = CameraFlashes.AUTO

Create your camera

// [...]
@override
  Widget build(BuildContext context) {
    return CameraAwesome(
      testMode: false,
      onPermissionsResult: (bool result) { }
      selectDefaultSize: (List<Size> availableSizes) => Size(1920, 1080),
      onCameraStarted: () { },
      onOrientationChanged: (CameraOrientations newOrientation) { },
      zoom: 0.64,
      sensor: _sensor,
      photoSize: _photoSize,
      switchFlashMode: _switchFlash,
      orientation: DeviceOrientation.portraitUp,
      fitted: true,
    );
  };
// [...]
Reveal parameters list

Param Type Description Required
testMode boolean true to wrap texture
onPermissionsResult OnPermissionsResult implement this to have a callback after CameraAwesome asked for permissions
selectDefaultSize OnAvailableSizes implement this to select a default size from device available size list โœ…
onCameraStarted OnCameraStarted notify client that camera started
onOrientationChanged OnOrientationChanged notify client that orientation changed
switchFlashMode ValueNotifier<CameraFlashes> change flash mode
zoom ValueNotifier<double> Zoom from native side. Must be between 0 and 1
sensor ValueNotifier<Sensors> sensor to initiate BACK or FRONT โœ…
photoSize ValueNotifier<Size> choose your photo size from the [selectDefaultSize] method
orientation DeviceOrientation initial orientation
fitted bool whether camera preview must be as big as it needs or cropped to fill with. false by default
imagesStreamBuilder Function returns an imageStream when camera has started preview

Take a photo ๐ŸŽ‰

await _pictureController.takePicture('THE_IMAGE_PATH/myimage.jpg');

Live image stream

The property imagesStreamBuilder allows you to get an imageStream once the camera is ready. Don't try to show all these images on Flutter UI as you won't have time to refresh UI fast enough. (there is too much images/sec).

CameraAwesome(
    ...
    imagesStreamBuilder: (imageStream) {
        /// listen for images preview stream
        /// you can use it to process AI recognition or anything else...
        print("-- init CamerAwesome images stream");
    },
)

๐Ÿ“ฑย  Tested devices

CamerAwesome was developed to support most devices on the market but some feature can't be fully functional. You can check if your device support all feature by clicking bellow.

Feel free to contribute to improve this compatibility list.

Reveal grid

Devices Flash Focus Zoom Flip
iPhone X โœ… โœ… โœ… โœ…
iPhone 7 โœ… โœ… โœ… โœ…
One Plus 6T โœ… โœ… โœ… โœ…
Xiaomi redmi โœ… โœ… โœ… โœ…
Honor 7 โœ… โœ… โœ… โœ…

๐ŸŽฏย  Our goals

Feel free to help by submitting PR !

  • ๐ŸŽฅ Record video
  • ๐ŸŒ  Focus on specific point
  • ๐Ÿ“ก Broadcast live image stream
  • ๐ŸŒค Exposure level
  • Add e2e tests
  • Fullscreen/SizedBox support
  • Complete example
  • Take a picture
  • Zoom level
  • Live switching camera
  • Device flash support
  • Auto focus

Sponsor

Initiated and sponsored by Apparence.io.

๐Ÿ‘ฅย  Contribution

Contributions are welcome. Contribute by creating a PR or create an issue ๐ŸŽ‰.

camera_awesome's People

Watchers

 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.