Easy Android camera integration, advanced features.

Overview

Build Status Download License

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

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
<com.priyankvasa.android.cameraviewex.CameraView
    android:id="@+id/camera"
    app:cameraMode="single_capture|continuous_frame|video_capture" />
  • Or in code
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

camera.facing = Modes.Facing.FACING_BACK // Open default back facing camera
camera.nextCamera() // Switch to next back facing camera

Sample apps

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 ✔️ ✔️
facing app:facing back, front, external ✔️ ✔️
aspectRatio app:aspectRatio 4:3, 16:9, 3:2, 16:10, 17:10, 8:5
(or any other ratio supported by device)
✔️ ✔️
continuousFrameSize app:continuousFrameSize W1920,H1080, W1440,1080, 1280,H720
(or any other size)
✔️ ✔️
singleCaptureSize app:singleCaptureSize W1920,H1080, W1440,1080, 1280,H720
(or any other size)
✔️ ✔️
touchToFocus app:touchToFocus false, true ✔️
autoFocus app:autoFocus off, auto, macro, continuous_video,
continuous_picture, edof
✔️ ✔️
pinchToZoom app:pinchToZoom false, true ✔️
flash app:flash off, on, torch, auto, redEye ✔️ ✔️
awb app:awb off, auto, incandescent, fluorescent, warm_fluorescent,
daylight, cloudy_daylight, twilight, shade
✔️
opticalStabilization app:opticalStabilization false, true ✔️
noiseReduction app:noiseReduction off, fast, high_quality, minimal, zero_shutter_lag ✔️
shutter app:shutter off, short_time, long_time ✔️ ✔️
outputFormat app:outputFormat jpeg, yuv_420_888, rgba_8888 ✔️ ✔️
jpegQuality app:jpegQuality default (90), low (60), medium (80), high (100) ✔️ ✔️
zsl app:zsl false, true ✔️
cameraId
(get only)
N/A Id of currently opened camera device ✔️ ✔️
cameraIdsForFacing
(get only)
N/A Sorted set of ids of camera devices for selected facing ✔️ ✔️
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. ✔️ ✔️
isCameraOpened
(get only)
N/A True if camera is opened, false otherwise. ✔️ ✔️
isSingleCaptureModeEnabled
(get only)
N/A True if single capture mode is enabled, false otherwise. ✔️ ✔️
isContinuousFrameModeEnabled
(get only)
N/A True if continuous frame mode is enabled, false otherwise. ✔️ ✔️
isVideoCaptureModeEnabled
(get only)
N/A True if video capture mode is enabled, false otherwise. ✔️ ✔️
isVideoRecording
(get only)
N/A True if there is a video recording in progress, false otherwise. ✔️ ✔️
supportedAspectRatios
(get only)
N/A Returns list of AspectRatio supported by selected camera. ✔️ ✔️
maxDigitalZoom
(get only)
N/A Returns a float value which is the maximum possible digital zoom value supported by selected camera. ✔️
currentDigitalZoom N/A Set camera digital zoom value. Must be between 1.0 and CameraView.maxDigitalZoom inclusive. ✔️

Documentation

For detailed documentation, please refer these docs.

Contribution Guidelines

See CONTRIBUTING.md.

