Giter VIP home page Giter VIP logo

camera_macos's Introduction

Camera macOS

Implementation of AVKit camera for macOS. Does basic things. Feel free to fork this repository and improve it!

Getting Started


Basic usage

How to use

Integrate CameraMacOSView in your widget tree. You can choose a fit method and a CameraMacOSMode (picture or video). When the camera is initialized, a CameraMacOSController object is created and can be used to do basic things such as taking pictures and recording videos.

final GlobalKey cameraKey = GlobalKey("cameraKey");
late CameraMacOSController macOSController;


//... build method ...

CameraMacOSView(
    key: cameraKey,
    fit: BoxFit.fill,
    cameraMode: CameraMacOSMode.picture,
    onCameraInizialized: (CameraMacOSController controller) {
        setState(() {
            this.macOSController = controller;
        });
    },
),

Take a picture

CameraMacOSFile? file = await macOSController.takePicture();
if(file != null) {
    Uint8List? bytes = file.bytes;
    // do something with the file...
}

Record a video

await macOSController.recordVideo(
    url: // get url from packages such as path_provider,
    maxVideoDuration: 30, // 30 seconds
    onVideoRecordingFinished: (CameraMacOSFile? file, CameraMacOSException? exception) {
        // called when maxVideoDuration has been reached
        // do something with the file or catch the exception
    });
);

CameraMacOSFile? file = await macOSController.stopVideoRecording();

if(file != null) {
    Uint8List? bytes = file.bytes;
    // do something with the file...
}

Notes

  • If you change the widget Key or the CameraMacOsMode, the widget will reinitialize.
  • The package supports macOS 10.11 and onwards.

Video settings

Default videos settings (currently locked) are:

  • 1980x1080 resolution
  • ac1 audio
  • mp4 format

You can set a maximum video duration (in seconds) for recording videos. A native timer will fire after time has passed. You can also set a file location. Default is in the Library/Cache directory of the application.

Output

After a video or a picture is taken, a CameraMacOSFile object is generated, containing the bytes of the content. If you specify a url for a video, it will return back also the file location.

Limitations and notes

  • The plugin is just a temporary substitutive package for the official Flutter team's camera package. It will work only on macOS.
  • Focus and orientation change are currently unsupported
  • Video Recording resolution is currently not supported

License

MIT

camera_macos's People

Contributors

rlomazzimitric avatar riccardo-lomazzi 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.