Cameraview: Native integration to speed up things like cropOutput

Created on 20 Nov 2017  路  4Comments  路  Source: natario1/CameraView

Taking picture without cropping output takes ~0.5 - 0.8 seconds. When set crop output to true it takes ~3 seconds. Is there any way to make it faster?

performance help wanted enhancement

All 4 comments

It's not only slow, it's also prone to out of memory errors #91 . We take the JPEG, decompress to Bitmap in full resolution, crop the Bitmap, compress again to JPEG. This is a relic from CameraKit and it sucks.

  • To make it faster in your app you can simply not use it. Use wrap_content for width and height so there is nothing to be cropped.

  • To make it faster in the library we need to use the NDK and do the cropping in native code. There are native libraries (example) that can crop a JPEG file without even decompressing, no middle steps. That would be super fast and no OOM at all.

If some of you wants to inject the NDK in CameraView, that's very welcome!

This looks easy:

In this case we don't need the NDK at runtime (just for building the .so?) and we get bindings already?

I don't think that this is very important and necessary. the reasons are following:

  • .so files will need to be included for all platforms, which results in significant increase of lib size
  • it is possible to fail more gracefully using WeakReferences for example
  • I'll take a closer look at current crop task in order to try optimizing current implementation

I also don't think this is very important, at least it's not coming soon... let's close for now.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Aissa-H picture Aissa-H  路  3Comments

HD-AD picture HD-AD  路  8Comments

leandro1995 picture leandro1995  路  6Comments

vedmedenko picture vedmedenko  路  9Comments

g-rabah picture g-rabah  路  11Comments