Comments
  • Video recording fails to save to file

    Video recording fails to save to file

    stopVideoRecording() always returns false, with no error

      private var tmpVideoFile: File? = null
    
      @SuppressLint("SimpleDateFormat")
      @Throws(IOException::class)
      private fun getNewVideoFile(): File {
        // Create an image file name
        val timeStamp: String = SimpleDateFormat("yyyyMMdd_HHmmss").format(Date())
        val directory = "${Environment.getExternalStorageDirectory().absolutePath}/filmit/videos".also { File(it).mkdirs() }
        return File(directory, "$timeStamp.mp4")
      }
    
      @SuppressLint("MissingPermission")
      private fun listenToVideoRecordEvent() {
        publisherDisposable = videoRecordEventPublisher.subscribe {
          if (it) {
            recordVideoFrame.visibility = View.VISIBLE
            tmpVideoFile = getNewVideoFile()
            recordVideoCamera.startVideoRecording(tmpVideoFile!!) {
              // Configure video (MediaRecorder) parameters
              audioEncoder = AudioEncoder.Aac
              videoFrameRate = 60
              videoStabilization = true
              videoEncoder = VideoEncoder.H263
            }
          } else {
            if(recordVideoCamera.stopVideoRecording()) {
              uploadTmpVideo()
            } else {
              Log.e(TAG, "failed to save video to file")
              Log.d(TAG, tmpVideoFile.toString())
            }
            recordVideoFrame.visibility = View.GONE
          }
        }
    
      }
    
    opened by yonathan06 12
  • [crash] Error opening camera with id 0

    [crash] Error opening camera with id 0

    Describe the bug I have get much crash with Error opening camera with id 0

    Using ProGuard YES

    Screenshots If applicable, add screenshots to help explain your problem.

    Device (please complete the following information):

    • Device: [Huawei Honor V20]
    • OS: [Android 9.0]

    Additional context / stacktrace Fatal Exception: com.priyankvasa.android.cameraviewex.CameraViewException: Error opening camera with id 0 (error: 4) at com.priyankvasa.android.cameraviewex.Camera2$cameraDeviceCallback$2$1.onError(Camera2.java:62) at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.notifyError(CameraDeviceImpl.java:1922) at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.lambda$Sm85frAzwGZVMAK-NE_gwckYXVQ(CameraDeviceImpl.java) at android.hardware.camera2.impl.-$$Lambda$CameraDeviceImpl$CameraDeviceCallbacks$Sm85frAzwGZVMAK-NE_gwckYXVQ.accept(-.java:8) at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:258) at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:182) at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:77) at android.os.Handler.handleCallback(Handler.java:907) at android.os.Handler.dispatchMessage(Handler.java:105) at android.os.Looper.loop(Looper.java:216) at android.os.HandlerThread.run(HandlerThread.java:65)

    inactive 
    opened by yangchendev 9
  • How to get supported hardware level?

    How to get supported hardware level?

    Hi. In Android camera 2 API there is implementation levels, I couldn't find any way, for checking implementation level. So how I can get implementation level?

    Link to documentation https://developer.android.com/reference/android/hardware/camera2/CameraCharacteristics.html#INFO_SUPPORTED_HARDWARE_LEVEL

    opened by rid-hrant 9
  • New logo/icon proposal

    New logo/icon proposal

    Good day sir. I am a graphic designer and i am interested in designing a logo for your good project. I will be doing it as a gift for free. I just need your permission first before I begin my design. Hoping for your positive feedback. Thanks

    inactive 
    opened by mansya 8
  • Crash if launching CameraActivity multiple times

    Crash if launching CameraActivity multiple times

    Describe the bug The latest batch of changes merged into developed has introduced an issue. If you launch your CameraActivity from another activity, then leave the camera, go back and forth a few times eventually it all locks up.

    I have provided a simple activity that I used to reproduce the issue off of the development branch. When I switch to my fork that does not have your latest changes I am able to open the camera as many times as I want without issue. To Reproduce Pull request that demonstrates the issue: https://github.com/pvasa/cameraview-ex/pull/118

    1. Have an activity that you launch the camera from
    2. Go back out of the camera
    3. Go in and out of the camera a few times and it will fail

    Expected behavior Before the latest batch of changes the issue did not occur.

    Using ProGuard

    • [ ] with ProGuard
    • [X ] without ProGuard

    Device (please complete the following information):

    • Device: LG G6
    • OS: 8.0
    • App version [2.7.0]
    opened by pcm2a 8
  • How to capture images in 16:9

    How to capture images in 16:9

    Can you point me in the right direction on how to set the aspect ratio for capturing an image with Camera2? The equivalent of setPictureSize on Camera1. I would like to do something similar to what we did with videos and allow taking photos in 4:3 or 16:9. Currently with a full screen preview the captured image is 4:3.

    opened by pcm2a 8
  • Provide video size to record in

    Provide video size to record in

    Currently the library will choose the highest video size in the current aspect ratio and based on the preview width/height. We should be able to specify exactly which size we want to record in. For example preview could be any size or shape but record in 1080p or 720p.

    Added:

    • Get the supported video sizes for the current camera
    • Set the video size using VideoConfiguration
    enhancement 
    opened by pcm2a 8
  • Capture fails after a restart of the camera

    Capture fails after a restart of the camera

    Describe the bug Capture doesn't work after stopping and restarting the camera in release 2.7.0. An error is not generated and the picture taken listener is not invoked. This showed up in this latest release (2.7.0), it doesn't seem to occur on 2.6.1.

    To Reproduce Steps to reproduce the behavior:

    1. Start camera using start
    2. Stop camera using stop(false)
    3. Start camera again using start
    4. Call capture and the dimming UI animation occurs but addPictureTakenListener or addCameraErrorListener are never called

    Expected behavior Calling capture should call either the error listener or the picture taken listener.

    Using ProGuard

    • [x] with ProGuard
    • [ ] without ProGuard

    Device (please complete the following information):

    • Device: S8+
    • OS: 8.0.0
    • API: 27
    • App version 0.1

    Branch Name (if using as a local module)

    • [ ] master
    • [ ] development
    • [x] release
    • [ ] other (please specify)
    bug 
    opened by arvinkx 7
  • Support for fixed orientation view and landscape video/image

    Support for fixed orientation view and landscape video/image

    Currently in order to record a landscape video you have to leave the orientation unlocked. This results in a jarring experience when the device changes from portrait to landscape. A better approach would be to allow the device to be fixed to portrait or userPortrait. When the recording or picture is taken it would be taken in the correct orientation based on the device orientation.

    Setting the activity to android:screenOrientation="userPortrait" locks the orientation but videos and images are taken in portrait even when rotated to landscape.

    For Camera1 you would use camera.setDisplayOrientation, which is already being done in Camera1.kt. For Camera2 I though it was supposed to just work by default since there is no setDisplayOrientation. However, it is not working.

    I will start looking into how this is supposed to work and see if I can come up with a fix. If you have any tips they would be welcomed.

    enhancement 
    opened by pcm2a 7
  • Exception at Video recording

    Exception at Video recording

    Hello, Finally i set like this:

    cameraView.setCameraMode(Modes.CameraMode.VIDEO_CAPTURE); cameraView.enableCameraMode(Modes.CameraMode.VIDEO_CAPTURE);

    String root = Environment.getExternalStorageDirectory().toString(); File myDir = new File(root + "/cubeTok"); myDir.mkdirs();

    String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date()); String fname = "cubeTok_" + timeStamp + ".mp4";

    File file = new File(myDir, fname); cameraView.startVideoRecording(file);

    But it's give an Exception: "com.priyankvasa.android.cameraviewex.CameraViewException: Unable to start video recording.

    Is there anything lake to put? Please me to solve this.

    Thanks.

    opened by 23nJay 6
  • Switch through cameras of set facing

    Switch through cameras of set facing

    I have closed the other PR and remade the changes from the latest development branch. I also refactored and made the changes simpler for the user. Almost all new phones come with more than 2 cameras now and in some cases 4 or 5 cameras.

    CameraView: start() -> User can still call this to start the camera, getting the default rear facing

    start(cameraId) -> New feature to allow starting right to a camera, for example remembering that the user was on the back camera.

    nextCamera() -> New feature that will cycle through all of the devices cameras, in the order that the device presents them. Example: 0 (rear), 1 (front), 2 (rear) for a LG G5 or LG G6.

    opened by pcm2a 6
  • Unable to start video recording.

    Unable to start video recording.

    Hi, I am getting following exception while start camera. and my goal is to capture video and continues frames.

    Please help me to solve this issue.

    com.priyankvasa.android.cameraviewex.CameraViewException: Unable to start video recording. java.lang.ArithmeticException: divide by zero Unable to start video recording.

    My code is --

    <com.priyankvasa.android.cameraviewex.CameraView
        android:id="@+id/camera"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:adjustViewBounds="true"
        android:keepScreenOn="true"
        app:aspectRatio="4:3"
        app:autoFocus="continuous_video"
        app:awb="auto"
        app:cameraMode="continuous_frame|video_capture"
        app:continuousFrameSize="W1440,1080"
        app:facing="back"
        app:flash="off"
        app:jpegQuality="high"
        app:noiseReduction="high_quality"
        app:opticalStabilization="true"
        app:outputFormat="jpeg"
        app:pinchToZoom="false"
        app:shutter="short_time"
        app:singleCaptureSize="1920,H1080"
        app:touchToFocus="false"
        app:zsl="true" />
    

    override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState)

        // Callbacks on UI thread
        _binding?.camera?.addCameraOpenedListener { /* Camera opened. */ }
            ?.addCameraErrorListener { t: Throwable, errorLevel: ErrorLevel -> /* Camera error! */
                Log.d("AAAAAA  ", "addCameraErrorListener")
            }
            ?.addCameraClosedListener { /* Camera closed. */
                Log.d("AAAAAA  ", "addCameraClosedListener")
            }
    
    }
    
    override fun onResume() {
        super.onResume()
        if (ActivityCompat.checkSelfPermission(
                requireContext(),
                Manifest.permission.CAMERA
            ) != PackageManager.PERMISSION_GRANTED
        ) {
            // TODO: Consider calling
            //    ActivityCompat#requestPermissions
            // here to request the missing permissions, and then overriding
            //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
            //                                          int[] grantResults)
            // to handle the case where the user grants the permission. See the documentation
            // for ActivityCompat#requestPermissions for more details.
            return
        }
        _binding?.camera?.start(Modes.DEFAULT_CAMERA_ID)
    

    // _binding?.camera?.setCameraMode(Modes.CameraMode.SINGLE_CAPTURE or Modes.CameraMode.CONTINUOUS_FRAME or Modes.CameraMode.VIDEO_CAPTURE) // _binding?.camera?.setCameraMode(Modes.CameraMode.VIDEO_CAPTURE)

    // OR keep other modes as is and enable video capture mode // _binding?.camera?.enableCameraMode(Modes.CameraMode.VIDEO_CAPTURE)

    // Callback on UI thread _binding?.camera?.addVideoRecordStartedListener { /* Video recording started */ Log.d("AAAAAA ", "Video recording started") }

    // Callback on UI thread _binding?.camera?.addVideoRecordStoppedListener { isSuccess -> // Video recording stopped Log.d("AAAAAA ", "Video recording stopped") // isSuccess is true if video was recorded and saved successfully }

        _binding?.camera?.setContinuousFrameListener {
            Log.d("AAAAAA  ", "Continuous Frame Listener")
            showFramePreview(it)
        }
    
        val direct = File(Environment.getExternalStorageDirectory().toString() + "/capture_video")
        if (!direct.exists()) {
            val wallpaperDirectory = File("/sdcard/capture_video/")
            wallpaperDirectory.mkdirs()
        }
        val file = File("/sdcard/capture_video/", "video_" + System.currentTimeMillis() + ".mp4")
        if (file.exists()) {
            file.delete()
        }
    
        _binding?.camera?.startVideoRecording(file) {
            // Configure video (MediaRecorder) parameters
            audioEncoder = AudioEncoder.Aac
            videoFrameRate = 30
            videoStabilization = true
        }
    }
    
    opened by krghv85 0
  • Android 11 and 12 I'm facing some issue

    Android 11 and 12 I'm facing some issue

    I have oneplus nord ce2 device with android 11 version

    I have tried to implement this library but when I start app it is showing only white screen

    • Device: Oneplus nord ce2
    • OS: Android 11

    Also I have tried with emulator with android 12

    In emulator I'm getting this error while capturing image

    2022-03-24 16:19:36.598 10182-10374/com.pathquestap E/CameraCaptureSession: Session 0: Exception while stopping repeating: android.hardware.camera2.CameraAccessException: CAMERA_ERROR (3): The camera device has encountered a serious error at android.hardware.camera2.impl.CameraDeviceImpl.checkIfCameraClosedOrInError(CameraDeviceImpl.java:2350) at android.hardware.camera2.impl.CameraDeviceImpl.stopRepeating(CameraDeviceImpl.java:1277) at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:579) at android.hardware.camera2.impl.CameraCaptureSessionImpl$2.onDisconnected(CameraCaptureSessionImpl.java:790) at android.hardware.camera2.impl.CameraDeviceImpl$7.run(CameraDeviceImpl.java:259) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loopOnce(Looper.java:201) at android.os.Looper.loop(Looper.java:288) at android.os.HandlerThread.run(HandlerThread.java:67)

    Untitled Screenshot 2022-03-24 162628

    opened by Bhagirath987 2
  • More than one file was found with OS independent path 'META-INF/atomicfu.kotlin_module'

    More than one file was found with OS independent path 'META-INF/atomicfu.kotlin_module'

    Want to raise 2 points:

    First is that the callbacks of the library are using kotlin and prefer lambda expressions. The code is not designed to work well with java 7. For example: camera.addCameraOpenedListener() Please mention this in prerequisite to use this library, or provide support/guide for using it along with Java 7.

    Second, After adding library dependency, got error during build: More than one file was found with OS independent path 'META-INF/atomicfu.kotlin_module'

    Expected behavior Build should work without causing conflicts.

    Using ProGuard

    • without ProGuard

    Device (please complete the following information):

    • Device: NA
    • OS: NA
    • API: 29
    • App version 3.5.5-alpha minSdkVersion 21 targetSdkVersion 29 compileSdkVersion 29 gradle 3.5.3 using Java 7

    To fix this, had to add following in app level gradle:

    packagingOptions {
            pickFirst  'META-INF/*'
    }
    

    Any reason why this is happening?

    My dependencies:

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.appcompat:appcompat:1.1.0'
        implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
        // request permission
        implementation 'com.karumi:dexter:6.0.1'
    
        // CameraViewEx
        // https://github.com/pvasa/cameraview-ex?utm_source=android-arsenal.com&utm_medium=referral&utm_campaign=7320
        implementation "com.priyankvasa.android:cameraview-ex:3.5.5-alpha"
    
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test.ext:junit:1.1.1'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    }
    
    requires investigation pinned 
    opened by deshant 0
  • Camera freeze when shooting with flash

    Camera freeze when shooting with flash

    The camera just freezes when shooting with FLASH_ON and after a small moment this error comes out 2019-09-26 03:38:21.827 17385-17385/com.waynyo.debug E/CameraFragment$onCreateView: com.priyankvasa.android.cameraviewex.CameraViewException: Error opening camera with id 0 (error: 4) at com.priyankvasa.android.cameraviewex.Camera2$cameraDeviceCallback$2$1.onError(Camera2.kt:145) at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.notifyError(CameraDeviceImpl.java:1929) at android.hardware.camera2.impl.CameraDeviceImpl$CameraDeviceCallbacks.lambda$Sm85frAzwGZVMAK-NE_gwckYXVQ(Unknown Source:0) at android.hardware.camera2.impl.-$$Lambda$CameraDeviceImpl$CameraDeviceCallbacks$Sm85frAzwGZVMAK-NE_gwckYXVQ.accept(Unknown Source:8) at com.android.internal.util.function.pooled.PooledLambdaImpl.doInvoke(PooledLambdaImpl.java:258) at com.android.internal.util.function.pooled.PooledLambdaImpl.invoke(PooledLambdaImpl.java:182) at com.android.internal.util.function.pooled.OmniFunction.run(OmniFunction.java:77) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at android.os.HandlerThread.run(HandlerThread.java:65)

    Steps to reproduce the behavior:

    1. set FLASH_ON 2.Shoot with the camera

    Expected behavior Give the image correctly with no freezes

    Using ProGuard

    • [x] without ProGuard

    Screenshots If applicable, add screenshots to help explain your problem.

    Device (please complete the following information):

    • Device: Galaxy Note 9
    • OS: Android 9
    • API: 28
    requires investigation pinned 
    opened by hmawla 0
  • Camera1 preview wrong orientation on some devices

    Camera1 preview wrong orientation on some devices

    Describe the bug 9/12/19 Update: I was totally incorrect about what was going on. The ZTE Cymbal T runs android 5 but when it tries to use Camera2 it is falling back to Camera1. This issue here is with Camera1 and not Camera2. I have also validated that the Camera2 functionality works perfectly on a Nexus 6, only when using Camera1 is it upside down. Because of this I consider it a much lower of a priority.

    Some devices have cameras installed in the device in non-standard orientations, usually with the front camera (selfie). Examples are some of the Nexus 5/6 devices and a test device I have, ZTE Cymbal T. The issue here is only with Camera1 and only with the preview. The recorded video is in the correct orientation.

    I did some tests forcing the camera into Camera1 and then tested the fix on the broken device and on a device that did not have the problem.

    Steps performed:

    1. Holding phone portrait, back camera:
    2. Holding phone portrait, switch to selfie camera:
    3. Rotate phone to landscape, switch to back camera
    4. Holding phone in landscape: switch to selfie camera:

    With my changes in place : https://github.com/pvasa/cameraview-ex/pull/209

    ZTE Cymbal T: Camera locked in portrait

    1. deviceRotation=0, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=90
    2. deviceRotation=0, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=270
    3. deviceRotation=90, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=90
    4. deviceRotation=90, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=270

    Xaiomi: Camera locked in portrait

    1. rotationDegrees=0, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=90
    2. rotationDegrees=0, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=90
    3. rotationDegrees=90, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=90
    4. rotationDegrees=90, WindowManager.rotation=0, getCameraDegrees()=0, displayOrientation=90

    Try it out on a few devices forcing the camera to use Camera1 and see if it also works correctly for you.

    Device (please complete the following information):

    • Device: ZTE Cymbal T
    • OS: Android 5.1
    bug pinned 
    opened by pcm2a 1
