diff options
author | kongchenrui <kongchenrui@xiaomi.com> | 2024-03-26 19:30:02 +0800 |
---|---|---|
committer | Clemenz Portmann <portmannc@google.com> | 2024-03-29 18:35:50 +0000 |
commit | 68618ef95bbd46627310ed253cb1f035acc37a60 (patch) | |
tree | 9bcefa7ba0b6e474dd0689f0247906b1baf9fc58 /apps | |
parent | 397196ad04b5ba48c37bb109cf718fb22a8199f5 (diff) | |
download | cts-68618ef95bbd46627310ed253cb1f035acc37a60.tar.gz |
Fix the big difference between RAW10 and YUV
When the device supports RAW10, RAW10 and YUV will be obtained for comparison.
In this process, convert_raw_to_rgb_image will be called to convert RAW10. At
this time, whiteLevel and blackLevelPattern will be obtained, but since our
main camera Sensor can output 14bit RAW, We configure this value according to
14bit, which will cause RAW10 to become darker after the conversion is
completed and fail the test.
For the above reasons, android.sensor.dynamicWhiteLevel and
android.sensor.dynamicBlackLevel should be used when converting Raw
Bug: 330825648
Change-Id: I29d38565f9282099b7f929f779e4cd2db1d6492c
Merged-In: I60dc289b0d8057c0cb70480d1366e6871c877a28
Signed-off-by: kongchenrui <kongchenrui@xiaomi.com>
Diffstat (limited to 'apps')
-rw-r--r-- | apps/CameraITS/utils/image_processing_utils.py | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/apps/CameraITS/utils/image_processing_utils.py b/apps/CameraITS/utils/image_processing_utils.py index 9ec4391cb86..ca78139a00d 100644 --- a/apps/CameraITS/utils/image_processing_utils.py +++ b/apps/CameraITS/utils/image_processing_utils.py @@ -355,7 +355,8 @@ def convert_capture_to_planes(cap, props=None): rgb[2::3].reshape(h, w, 1)) elif cap['format'] == 'raw': assert_props_is_not_none(props) - white_level = float(props['android.sensor.info.whiteLevel']) + white_level = get_white_level(props, cap['metadata']) + logging.debug('dynamic white level: %.2f', white_level) img = numpy.ndarray( shape=(h * w,), dtype='<u2', buffer=cap['data'][0:w * h * 2]) img = img.astype(numpy.float32).reshape(h, w) / white_level @@ -405,7 +406,7 @@ def convert_capture_to_planes(cap, props=None): return [imgs[i] for i in idxs] elif cap['format'] == 'rawStats': assert_props_is_not_none(props) - white_level = float(props['android.sensor.info.whiteLevel']) + white_level = get_white_level(props, cap['metadata']) # pylint: disable=unused-variable mean_image, var_image = unpack_rawstats_capture(cap) idxs = get_canonical_cfa_order(props) @@ -479,6 +480,9 @@ def convert_raw_to_rgb_image(r_plane, gr_plane, gb_plane, b_plane, props, # Reorder black levels and gains to R,Gr,Gb,B, to match the order # of the planes. black_levels = [get_black_level(i, props, cap_res) for i in range(4)] + logging.debug('dynamic black levels: %s', black_levels) + white_level = get_white_level(props, cap_res) + logging.debug('dynamic white level: %.2f', white_level) gains = get_gains_in_canonical_order(props, gains) # Convert CCM from rational to float, as numpy arrays. @@ -613,6 +617,27 @@ def get_gains_in_canonical_order(props, gains): else: raise error_util.CameraItsError('Not supported') +def get_white_level(props, cap_res=None): + """Return the white level to use for a given capture. + + Uses a dynamic value from the capture result if available, else falls back + to the static global value in the camera characteristics. + + Args: + props: The camera properties object. + cap_res: A capture result object. + + Returns: + The white level value of type float. + """ + if (cap_res is not None and + 'android.sensor.dynamicWhiteLevel' in cap_res and + cap_res['android.sensor.dynamicWhiteLevel'] is not None): + white_level = cap_res['android.sensor.dynamicWhiteLevel'] + else: + white_level = props['android.sensor.info.whiteLevel'] + return float(white_level) + def get_black_level(chan, props, cap_res=None): """Return the black level to use for a given capture. |