1

I am trying to figure out the limitations of using camera2 with devices that have hardware level support LEGACY. From the official docs for android camera2 api:

LEGACY: These devices expose capabilities to apps through the Camera API2 interfaces that are approximately the same capabilities as those exposed to apps through the Camera API1 interfaces. The legacy frameworks code conceptually translates Camera API2 calls into Camera API1 calls; legacy devices do not support Camera API2 features such as per-frame controls.

I have found this to be false... In fact I expected that sensor orientation obtained through Camera.CameraInfo camInfo -> camInfo.orientation (docs) would be the same as cameraCharacteristics.get(CameraCharacteristics.SENSOR_ORIENTATION) (docs)

However it is not the case!

  • Camera API 1 returns an orientation angle of 90°
  • Camera API 2 returns an orientation angle of 270°

Notice that this is quite different! Landscape orientation != inverse landscape orientation! For example it would completely break the Matrix transformation from the screen preview coordinates to the camera sensor space.

Am I missing something? Is this intended behaviour? I am using a Xiaomi Redmi 5 plus with Android 8.1 (is this a manufacturer issue?)

Thanks

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
dnhyde
  • 1,265
  • 2
  • 14
  • 24
  • Make sure that you compare the answers for the same camera. Could it be that you ask **camera2** characteristics for the front-facing camera, while the **Camera.CameraInfo** applies to back-facing camera? Also, I am curious to know which value, **90°** or **270°**, is correct (*I mean, does this [answer](https://stackoverflow.com/a/10905851/192373) produce correct results, or not*). – Alex Cohn Jun 22 '19 at 22:04
  • 1
    Thanks for your comment, I ask the characteristics for the back camera in both cases (do you think that manufacturers can employ different sensor orientation depending if the front or back camera? It can happen of course but for now I did not encounter such cases) Anyway the correct answer is 90° but I am starting to wonder if camera2 tells the rotation to apply to be in camera sensor space and camera1 the rotation to apply to be in display coordinate space (even if the docs state that it should be the rotation to transform from display coordinate to camera coordinates) – dnhyde Jun 23 '19 at 20:36

1 Answers1

1

If the two queries apply to the same camera, this is definitely a bug, and Xiaomi is responsible. Bugs do happen even on mainstream devices, and the camera API adaptation layers tend to be more buggy than other APIs.

You may find that for LEGACY devices, camera2 layer introduces extra overhead, and vice versa. You get best performance if you work trhough the deprecated Camera API for LEGACY devices, and through the camera2 API for other devices. I know it's painful to support two versions of your code, but when you need to utilize the device in the best way, you have to pay this price.

Alex Cohn
  • 56,089
  • 9
  • 113
  • 307
  • Ok thank you for your answer! I did in fact have a wrapper around the two camera APIs but I was hoping I could use only camera 2 after 5 years of deprecation of the old Camera API. The thing is that moving to Android 9 the old Camera API will not work any longer (at least this happened on Samsung Galaxy S9) so the deprecation of Camera 1 is becoming real at last, Android 9 will force manufacturers to implement Camera2 right? A strong alternative would be Camera X but I tried it and it's still in alpha so it's too soon to adopt it – dnhyde Jun 24 '19 at 11:54