Releases(v3.5.7-alpha)
  • v3.5.7-alpha(Jan 31, 2022)

  • v3.5.5-alpha(Aug 24, 2019)

  • v3.5.4-alpha(Aug 21, 2019)

    • Improve size fallback mechanism for continuous frame and single capture modes.
      • Check this and this doc for more info about the size selection mechanism
    • Use requested output format instead of ImageReader::class to fetch list of supported output sizes from StreamConfigurationMap. This was a bug as when fetching this list using ImageReader class, it only returns list for ImageFormat.PRIVATE which might be different than actual output format.
    Source code(tar.gz)
    Source code(zip)
  • v3.5.3-alpha(May 24, 2019)

    • Fix incorrect cropping for non standard image size and orientation when images are pre-rotated
    • Fix texture cropping for non standard preview size in landscape mode
    Source code(tar.gz)
    Source code(zip)
  • v3.5.2-alpha(May 16, 2019)

    • Fix video recording bug

    New apis:

    • cameraId - String id of currently opened camera device
    • cameraIdsForFacing - SortedSet of string ids of camera devices for selected facing
    • nextCamera() - Open next camera in sequence of sorted camera ids for current facing

    Updated apis:

    • start(cameraId) - Start now accepts an optional string cameraId to manually select which camera id to open. If nothing passed, first (default system) camera will be opened for selected facing
    • app:facing AND cameraView.facing - Both now accepts a new facing value external in xml and Modes.Facing.FACING_EXTERNAL for in code usage. This facing open any external camera available and falls back to Modes.Facing.FACING_BACK if there is no external camera
    Source code(tar.gz)
    Source code(zip)
  • v3.5.1-alpha(Apr 26, 2019)

  • v3.5.0-alpha(Apr 22, 2019)

    • New apis:

      • continuousFrameSize (type: Size) Set preferred (not guaranteed) output frame size for continuous frames mode
      • singleCaptureSize (type: Size) Set preferred (not guaranteed) output image size for single capture mode
    • Updated apis:

      • setPreviewFrameListener(..) -> setContinuousFrameListener(..)
    • Decide orientation based on aspect ratio. For eg., x:y (landscape) and y:x (portrait) now generates different preview/output orientation independent of device/screen orientation.

    • Improve image processing for RGBA_8888 format outputs

    • Use Google's exif implementation as a part of library to avoid external dependency on support ExifInterface lib

    • Support custom sized continuous frames and single captures different from aspect ratio and best/highest size

    • Bug fixes

    • Performance and stability improvements

    Source code(tar.gz)
    Source code(zip)
  • v3.4.3(Apr 15, 2019)

  • v3.4.2(Apr 7, 2019)

    • Move sampleApp to separate project
    • Migrate sampleApp to AndroidX
    • Setup local maven repo to build library module (legacy support packages and AndroidX are not compatible under same project)
    • Bug fixes
    Source code(tar.gz)
    Source code(zip)
  • v3.4.1(Mar 31, 2019)

  • v3.4.0(Mar 28, 2019)

    Updates:

    • Api changes:
      • Preview frame listener now accepts a parameter maxFrameRate (float) It is the maximum number of frames per second generated by the listener. Actual frame rate might be less based on device capabilities but will not be more than this value. A float can be set for eg., max frame rate of 0.5f will produce one frame every 2 seconds. Any value less than or equal to zero (<= 0f) will produce maximum frames per second supported by device. Not providing this value uses the maximum possible frame rate.
    • Bug fixes
    Source code(tar.gz)
    Source code(zip)
  • v3.3.0(Mar 22, 2019)

    • Api changes
      • New api - enableCameraMode(Modes.CameraMode) Enable any single camera mode or multiple camera modes by passing [Modes.CameraMode]. Multiple modes can be enabled by passing bitwise or'ed value of multiple [Modes.CameraMode].
      • New api - disableCameraMode(Modes.CameraMode) Disable any camera mode from [Modes.CameraMode], one at a time
    Source code(tar.gz)
    Source code(zip)
  • v3.2.0(Mar 15, 2019)

    • Make some API changes to make it consistent.
    • Updated APIs
      • addPictureTakenListener { image: Image -> } The output type has changed from ByteArray to Image which is a wrapper consisting of the original ByteArray image data and some extra metadata which has information about output orientation (more to be added later)
      • setPreviewFrameListener { image: Image -> } The android.media.Image is now replaced with internal Image data class same as the one in picture taken listener
      • setLegacyPreviewFrameListener is no longer needed now and it is removed. It should be replaced with setPreviewFrameListener
    • Performance and stability improvements
    Source code(tar.gz)
    Source code(zip)
  • v3.1.3(Mar 6, 2019)

  • v3.1.1(Mar 1, 2019)

  • v3.1.0(Feb 26, 2019)

    • Implement preview frame listener for camera1
    • Support video recording for camera1
    • Run everything suspending style to avoid any UI lag while view rendering
    • Support many more video sizes
      • Min, Min16x9, Min11x9, Min4x3, Min3x2, Min1x1
      • Max, Max16x9, Max11x9, Max4x3, Max3x2, Max1x1
      • P2160, P1440, P1080, P720, P480, CIF, QVGA, QCIF
    • Fix some aspect ratio related and image quality bugs
    • Fix sample app bug
    • Overall performance and stability improvements
    • Fix camera2 implementation which created issue in fallback mechanism
    Source code(tar.gz)
    Source code(zip)
  • v3.0.1-beta(Jan 29, 2019)

  • v3.0.0-beta(Jan 28, 2019)

    • Support multiple simultaneous camera modes
    • Api changes
      • CameraView.cameraMode is now CameraView.setCameraMode(..) It can accept a bitwise OR'ed integer like below to enable multiple camera modes
    cameraView.setCameraMode(Modes.CameraMode.CONTINUOUS_FRAME or Modes.CameraMode.VIDEO_CAPTURE)
    
    • Bug fixes
    Source code(tar.gz)
    Source code(zip)
  • v2.8.2(Jan 28, 2019)

  • v2.8.1(Jan 22, 2019)

  • v2.8.0(Jan 22, 2019)

    • Improve background thread handling
    • Fix few bugs related to camera not working (or crash) on restart
    • Provide better apis to stop and destroy CameraView instance
    • New Apis
      • CameraView.destroy() - Tear down this CameraView instance. The instance is not usable anymore after this call.
      • CameraView.isActive - Check if this CameraView instance is still active and usable.
    • More realistic sample app code
    Source code(tar.gz)
    Source code(zip)
  • v2.7.0(Jan 16, 2019)

    • Max video duration can be provided in VideoConfiguration
    • Video size can be provided in VideoConfiguration
    • Add video started stopped listeners
    • Fix background tasks implementation to run tasks on correct thread
    • Fix invalid rotation issue
    Source code(tar.gz)
    Source code(zip)
  • v2.6.0(Jan 5, 2019)

    • More auto focus modes
    • Better video recording
    • Better exception handling and error level indication in the callback
    • Better touch to focus
    • Fix camera1 implementation
    • Fix UI tests
    Source code(tar.gz)
    Source code(zip)
  • v2.5.0(Dec 22, 2018)

  • v2.4.2(Dec 19, 2018)

    • Implement basic touch to focus feature
    • Add api for providing video config when starting to record video
    • Add attribute for specifying output jpeg quality
    • Improve sample app output handling
    Source code(tar.gz)
    Source code(zip)
  • v2.4.1(Dec 14, 2018)

  • v2.4.0(Dec 14, 2018)

  • v2.3.0(Dec 5, 2018)

  • v2.2.2(Nov 22, 2018)

  • v2.2.1(Nov 22, 2018)

