CameraView
Menu toggle
latest: v2.7.2 GitHub

New versions are released through GitHub, so the reference page is the GitHub Releases page.

Starting from 2.4.0, you can now support development through the GitHub Sponsors program. Companies can share a tiny part of their revenue and get private support hours in return. Thanks!

v2.7.2
  • Fix: fix camera rotation handling for Compose apps and other specific scenarios (#1117)

https://github.com/natario1/CameraView/compare/v2.7.1...v2.7.2

v2.7.1
  • Fix: fix preview issues on Pixel 4A with certain FPS, thanks to @honzasmuk (#1089)
  • Improvement: don’t catch gestures if they’re turned off, thanks to @ObsidianX (#1068)
  • New: new flag cameraDrawHardwareOverlays and setDrawHardwareOverlays() to draw overlays on hardware canvas, thanks to @ObsidianX (#1066)
  • Publish on Maven Central instead of JCenter

https://github.com/natario1/CameraView/compare/v2.7.0...v2.7.1

v2.7.0
  • New: onPictureShutter() callback when taking pictures, thanks to @EzequielAdrianM (#1030)
  • New: GestureAction.TAKE_PICTURE_SNAPSHOT lets you take snapshots on gesture, thanks to @EzequielAdrianM (#1030)
  • Improvement: try-catch internal exception when takePicture fails, thanks to @michaelspecht (#1024)
  • Improvement: log errors when file writing fails, thanks to @bwt (#960)
  • Fix: Avoid preview deadlocks (#1020)
  • Fix: Workaround for messed-up preview on Pixel 4 (#1020)
  • Fix: Avoid internal StackOverflow errors (#992)

https://github.com/natario1/CameraView/compare/v2.6.4...v2.7.0

v2.6.4
  • Fix: Fix many small bugs (#953)

https://github.com/natario1/CameraView/compare/v2.6.3...v2.6.4

v2.6.3
  • [Video] New: setAudioCodec and app:cameraAudioCodec to choose the audio encoding format, thanks to @EverydayPineapple (#861)
  • [Camera1, Frame processing] Fix: frame processing restarts automatically after taking a picture, thanks to @jeffreyfjohnson (#877)
  • [Camera1] Improvement: catch more errors in Camera1 lifecycle to avoid crashes, thanks to @Namazed (#851 and #897)
  • [CameraView] Improvement: setLifecycleOwner is now nullable and will unbind the lifecycle, thanks to @Namazed (#798)
  • [Preview] Improvement: the CameraPreview APIs are much more friendly for subclassing (#816)

https://github.com/natario1/CameraView/compare/v2.6.2...v2.6.3

v2.6.2
  • [Frame processing] New: frame.getRotationToUser() and frame.getRotationToView() APIs to help with processing vs. rendering (#745)
  • [Camera1, Camera2] New: cameraPreviewFrameRateExact="true|false" to tell whether the desired preview frame rate should be as exact as possible, thanks to [@hualong-shen][hualong-shenn] (#754)
  • [Logging] Improvement: CameraLogger is now thread safe, thanks to @Namazed (#779)
  • [Permissions] Improvement: added runtime API setRequestPermissions() that matches the XML attribute, thanks to @Namazed (#775)

https://github.com/natario1/CameraView/compare/v2.6.1...v2.6.2

v2.6.1
  • [Video] New: takeVideo(FileDescriptor) for file descriptors, thanks to @sewar (#732)
  • [Video] Improvement: fixed “no encoder found” issues for some devices (#741)
  • [Camera2, Metering] Improvement: increased metering timeout for touch metering (#741)
  • [Camera2, Metering] Improvement: extended touch metering to LEGACY devices (#741)

https://github.com/natario1/CameraView/compare/v2.6.0...v2.6.1

v2.6.0

  • [Metering] New: startAutoFocus(RectF) will start 3A metering to a given rect instead of a spot (#724)
  • [Permissions] New: app:cameraRequestPermissions flag to disable the automatic activity permission request (#718)
  • [Frame processing] New: setFrameProcessingPoolSize() to set the number of Frame instances that can exist at any given time. Useful in conjunction with setFrameProcessingExecutors(). Please read docs (#716)
  • [Frame processing] New: setFrameProcessingExecutors() to set the number of threads involved in frame processing. Useful in conjunction with setFrameProcessingPoolSize(). Please read docs (#716)
  • [Frame processing, Camera2] Improvement: ensure that slow processing does now slow down the preview (#716)

https://github.com/natario1/CameraView/compare/v2.5.0...v2.6.0

v2.5.0

  • [Camera2] New: support for RAW pictures with new APIs setPictureFormat() and CameraOptions.getSupportedPictureFormats(). Contains a breaking change: PictureResult.getFormat() is not an integer anymore but rather a PictureFormat. This API had no real purpose so this might not affect you (#691)
  • [Camera2] New: support for constraining the frame processing size through setFrameProcessingMaxWidth() and setFrameProcessingMaxHeight(). This can improve processing performance (#691)
  • [Camera2] New: support for choosing the frame processing format through setFrameProcessingFormat() and CameraOptions.getSupportedFrameProcessingFormats() (#691)
  • [Camera2] Improvement: Frame processing FPS for Camera2 is now smooth and typically better than Camera1. This required some breaking changes (see below) (#691)
  • [Camera1, Camera2] Improvement: improved internal threading (#697)
  • [Camera1, Camera2] Improvement: improvements to stability and edge cases behavior (#696)
  • [Real time filters] Change: filters do not need the experimental flag anymore (#691)

The new frame processing approach will force you to update your code, because Frame.getData() is not a a byte[] anymore. The class of this object now depends on the engine being used. You can use frame.getDataClass() (or instanceof) to check.

If you are using the Camera1 engine, you will still receive byte arrays, so you can just cast frame.getData() to byte[], assuming it’s not done already by the compiler.

If you are using the experimental Camera2 engine, you will receive android.media.Images instead. This object will likely be accepted by frame processing libraries, and also offers access to raw byte data. This change greatly improved the FPS performance, which is what matters the most at the library level.

https://github.com/natario1/CameraView/compare/v2.4.0...v2.5.0

v2.4.0

  • [Camera2] New: support for previewFrameRate. Controls preview FPS, snapshot FPS, processor FPS, thanks to @vaibhavbhandula (#653)
  • [Camera1] New: support for previewFrameRate for Camera1 (#661)
  • [Camera2] Fix: fix crashes when taking snapshots very early (#651)
  • [Preview] Fix: Fixed preview being upside-down for 180 degrees flips (#651)
  • Fix: other bug fixes (#651)

https://github.com/natario1/CameraView/compare/v2.3.1...v2.4.0

v2.3.1
  • [Video] Improvement: better timing for onVideoRecordingStart() thanks to @agrawalsuneet (#632)
  • [Video, Camera1] Fix: fixed video errors when starting on specific devices (#617)
  • [Video] Fix: fixed crash when closing the app during video snapshots (#630)
  • [Preview] Fix: fixed crash when using GL_SURFACE (#630)

https://github.com/natario1/CameraView/compare/v2.3.0...v2.3.1

v2.3.0

  • [Camera2, Metering] New: startAutoFocus is much more powerful and does 3A metering (AF, AE, AWB) (#574)
  • [Camera2, Metering] New: setPictureMetering(boolean) decides whether to do metering before takePicture(). Defaults to true to improve quality. (#580)
  • [Camera2, Metering] New: setPictureSnapshotMetering(boolean) decides whether to do metering before takePictureSnapshot(). Defaults to false to improve latency. However, you can set this to true to greatly improve the snapshot quality, for example to support Flash. (#580)
  • [Camera2, Metering] New: metering extended to many more cameras, which can now use startAutoFocus or the focus gesture (#574)
  • [Camera2, Metering] Improvement: onAutoFocusEnd is now guaranteed to be called (#574)
  • [Camera2, Metering] Improvement: taking picture does not invalidate the previous focus (#574)
  • [Camera2, Metering] Improvement: better metering when zoomed in (#574)
  • [Real time filters] Breaking change: Filter interface signatures now accept timestamps for animations (#588)
  • [Overlays] New: you can now use addView() and removeView() to add or remove overlays at runtime (see docs) (#588)
  • [Video] Improvement: better encoder selection (#588)
  • Fix: fixed various bugs and improved stability (#588)

https://github.com/natario1/CameraView/compare/v2.2.0...v2.3.0

v2.2.0

  • [Real time filters] New: SimpleFilter class accepts a fragment shader in the constructor (#552)
  • [Real time filters] New: MultiFilter to apply more than one filter at the same time (#559)
  • [Video] Improvement: query device encoders before configuring them. Should fix issues on multiple devices (#545)
  • [Video] Fix: takeVideoSnapshot not working unless you set a max duration (#551)
  • [Video] Fix: takeVideo crashing on Camera2 LEGACY devices (#551)
  • [Frame Processing] Fix: fixed dead Frames issues and improved error messages (#572)
  • Fix: fixed CameraView appearance in the layout editor (#564)

https://github.com/natario1/CameraView/compare/v2.1.0...v2.2.0

v2.1.0

This release adds experimental support for real-time filters thanks to @agrawalsuneet. Please read the documentation page for usage instructions.

  • New: Real-time filters support (#527)
  • New: Add filters through XML (#535)
  • New: Map filter controls to scroll/pinch gestures (#537)

https://github.com/natario1/CameraView/compare/v2.0.0...v2.1.0

v2.0.0

  • Fix: bug with picture recorder (#521)
  • Fix: video snapshots appearing black (#528)
  • Fix: video snapshots exceptions and audio issues (#530)

https://github.com/natario1/CameraView/compare/v2.0.0-rc2...v2.0.0

v2.0.0-rc2
  • Fix: crashes when stopping video snapshots (#513)
  • Fix: dependencies missing, leading to runtime crashes (#517)

https://github.com/natario1/CameraView/compare/v2.0.0-rc1...v2.0.0-rc2

v2.0.0-rc1

This is likely to be the last release before v2.0.0.

  • New: support for watermarks and animated overlays (docs), thanks to @RAN3000 (#502, #421)
  • New: added onVideoRecordingStart() to be notified when video recording starts, thanks to @agrawalsuneet (#498)
  • New: added onVideoRecordingEnd() to be notified when video recording ends (#506)
  • New: added Audio.MONO and Audio.STEREO to control the channel count for videos and video snapshots (#506)
  • New: added cameraUseDeviceOrientation to choose whether picture and video outputs should consider the device orientation or not (#497)
  • Improvement: improved Camera2 stability and various bugs fixed (e.g. #501)
  • Improvement: improved video snapshots speed, quality and stability (#506)

https://github.com/natario1/CameraView/compare/v2.0.0-beta06...v2.0.0-rc1

v2.0.0-beta06
  • New: Full featured Camera2 integration! Use cameraExperimental="true" and cameraEngine="camera2" to test this out. (#490)
  • Improvement: we now choose a video recording profile that is compatible with the chosen size. Should fix some video recording issues. (#477)
  • Improvement: most internals are now open to be accessed by subclassing. Feel free to open PRs with more protected methods to be overriden. ([#494][494])
  • Breaking change: some public classes have been moved to different packages. See table here. (#482)
  • Breaking change: the listener methods onFocusStart and onFocusEnd are now called onAutoFocusStart and onAutoFocusEnd. (#484)
  • Breaking change: the gesture actions focus and focusWithMarker have been removed and replaced by autoFocus, which shows no marker. (#484)
  • New: new API called setAutoFocusMarker() lets you choose your own marker. (#484)

If you were using focus, just switch to autoFocus.

If you were using focusWithMarker, you can add back the old marker.

https://github.com/natario1/CameraView/compare/v2.0.0-beta05...v2.0.0-beta06

v2.0.0-beta05
  • Fixed FrameProcessor freeze and release behavior, was broken (#431)
  • New: new api setAutoFocusResetDelay to control the delay to reset the focus after autofocus was performed, thanks to @cneuwirt (#435)
  • Faster camera preview on layout changes (#403)
  • A few bug fixes (#471)

https://github.com/natario1/CameraView/compare/v2.0.0-beta04...v2.0.0-beta05

v2.0.0-beta04
  • Renames setPreviewSize to setPreviewStreamSize (previewSize suggests it is related to the view size but it’s not) (#393)
  • Added new APIs setSnapshotMaxWidth and setSnapshotMaxHeight (#393). You can now have a good looking preview but still take low-res snapshots using these snapshot constraints. Before this, the two sizes were coupled.

https://github.com/natario1/CameraView/compare/v2.0.0-beta03...v2.0.0-beta04

v2.0.0-beta03
  • Fixed a few bugs (#392)
  • Important fixes to video snapshot recording (#374)

https://github.com/natario1/CameraView/compare/v2.0.0-beta02...v2.0.0-beta03

v2.0.0-beta02
  • Fixed important bugs (#356)
  • Picture snapshots are now flipped when front camera is used (#360)
  • Added PictureResult.getFacing() and VideoResult.getFacing() (#360)

https://github.com/natario1/CameraView/compare/v2.0.0-beta01...v2.0.0-beta02

v2.0.0-beta01

This is the first beta release. For changes with respect to v1, please take a look at the migration guide.

v1.6.1

This is the last release before v2.

  • Fixed: crash when using TextureView in API 28, thanks to @Keyrillanskiy (#297)
  • Fixed: restore Frame Processor callbacks after taking videos, thanks to @stefanJi (#344)
  • Enhancement: when horizontal, camera now uses the last available orientation, thanks to @aartikov (#290)
  • Changed: we now swallow exceptions during autoFocus that were happening unpredictably on some devices, thanks to @mahdi-ninja (#332)

https://github.com/natario1/CameraView/compare/v1.6.0...v1.6.1

v1.6.0

  • Lifecycle support. Use setLifecycleOwner instead of calling start, stop and destroy (#265)
  • Enhancement: provide synchronous version of CameraUtils.decodeBitmap thanks to @athornz (#224)
  • Enhancement: prevent possible context leak thanks to @MatFl (#245)
  • Bug: fix crash when using default VideoCodec thanks to @Namazed (#264)
  • Enhancement: CameraException.getReason() gives some insight about the error (#265)
  • Enhancement: Common crashes are now being posted to the error callback instead of crashing the app (#265)

https://github.com/natario1/CameraView/compare/v1.5.1...v1.6.0

v1.5.1
  • Bug: byte array length for Frames was incorrect thanks to @ssakhavi (#205)
  • Bug: gestures were crashing in some conditions (#222)
  • Bug: import correctly the ExifInterface library (#222)
  • Updated dependencies thanks to @caleb-allen (#190)

https://github.com/natario1/CameraView/compare/v1.5.0...v1.5.1

v1.5.0

  • New: set encoder for video recordings with cameraVideoCodec (#174)
  • New: set max duration for videos with cameraVideoMaxDuration (#172)
  • Enhancement: reduced lag with continuous gestures (ev, zoom) (#170)
  • Bug: tap to focus was crashing on some devices (#167)
  • Bug: capturePicture was breaking if followed by another event soon after (#173)

https://github.com/natario1/CameraView/compare/v1.4.2...v1.5.0

v1.4.2
  • Add prefix to XML resources so they don’t collide, thanks to @RocketRider (#162)
  • Add videoMaxSize API and XML attribute, to set max size video in bytes, thanks to @chaitanyaraghav (#104)
  • Improved the preview size selection, thanks to @YeungKC (#133)
  • Improved the playSounds attribute, was playing incorrectly, thanks to @xp-vit (#143)

https://github.com/natario1/CameraView/compare/v1.4.1...v1.4.2

v1.4.1
  • Fixed a bug that would flip the front camera preview on some devices (#112)
  • Two new CameraOptions APIs: o.getSupportedPictureSizes() and o.getSupportedPictureAspectRatios() (#101)
  • Most controls (video quality, hdr, grid, session type, audio, white balance, flash, facing) now inherit from a base Control class (#105). This let us add new APIs:

    • CameraView.set(Control): sets the control to the given value, e.g. set(Flash.AUTO)
    • CameraOptions.supports(Control): returns true if the control is supported
    • CameraOptions.getSupportedControls(Class<? extends Control>): returns list of supported controls of a given kind

https://github.com/natario1/CameraView/compare/v1.4.0...v1.4.1

v1.4.0

  • CameraView is now completely thread-safe. All actions are asynchronous. (#97) This has some breaking drawbacks. Specifically, the get methods (e.g., getWhiteBalance) might not return the correct value while it is being changed. So don’t trust them right after you have changed the value. Instead, always check the CameraOptions to see if the value you want is supported.
  • Added error handling (#97) in CameraListener.onCameraError(CameraException). At the moment, all exceptions there are unrecoverable. When the method is called, the camera is showing a black preview. This is a good moment to show an error dialog to the user. You can also try to start() again but that is not guaranteed to work.
  • Long requested ability to set the picture output size (#99). Can be done through CameraView.setPictureSize() or through new XML attributes starting with cameraPictureSize. Please refer to docs about it.
  • Deprecated toggleFacing. It was unreliable and will be removed.
  • Deprecated getCaptureSize. Use getPictureSize instead.
  • Fixed bugs.

https://github.com/natario1/CameraView/compare/v1.3.2...v1.4.0

v1.3.2
  • Fixed a memory leak thanks to @andrewmunn (#92)
  • Reduced memory usage when using cropOutput thanks to @RobertoMorelos (#93)
  • Improved efficiency for Frame processors, recycle buffers and Frames (#94)

https://github.com/natario1/CameraView/compare/v1.3.1...v1.3.2

v1.3.1
  • Fixed a bug that would make setFacing and other APIs freeze the camera (#86)
  • Fixed ConcurrentModificationExceptions during CameraListener callbacks (#88)

https://github.com/natario1/CameraView/compare/v1.3.0...v1.3.1

v1.3.0

  • Ability to inject frame processors to do your own visual tasks (barcodes, facial recognition etc.) (#82)
  • Ability to inject external loggers (e.g. Crashlytics) to listen for internal logging events (#80)
  • Improved CameraUtils.decodeBitmap, you can now pass maxWidth and maxHeight to avoid OOM (#83)
  • Updated dependencies thanks to @v-gar (#73)

https://github.com/natario1/CameraView/compare/v1.2.3...v1.3.0