Description
CameraViewEx makes integration of camera implementation and various camera features into any Android project very easy.
Requires API Level 14. The library uses Camera 1 API on API Level 14-20 and Camera2 on 21 and above.
CameraViewEx alternatives and similar packages
Based on the "Kotlin" category.
Alternatively, view CameraViewEx alternatives based on common mentions on social networks and blogs.
-
CalendarView
A highly customizable calendar view and compose library for Android and Kotlin Multiplatform. -
Balloon
:balloon: Modernized and sophisticated tooltips, fully customizable with an arrow and animations for Android. -
kotlin-android-template
Android + Kotlin + Github Actions + ktlint + Detekt + Gradle Kotlin DSL + buildSrc = โค๏ธ -
NotyKT ๐๏ธ
๐ NotyKT is a complete ๐Kotlin-stack (Backend + Android) ๐ฑ application built to demonstrate the use of Modern development tools with best practices implementation๐ฆธ. -
Material Chip View
Material Chip view. Can be used as tags for categories, contacts or creating text clouds -
DrawableToolbox
๐ ๏ธ The missing drawable toolbox for Android. Create drawables programmatically and get rid of the boring and always repeated drawable.xml files. -
Navigation Toolbar for Android
:octocat: Navigation toolbar is a slide-modeled UI navigation controller made by @Ramotion -
Pdf Viewer For Android
A Lightweight PDF Viewer Android library which only occupies around 80kb while most of the Pdf viewer occupies up to 16MB space. -
Capturable
๐Jetpack Compose utility library for capturing Composable content and transforming it into Bitmap Image๐ผ๏ธ -
SSComposeCookBook
A Collection of major Jetpack compose UI components which are commonly used.๐๐๐ -
Pluto Debug Framework
Android Pluto is a on-device debugging framework for Android applications, which helps intercept Network calls, capture Crashes & ANRs, manipulate application data on-the-go, and much more. -
Carousel Recyclerview
Carousel Recyclerview let's you create carousel layout with the power of recyclerview by creating custom layout manager. -
CrunchyCalendar โ awesome calendar widget for android apps
A beautiful material calendar with endless scroll, range selection and a lot more! -
Permission Flow for Android
Know about real-time state of a Android app Permissions with Kotlin Flow APIs. -
SSCustomBottomNavigation
Animated TabBar with native control and Jetpack Navigation support..โจ๐๐ -
Only
:bouquet: An easy way to persist and run code block only as many times as necessary on Android. -
Nextflix-Composable
Includes jetpack compose, navigation, paging, hilt, retrofit, coil, coroutines, flow.. -
EasyPermissions-ktx
๐ Kotlin version of the popular google/easypermissions wrapper library to simplify basic system permissions logic on Android M or higher. -
Compose Compiler Reports to HTML Generator
A utility (Gradle Plugin + CLI) to convert Jetpack Compose compiler metrics and reports to beautified HTML page. -
FlowMVI
A Kotlin Multiplatform MVI library based on coroutines with a rich DSL and a powerful plugin system. -
Events Calendar
Events Calendar is a user-friendly library that helps you achieve a cool Calendar UI with events mapping. You can customise every pixel of the calendar as per your wish and still achieve in implementing all the functionalities of the native android calendar in addition with adding dots to the calendar which represents the presence of an event on the respective dates. It can be done easily, you are just a few steps away from implementing your own badass looking Calendar for your very own project! -
MidJourney Images Compose Multiplatform Mobile Application
This application is developed to display the images created by MidJourney. The application is developed with Compose Multiplatform and works on many platforms including Android and iOS platforms. -
SSCustomEditTextOutLineBorder
Same as the Outlined text fields presented on the Material Design page but with some dynamic changes. ๐ ๐ -
Bytemask
Android Gradle Plugin that masks secret strings for the app in the source code making it difficult to extract from reverse engineering. -
TimelineView
A customizable and easy-to-use Timeline View library for Android. Works as a RecyclerView decorator (ItemDecoration)
CodeRabbit: AI Code Reviews for Developers
Do you think we are missing an alternative of CameraViewEx or a related project?
README
CameraViewEx
This is an extended version of Google's cameraview library with better stability and many more features.
CameraViewEx highly simplifies integration of camera implementation and various camera features into any Android project. It uses new camera2 api with advanced features on API level 21 and higher and smartly switches to camera1 on older devices (API < 21).
Minimum API 14 is required to use CameraViewEx.
API Level | Camera API | Preview View |
---|---|---|
14-20 | Camera1 | TextureView |
21+ | Camera2 | TextureView |
Why another camera library?
Every camera library out there has some issues. Some good ones uses only camera1 api which cannot give best performance possible with today's devices, some are not updated anymore, some does not have all the features while some has a lot of features but uses complex api. CameraViewEx tries to solve all these issues while providing simpler api and more features.
Features
- High quality image capture
- Multiple camera modes like single capture, continuous frame, and video capture
- Ability to enable all or multiple modes simultaneously
- Preview frame listener
- Any size preview
- Customizable continuous frame and single capture output size (different from preview size and aspect ratio)
- Support multiple formats for output images like jpeg, yuv_420_888, rgba_8888
- Pinch to zoom
- Touch to focus
- Configurable auto white balance, auto focus, flash, noise reduction, and optical / video stabilization
- Highly configurable video recording with most of the options from MediaRecorder
- Support multiple aspect ratios
- Switch between front and back camera
- Adjustable output image quality
- Zero shutter lag mode
- Shutter animation for single capture
jcenter() to mavenCentral() migration
Change the import from,
implementation "com.priyankvasa.android:cameraview-ex:3.5.5-alpha"
to
implementation "dev.priyankvasa.android:cameraview-ex:3.5.5-alpha"
The top level domain has changed from com
to dev
.
Only the following versions are migrated
Usage
Import dependency
In app build.gradle,
dependencies {
// ...
implementation "com.priyankvasa.android:cameraview-ex:3.5.5-alpha"
}
In layout xml
<com.priyankvasa.android.cameraviewex.CameraView
android:id="@+id/camera"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:keepScreenOn="true"
app:aspectRatio="4:3"
app:autoFocus="continuous_picture"
app:awb="auto"
app:cameraMode="single_capture"
app:continuousFrameSize="W1440,1080"
app:facing="back"
app:flash="auto"
app:jpegQuality="high"
app:noiseReduction="high_quality"
app:opticalStabilization="true"
app:outputFormat="jpeg"
app:pinchToZoom="true"
app:shutter="short_time"
app:singleCaptureSize="1920,H1080"
app:touchToFocus="true"
app:zsl="true" />
Setup camera
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
// Callbacks on UI thread
camera.addCameraOpenedListener { /* Camera opened. */ }
.addCameraErrorListener { t: Throwable, errorLevel: ErrorLevel -> /* Camera error! */ }
.addCameraClosedListener { /* Camera closed. */ }
}
override fun onResume() {
super.onResume()
camera.start()
}
override fun onPause() {
camera.stop()
super.onPause()
}
override fun onDestroyView() {
camera.destroy()
super.onDestroyView()
}
Capture still picture
// enable only single capture mode
camera.setCameraMode(Modes.CameraMode.SINGLE_CAPTURE)
// OR keep other modes as is and enable single capture mode
camera.enableCameraMode(Modes.CameraMode.SINGLE_CAPTURE)
// Output format is whatever set for [app:outputFormat] parameter
// Callback on UI thread
camera.addPictureTakenListener { image: Image -> /* Picture taken. */ }
camera.capture()
// Disable single capture mode
camera.disableCameraMode(Modes.CameraMode.SINGLE_CAPTURE)
Process preview frames
// enable only continuous frame mode
camera.setCameraMode(Modes.CameraMode.CONTINUOUS_FRAME)
// OR keep other modes as is and enable continuous frame mode
camera.enableCameraMode(Modes.CameraMode.CONTINUOUS_FRAME)
// Output format is always ImageFormat.YUV_420_888
// Callback on background thread
camera.setContinuousFrameListener(maxFrameRate = 10f /*optional*/) { image: Image -> /* Frame available. */ }
// Disable continuous frame mode
camera.disableCameraMode(Modes.CameraMode.CONTINUOUS_FRAME)
Record video
// enable only video capture mode
camera.setCameraMode(Modes.CameraMode.VIDEO_CAPTURE)
// OR keep other modes as is and enable video capture mode
camera.enableCameraMode(Modes.CameraMode.VIDEO_CAPTURE)
// Callback on UI thread
camera.addVideoRecordStartedListener { /* Video recording started */ }
// Callback on UI thread
camera.addVideoRecordStoppedListener { isSuccess ->
// Video recording stopped
// isSuccess is true if video was recorded and saved successfully
}
camera.startVideoRecording(outputFile) {
// Configure video (MediaRecorder) parameters
audioEncoder = AudioEncoder.Aac
videoFrameRate = 30
videoStabilization = true
}
// When done recording
camera.stopVideoRecording()
// On APIs 24 and above video recording can be paused and resumed as well
camera.pauseVideoRecording()
camera.resumeVideoRecording()
// Disable video capture mode
camera.disableCameraMode(Modes.CameraMode.VIDEO_CAPTURE)
Set multiple modes simultaneously
- In xml
xml <com.priyankvasa.android.cameraviewex.CameraView android:id="@+id/camera" app:cameraMode="single_capture|continuous_frame|video_capture" />
- Or in code ```kotlin camera.setCameraMode(Modes.CameraMode.SINGLE_CAPTURE or Modes.CameraMode.CONTINUOUS_FRAME or Modes.CameraMode.VIDEO_CAPTURE)
// Setup all the listeners including preview frame listener
camera.startVideoRecording(outputFile) camera.capture()
// The listeners will receive their respective outputs
#### Switch through cameras for set facing
```kotlin
camera.facing = Modes.Facing.FACING_BACK // Open default back facing camera
camera.nextCamera() // Switch to next back facing camera
Sample apps
- Kotlin sample app - Advanced usage
- Java sample app - Very simple usage
Configuration
CameraView property | XML Attribute | Possible Values (bold value is the default one) | Camera1 Support (API 14 to 20) | Camera2 Support (API 21+) |
---|---|---|---|---|
cameraMode | app:cameraMode | single_capture, continuous_frame, video_capture | :heavy_check_mark: | :heavy_check_mark: |
facing | app:facing | back, front, external | :heavy_check_mark: | :heavy_check_mark: |
aspectRatio | app:aspectRatio | 4:3, 16:9, 3:2, 16:10, 17:10, 8:5 (or any other ratio supported by device) | :heavy_check_mark: | :heavy_check_mark: |
continuousFrameSize | app:continuousFrameSize | W1920,H1080 , W1440,1080 , 1280,H720 (or any other size) |
:heavy_check_mark: | :heavy_check_mark: |
singleCaptureSize | app:singleCaptureSize | W1920,H1080 , W1440,1080 , 1280,H720 (or any other size) |
:heavy_check_mark: | :heavy_check_mark: |
touchToFocus | app:touchToFocus | false, true | :x: | :heavy_check_mark: |
autoFocus | app:autoFocus | off, auto, macro, continuous_video, continuous_picture, edof | :heavy_check_mark: | :heavy_check_mark: |
pinchToZoom | app:pinchToZoom | false, true | :x: | :heavy_check_mark: |
flash | app:flash | off, on, torch, auto, redEye | :heavy_check_mark: | :heavy_check_mark: |
awb | app:awb | off, auto, incandescent, fluorescent, warm_fluorescent, daylight, cloudy_daylight, twilight, shade | :x: | :heavy_check_mark: |
opticalStabilization | app:opticalStabilization | false, true | :x: | :heavy_check_mark: |
noiseReduction | app:noiseReduction | off, fast, high_quality, minimal, zero_shutter_lag | :x: | :heavy_check_mark: |
shutter | app:shutter | off, short_time, long_time | :heavy_check_mark: | :heavy_check_mark: |
outputFormat | app:outputFormat | jpeg, yuv_420_888, rgba_8888 | :heavy_check_mark: | :heavy_check_mark: |
jpegQuality | app:jpegQuality | default (90), low (60), medium (80), high (100) | :heavy_check_mark: | :heavy_check_mark: |
zsl | app:zsl | false, true | :x: | :heavy_check_mark: |
cameraId (get only) | N/A | Id of currently opened camera device | :heavy_check_mark: | :heavy_check_mark: |
cameraIdsForFacing (get only) | N/A | Sorted set of ids of camera devices for selected facing | :heavy_check_mark: | :heavy_check_mark: |
isActive (get only) | N/A | True if this CameraView instance is active and usable, false otherwise. It is set to false after CameraView.destroy() call. |
:heavy_check_mark: | :heavy_check_mark: |
isCameraOpened (get only) | N/A | True if camera is opened, false otherwise. | :heavy_check_mark: | :heavy_check_mark: |
isSingleCaptureModeEnabled (get only) | N/A | True if single capture mode is enabled, false otherwise. | :heavy_check_mark: | :heavy_check_mark: |
isContinuousFrameModeEnabled (get only) | N/A | True if continuous frame mode is enabled, false otherwise. | :heavy_check_mark: | :heavy_check_mark: |
isVideoCaptureModeEnabled (get only) | N/A | True if video capture mode is enabled, false otherwise. | :heavy_check_mark: | :heavy_check_mark: |
isVideoRecording (get only) | N/A | True if there is a video recording in progress, false otherwise. | :heavy_check_mark: | :heavy_check_mark: |
supportedAspectRatios (get only) | N/A | Returns list of AspectRatio supported by selected camera. |
:heavy_check_mark: | :heavy_check_mark: |
maxDigitalZoom (get only) | N/A | Returns a float value which is the maximum possible digital zoom value supported by selected camera. | :x: | :heavy_check_mark: |
currentDigitalZoom | N/A | Set camera digital zoom value. Must be between 1.0 and CameraView.maxDigitalZoom inclusive. |
:x: | :heavy_check_mark: |
Documentation
For detailed documentation, please refer these docs.
Contribution Guidelines
See CONTRIBUTING.md.
*Note that all licence references and agreements mentioned in the CameraViewEx README section above
are relevant to that project's source code only.