Owner
Priyank Vasa
Priyank Vasa
A library with many useful and easy-to-use features

This library was made as a replacement for qLib and in the future cubed. These 2 plugins are hard to get you hands on and one of them has many outdated methods so this is a more modern version of those things

Max 1 May 6, 2022
Android sample app for mobile-sdk integration

Dyte Android Sample App An example app in kotlin using the Dyte Mobile Core SDK Explore the docs » View Demo · Report Bug · Request Feature Table of C

Dyte 5 Jul 30, 2022
Compose Multiplatform integration for Redux-Kotlin

Redux-Kotlin-Compose Compose Multiplatform integration for Redux Kotlin Installation Artifacts are hosted on maven central. For multiplatform, add the

Redux-Kotlin 7 Sep 7, 2022
Advanced State in Jetpack Compose Codelab

Advanced State in Jetpack Compose Codelab This folder contains the source code for the Advanced State in Jetpack Compose Codelab codelab. The project

Carlos Barrios 1 May 12, 2022
An advanced Minecraft plugin template made in Gradle

//DONT_APPLY_TEMPLATE_CHANGE Gradle Plugin Template Kotlin DSL Version ℹ️ This template was planned to support only kotlin, but it also supports Java!

null 0 Apr 17, 2022
Yet another advanced Craftfting Table mod. My entry for ModFest: Singularity

