Camera is a library for Android built using the Camera2 API.

Overview

Camera




Camera is a library for Android built using the Camera2 API.


The Camera2 API allows users to capture RAW images, i.e. unprocessed pixel data directly from the camera sensor that has not yet been converted into a format and colorspace typically used for displaying and storing images viewed by humans. The DngCreator class is provided as part of the Camera2 API as a utility for saving RAW images as DNG files.

Aim of this lib is to make the use of Camera2 APIs with Jetpack Compose easier.


This lib usees code from Camera2Basic sample by google.


⚠️ This library is still under development: Do not use this in production!


Gradle

Add the dependency below to your module's build.gradle file:

dependencies {
    implementation "com.binishmatheww:camera:<version>"
}

Note: Please make sure that your project uses Jetpack Compose 1.3.0, Compose Compiler 1.3.2, and Kotlin 1.7.20.


Usage

Use CameraPreviewLayout composable to preview frames from the camera. You must pass a CameraController to the composable. An instance of CameraController can be obtained using rememberCameraController(). By default, the CameraController will select the back facing camera.

ConstraintLayout(
    modifier = Modifier
       .fillMaxSize()
) {

                val (
                cameraPreviewLayoutConstraint,
                captureButtonConstraint
                ) = createRefs()

                val cameraController = rememberCameraController()

                val coroutineScope = rememberCoroutineScope()

                var isCaptureButtonEnabled by remember { mutableStateOf(true) }

                CameraPreviewLayout(
                    modifier = Modifier
                        .constrainAs(cameraPreviewLayoutConstraint){
                            linkTo(top = parent.top, bottom = parent.bottom)
                            linkTo(start = parent.start, end = parent.end)
                        },
                    cameraController = cameraController,
                )

                Button(
                    modifier = Modifier.constrainAs(captureButtonConstraint){
                        linkTo(start = parent.start, end = parent.end)
                        bottom.linkTo(parent.bottom, 24.dp)
                    },
                    enabled = isCaptureButtonEnabled,
                    onClick = {
                        coroutineScope.launch {

                            isCaptureButtonEnabled = false
                            cameraController.captureImage()
                            isCaptureButtonEnabled = true

                        }
                    }
                ) {

                    Text(
                        text = "Capture"
                    )

                }

}

Support

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub.

License

Copyright 2022 Binish Mathew

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    https://www.apache.org/licenses/LICENSE-2.0
    
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
 */
You might also like...
🧱  A tetris game fully built using Jetpack Compose
🧱 A tetris game fully built using Jetpack Compose

A tetris game fully built using Jetpack Compose, almost all UI elements are created by code, including the following app icon, which is also generated by Composable with @Preview.

🕒 A kinetic wall clock, built using Compose Desktop
🕒 A kinetic wall clock, built using Compose Desktop

🕒 klokk A kinetic wall clock, built using Compose Desktop. 🔮 Demo Watch full demo Watch Development - Behind the Scenes - Part 1 Watch Development -

This is a sample app(For beginners - App #1) built using Jetpack Compose
This is a sample app(For beginners - App #1) built using Jetpack Compose

This is a sample app(For beginners - App #1) built using Jetpack Compose. It is a simple - single screen app to demonstrate use of basic Jetpack Compose UI elements like Text, Image and Button & LazyColumn (Vertical Recyclerview). It also demonstrates how compose manages state with a Boolean State.

This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Compose.
This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Compose.

JetBMICalculator This is a sample app(For beginners - App #2) built using Jetpack Compose. It demonstrates the concept of State Hoisting in Jetpack Co

LearnCompose - A simple UI built using Jetpack Compose
LearnCompose - A simple UI built using Jetpack Compose

Compose course UI A simple UI built using Jetpack Compose. Consists of a list sc

❤️ A heart-shaped toggle switch component built using Jetpack Compose
❤️ A heart-shaped toggle switch component built using Jetpack Compose

heart-switch A heart-shaped toggle switch component built using Jetpack Compose. Inspired by Tore Bernhoft's I heart toggle Dribbble shot and Anatoliy

Facebook clone built using Jetpack Compose, Firebase Authentication and Firebase Firestore.

facebook-compose Facebook clone built using Jetpack Compose, Firebase Authentication and Firebase Firestore. Setup Create a Firebase project and add t

Morph is an Android library, written in Kotlin, built to work together with Jetpack Compose.
Morph is an Android library, written in Kotlin, built to work together with Jetpack Compose.

Morph Morph is an Android library, written in Kotlin, built to work together with Jetpack Compose. It allows you to transition any view to another vie

Simple app to consumer api movies with retrofit and save result in database with room using android jetpack
Simple app to consumer api movies with retrofit and save result in database with room using android jetpack

MoviesCompose Simple app to consumer api movies with retrofit and save result in database with room using android jetpack Instruccions Log Up in https

Releases(v0.0.1)
Owner
binishmatheww
Android developer
binishmatheww
Ecormmerce app built using Android latest UI framework - Compose UI and data coming from Fake Store API

BuyCart ?? Android shopping app built with Jetpack Compose consuming FAKE STORE API I am trying to learn and follow some standard Android architecture

Henry Udorji 4 Aug 5, 2022
Formula 1 app to show current Standings from a REST API.Built using jetpack compose and kotlin.

Formula1 Formula 1 app to show Standings fetching data from REST API ?? Screenshots Tech Stack. Kotlin - Kotlin is a programming language that can run

Ezra Kanake 5 Oct 28, 2022
Jetpack-compose-uis - A collection of some UIs using Jetpack Compose. built using Katalog

Jetpack Compose UIs This is a collection of some UIs using Jetpack Compose. It i

Mori Atsushi 3 Dec 15, 2022
Carol 12 Sep 25, 2022
JetMovies - built this project with Jetpack Compose and TheMovieDb API

JetMovies I built this project with Jetpack Compose and TheMovieDb API. Used: Jetpack Compose Coroutines, Flow, State Flow ViewModel Constraint Layout

Suat Zengin 7 Dec 15, 2022
An android library to highlight different features of the app built using Jetpack Compose.

An android library to highlight different features of the app built using Jetpack Compose.

Canopas Software 230 Dec 23, 2022
Jetpack Compose Boids | Flocking Insect 🐜. bird or Fish simulation using Jetpack Compose Desktop 🚀, using Canvas API 🎨

?? ?? ?? Compose flocking Ants(boids) ?? ?? ?? Jetpack compose Boids | Flocking Insect. bird or Fish simulation using Jetpack Compose Desktop ?? , usi

Chetan Gupta 38 Sep 25, 2022
JetFlix - A clone of Android NetFlix app in Android built using Jetpack compose.

JetFlix A clone of Android NetFlix app in Android built using Jetpack compose. This sample app showcases the following: MVVM Architecture (ViewModel +

Pushpal Roy 40 Dec 6, 2022
Instagram Clone built in Android using concept of Jetpack compose.

Instagram_Clone Instagram clone is an app build using new technologies/trends and other advanced Jetpack compose specific concepts. Following are the

raj narayan mishra 4 Dec 2, 2022
This app can be used to track open slots for vaccination. This is built using Jetpack Compose.

Covid Vaccine This projects used the Cowin APIs provided by the government. Screenshots Tech Stack Used Kotlin Dagger Hilt Clean Architecture with Mod

Himanshu Singh 101 Dec 15, 2022