5

I am using the camera2 API to get a stream of images of format ImageFormat.YUV_420_888. I need to do some processing on them with a library that requires sending the image as an RGB byte array (so the byte array length = width * height * 3)

I used this thread (and also probably all the others) to convert the Image into an RGB byte array (which seems to be working, at least the result byte array is the one I need).

Also, here is the exact code I used to convert the YUV_420 to RGB, in Kotlin, with some updates: https://gist.github.com/VictorMotogna/e7a8493af65be994f29f5508660dd4a9

The problem is that the conversion crashes with the message A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0xe00000084 in tid 20776 (package name), pid 20776 after a few tries.

I've tried other image formats, other conversions, nothing seems to work - I either get the same crash (when using YUV_420 or NV21) or I can't get the correct image/conversion.

One thing that seemed to help was: With android:hardwareAccelerated="false" the app crashed after a lot more runs than with android:hardwareAccelerated="true"

Does anyone know how to fix it?

Victor Motogna
  • 731
  • 1
  • 12
  • 22

1 Answers1

0

Things I noticed in your example code:

  • you destroy your allocations before you are finished using them (can be reused like the rs context)
  • you define and set default launch options (not needed)
SerialSensor
  • 315
  • 2
  • 11