natario1 / CameraView

📸 A well documented, high-level Android interface that makes capturing pictures and videos easy, addressing all of the common issues and needs. Real-time filters, gestures, watermarks, frame processing, RAW, output of any size.
https://natario1.github.io/CameraView
Other
4.89k stars 922 forks source link

Fix issue #1239 , Redmi RAW crash #1240

Open michelerenzullo opened 1 year ago

michelerenzullo commented 1 year ago

bug

When switching to RAW Mode, we set mCaptureSize field using computeCaptureSize(), this one relies on the Set<Size> of supportedPictureSizes, picking the biggest, that's the problem: some manufacturer like in Redmi Note 8 Pro, returns as RAW_SENSOR sizes:

RAW_SENSOR sizes: 
[4640x3472@(33.333, 33.3), 9280x6944@(50.000, 33.3)]

But 9280x6944 it's a lie, since the maximum sensor pixel array is 4640x3472px . So while for JPEG it's not crashing because they might use some kinda of interpolation to upsample, for RAW it will since the only capture size allowed is the one set in SENSOR_INFO_PRE_CORRECTION_ACTIVE_ARRAY_SIZE ( or SENSOR_INFO_PIXEL_ARRAY_SIZE if the first is null ) Enclosed dump of Camera2 API in Redmi Note 8 Pro camera2info-Redmi_Redmi_Note_8_Pro.txt

To Reproduce

Steps to reproduce the behavior, possibly in the demo app:

  1. Go to Settings in demo app
  2. Select Picture Format "dng"
  3. Exception #2 , camera stop java.lang.AssertionError: Height and width of image buffer did not match height and width of either the preCorrectionActiveArraySize or the pixelArraySize.

Expected behavior

Switch to dng mode and capture in raw