Sleep is under rated

I always seem like I don’t have enough time. Like I have so much on my to-do list today, what can I cut out to make more time to do them? Most people to “save time” cut out a few hours of sleep. It…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Android Camera Library Comparison

Fotoapparat vs. CameraKit

Before we dive into their differences, let’s take a look at some of their similarities.

Lets take a look at the features each library includes.

Notes:

Both libraries allow for simple settings such as focus, flash, and camera front/back selection to be changed dynamically. However, they differ in how much configuration they allow beyond that.

CameraKit prefers ease of use over customization. It automatically selects the camera and preview resolutions for you and automatically crops the preview frames to fit in the space available.

Conversely, Fotoapparat favors customization and provides clever APIs that expose the device’s capabilities and allow them to be configured however you desire. In addition to being able to set specific resolutions, you can also configure the sensor’s sensitivity (ISO) and the frame processor’s FPS setting. The APIs provide filters and selectors to help you dynamically select ideal settings. For example, it allows for advanced logic such as:

The code to implement that is very simple and looks like this:

CameraKit claims to be “extremely performant” and has optimized its bitmap processing code by moving it into native code. In this section we’ll compare each library’s capture speed to see if CameraKit’s native code gives it an advantage over Fotoapparat.

First, we’ll compare the capture speed of taking full resolution (4032x2268) images and receiving the output as a byte array with rotation correction.

Note: All data below was captured on a Samsung Galaxy S8 and measurements were averaged over ten runs.

Both libraries also support a quick capture mode that captures a lower resolution image from the preview stream. CameraKit calls this mode “Still” capture and Fotoapparat supports this via its frame processor. Let’s look at how the capture speed compares using the quick capture mode in each library.

Fotoapparat supports an additional option which allows images to be saved directly to a file instead of receiving them as a byte array. This option can be applied to both standard capture mode and quick capture mode. Since CameraKit doesn’t support this option, we’ll compare how Fotoapparat’s ‘Save to File’ option affects performance of its capture modes.

Saving to a file is 4x quicker than receiving the image as a byte array

The main reason saving to a file is quicker is because the image’s orientation information is written to the file’s EXIF data which means the image doesn’t have to be rotated programmatically.

To test stability, both libraries’ sample apps were tested across a variety of devices ranging from Android 4.1.1 to 7.0.

✓ == successful image capture; ✘ == fatal crash

Fotoapparat was crash-free and was able to successfully capture images on all devices tested. CameraKit crashed on 4 of 12 devices due to two distinct issues.

CameraKit is significantly larger than Fotoapparat due to its use of native code. If size is a concern and you don’t need support for all architectures included (hint: you don’t), you can reduce CameraKit’s size by using NDK abiFilters in your build.gradle file to only include the architectures that your project needs. For example, including the filter below which only includes armeabi-v7a and x86 reduces CameraKit’s size by 73% (from 1.5MB down to 0.4MB).

Both libraries have a great community that are actively developing new features, so visit their repos to view their development progress or contribute to their roadmap.

DISCLOSURE STATEMENT: These opinions are those of the author. Unless noted otherwise in this post, Capital One is not affiliated with, nor is it endorsed by, any of the companies mentioned. All trademarks and other intellectual property used or displayed are the ownership of their respective owners. This article is © 2017 Capital One.

Add a comment

Related posts:

IdentityMind joins DataBroker DAO alliance

The DataBroker DAO Alliance is gradually taking shape. One of the most recent members we could welcome is IdentityMind, a risk and compliance platform used to help validate that individuals and…

Why Instagram Is the Worst Social Media for Mental Health

Instagram is the worst social media network for mental health and wellbeing, according to a recent survey of almost 1,500 teens and young adults. While the photo-based platform got points for…

WHO ARE YOU?

It must have been one of the first sessions I had with my therapist. I remember that virtual meeting cause covid was happening, and I had to appear on that zoom call with my yellow, not fashionable…