Crafting Bench A utility mod that adds a custom crafting table with semi-automatic crafting. Features For a complete list of features please check the

Luca Argolo 2 Aug 23, 2022
LifecycleMvp 1.2 0.0 Kotlin is MVP architecture implementation with Android Architecture Components and Kotlin language features

MinSDK 14+ Download Gradle Add to project level build.gradle allprojects { repositories { ... maven { url 'https://jitpack.io' }

Robert 20 Nov 9, 2021
Basic Android app to use Jetpack WorkManager API features

jetpack-work-manager-playground Basic Android app to use Jetpack WorkManager API features Jetpack WorkManager Playground Demo app Jetpack WorkManager

Raheem 0 Dec 9, 2021
Enable and customize hidden features on Android 12.

Android 12 Extensions This is a Magisk + Xposed module that adds customization and enables hidden features on Android 12. It also includes a configura

Danny Lin 383 Jan 1, 2023
Reusable login template to learn Kotlin & Android additional features

LogIn_Application reusable login template I started this project to learn Kotlin & Android additional features. This is LogIn Template App as part of

null 0 Dec 14, 2021
Example Multi module architecture Android project using MVVM, Dynamic Features, Dagger-Hilt, Coroutines and Navigation Components

ModularDynamicFeatureHilt An Android template project following a multi module approach with clean architecture. It has been built following Clean Arc

Mbuodile Obiosio 25 Nov 23, 2022
This library provides common speech features for ASR including MFCCs and filterbank energies for Android and iOS.

Kotlin Speech Features Quick Links ?? Introduction This library is a complete port of python_speech_features in pure Kotlin available for Android and

Merlyn Mind 13 Oct 7, 2022
A news app with amazing features.

Newdo-News In this app I'll show you how to fetch current news from a public API. The aim of this project is to show you how use best practices in And

Victor Loveday 6 Aug 17, 2022
Provides Kotlin libs and some features for building Kotlin plugins

Kotlin Plugin Provides Kotlin libs and some features for building awesome Kotlin plugins. Can be used instead of CreeperFace's KotlinLib (don't use to

null 3 Dec 24, 2021
Com.hhvvg.anytext - An application provides features to modify any TextView in any other applications

AnyText What's this This application provides features to modify any TextView in

null 6 Dec 2, 2022
An amazing expense tracker app, with great features and beautiful UI. Check it out!

My Expense Tracker Expense tracker app to keep your finances in order. Built entirely in Kotlin using modern architecture components. Build ??️ My Exp

Ken Ali 7 Oct 26, 2022
Create an application with Kotlin/JVM and Kotlin/JS, and explore features around code sharing, serialization, server- and client

Practical Kotlin Multiplatform on the Web 본 저장소는 코틀린 멀티플랫폼 기반 웹 프로그래밍 워크숍(강좌)을 위해 작성된 템플릿 프로젝트가 있는 곳입니다. 워크숍 과정에서 코틀린 멀티플랫폼을 기반으로 프론트엔드(front-end)는 Ko

SpringRunner 14 Nov 5, 2022
Create an application with Kotlin/JVM and Kotlin/JS, and explore features around code sharing, serialization, server- and client

Building a Full Stack Web App with Kotlin Multiplatform 본 저장소는 INFCON 2022에서 코틀린 멀티플랫폼 기반 웹 프로그래밍 핸즈온랩을 위해 작성된 템플릿 프로젝트가 있는 곳입니다. 핸즈온 과정에서 코틀린 멀티플랫폼을

Arawn Park 19 Sep 8, 2022
This app features - Modern Design, MVVM, Hilt, Room, StateFlow, Jetpack Compose

MyMusic is a beautiful app showing how to build modern looking interfaces using Jetpack Compose, recommended libraries, best practices and architectur

Ibrahim 54 Dec 27, 2022