CameraITS: linear tonemap update
Use eithre CONTRAST_CURVE or GAMMA_VALUE mode to configure linear
tonemap.
Bug: 20888941
Change-Id: I8cbca8772b9f08812f50af29e19367c5abe08efe
diff --git a/apps/CameraITS/pymodules/its/objects.py b/apps/CameraITS/pymodules/its/objects.py
index f6d2e2d..bc77a62 100644
--- a/apps/CameraITS/pymodules/its/objects.py
+++ b/apps/CameraITS/pymodules/its/objects.py
@@ -70,7 +70,8 @@
else:
return float(r["numerator"]) / float(r["denominator"])
-def manual_capture_request(sensitivity, exp_time, linear_tonemap=False):
+def manual_capture_request(
+ sensitivity, exp_time, linear_tonemap=False, props=None):
"""Return a capture request with everything set to manual.
Uses identity/unit color correction, and the default tonemap curve.
@@ -82,6 +83,9 @@
with.
linear_tonemap: [Optional] whether a linear tonemap should be used
in this request.
+ props: [Optional] the object returned from
+ its.device.get_camera_properties(). Must present when
+ linear_tonemap is True.
Returns:
The default manual capture request, ready to be passed to the
@@ -105,10 +109,20 @@
"android.shading.mode": 1
}
if linear_tonemap:
- req["android.tonemap.mode"] = 0
- req["android.tonemap.curveRed"] = [0.0,0.0, 1.0,1.0]
- req["android.tonemap.curveGreen"] = [0.0,0.0, 1.0,1.0]
- req["android.tonemap.curveBlue"] = [0.0,0.0, 1.0,1.0]
+ assert(props is not None)
+ #CONTRAST_CURVE mode
+ if 0 in props["android.tonemap.availableToneMapModes"]:
+ req["android.tonemap.mode"] = 0
+ req["android.tonemap.curveRed"] = [0.0,0.0, 1.0,1.0]
+ req["android.tonemap.curveGreen"] = [0.0,0.0, 1.0,1.0]
+ req["android.tonemap.curveBlue"] = [0.0,0.0, 1.0,1.0]
+ #GAMMA_VALUE mode
+ elif 3 in props["android.tonemap.availableToneMapModes"]:
+ req["android.tonemap.mode"] = 3
+ req["android.tonemap.gamma"] = 1.0
+ else:
+ print "Linear tonemap is not supported"
+ assert(False)
return req
def auto_capture_request():
diff --git a/apps/CameraITS/tests/scene1/test_crop_region_raw.py b/apps/CameraITS/tests/scene1/test_crop_region_raw.py
index 189e987..7973755 100644
--- a/apps/CameraITS/tests/scene1/test_crop_region_raw.py
+++ b/apps/CameraITS/tests/scene1/test_crop_region_raw.py
@@ -64,7 +64,7 @@
# Use a manual request with a linear tonemap so that the YUV and RAW
# should look the same (once converted by the its.image module).
e, s = its.target.get_target_exposure_combos(cam)["minSensitivity"]
- req = its.objects.manual_capture_request(s,e, True)
+ req = its.objects.manual_capture_request(s,e, True, props)
cap1_raw, cap1_yuv = cam.do_capture(req, cam.CAP_RAW_YUV)
# Capture with a crop region.
diff --git a/apps/CameraITS/tests/scene1/test_jpeg.py b/apps/CameraITS/tests/scene1/test_jpeg.py
index 25c2038..7bc038d 100644
--- a/apps/CameraITS/tests/scene1/test_jpeg.py
+++ b/apps/CameraITS/tests/scene1/test_jpeg.py
@@ -33,7 +33,7 @@
its.caps.per_frame_control(props))
e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"]
- req = its.objects.manual_capture_request(s, e, True)
+ req = its.objects.manual_capture_request(s, e, True, props)
# YUV
size = its.objects.get_available_output_sizes("yuv", props)[0]
diff --git a/apps/CameraITS/tests/scene1/test_latching.py b/apps/CameraITS/tests/scene1/test_latching.py
index 3bc4356..176f01b 100644
--- a/apps/CameraITS/tests/scene1/test_latching.py
+++ b/apps/CameraITS/tests/scene1/test_latching.py
@@ -45,20 +45,20 @@
b_means = []
reqs = [
- its.objects.manual_capture_request(s, e, True),
- its.objects.manual_capture_request(s, e, True),
- its.objects.manual_capture_request(s*2,e, True),
- its.objects.manual_capture_request(s*2,e, True),
- its.objects.manual_capture_request(s, e, True),
- its.objects.manual_capture_request(s, e, True),
- its.objects.manual_capture_request(s, e*2, True),
- its.objects.manual_capture_request(s, e, True),
- its.objects.manual_capture_request(s*2,e, True),
- its.objects.manual_capture_request(s, e, True),
- its.objects.manual_capture_request(s, e*2, True),
- its.objects.manual_capture_request(s, e, True),
- its.objects.manual_capture_request(s, e*2, True),
- its.objects.manual_capture_request(s, e*2, True),
+ its.objects.manual_capture_request(s, e, True, props),
+ its.objects.manual_capture_request(s, e, True, props),
+ its.objects.manual_capture_request(s*2,e, True, props),
+ its.objects.manual_capture_request(s*2,e, True, props),
+ its.objects.manual_capture_request(s, e, True, props),
+ its.objects.manual_capture_request(s, e, True, props),
+ its.objects.manual_capture_request(s, e*2, True, props),
+ its.objects.manual_capture_request(s, e, True, props),
+ its.objects.manual_capture_request(s*2,e, True, props),
+ its.objects.manual_capture_request(s, e, True, props),
+ its.objects.manual_capture_request(s, e*2, True, props),
+ its.objects.manual_capture_request(s, e, True, props),
+ its.objects.manual_capture_request(s, e*2, True, props),
+ its.objects.manual_capture_request(s, e*2, True, props),
]
caps = cam.do_capture(reqs, fmt)
diff --git a/apps/CameraITS/tests/scene1/test_param_color_correction.py b/apps/CameraITS/tests/scene1/test_param_color_correction.py
index b7fdc7b..09b3707 100644
--- a/apps/CameraITS/tests/scene1/test_param_color_correction.py
+++ b/apps/CameraITS/tests/scene1/test_param_color_correction.py
@@ -42,7 +42,7 @@
# Baseline request
e, s = its.target.get_target_exposure_combos(cam)["midSensitivity"]
- req = its.objects.manual_capture_request(s, e, True)
+ req = its.objects.manual_capture_request(s, e, True, props)
req["android.colorCorrection.mode"] = 0
# Transforms:
diff --git a/apps/CameraITS/tests/scene1/test_param_exposure_time.py b/apps/CameraITS/tests/scene1/test_param_exposure_time.py
index e6078d9..0c0aab1 100644
--- a/apps/CameraITS/tests/scene1/test_param_exposure_time.py
+++ b/apps/CameraITS/tests/scene1/test_param_exposure_time.py
@@ -39,7 +39,7 @@
e,s = its.target.get_target_exposure_combos(cam)["midExposureTime"]
for i,e_mult in enumerate([0.8, 0.9, 1.0, 1.1, 1.2]):
- req = its.objects.manual_capture_request(s, e * e_mult, True)
+ req = its.objects.manual_capture_request(s, e * e_mult, True, props)
cap = cam.do_capture(req)
img = its.image.convert_capture_to_rgb_image(cap)
its.image.write_image(
diff --git a/apps/CameraITS/tests/scene1/test_param_flash_mode.py b/apps/CameraITS/tests/scene1/test_param_flash_mode.py
index aae56aa..38f864f 100644
--- a/apps/CameraITS/tests/scene1/test_param_flash_mode.py
+++ b/apps/CameraITS/tests/scene1/test_param_flash_mode.py
@@ -39,7 +39,7 @@
# linear tonemap.
e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"]
e /= 4
- req = its.objects.manual_capture_request(s, e, True)
+ req = its.objects.manual_capture_request(s, e, True, props)
for f in [0,1,2]:
req["android.flash.mode"] = f
diff --git a/apps/CameraITS/tests/scene1/test_tonemap_sequence.py b/apps/CameraITS/tests/scene1/test_tonemap_sequence.py
index 18ca506..7c87ca2 100644
--- a/apps/CameraITS/tests/scene1/test_tonemap_sequence.py
+++ b/apps/CameraITS/tests/scene1/test_tonemap_sequence.py
@@ -40,7 +40,7 @@
means = []
# Capture 3 manual shots with a linear tonemap.
- req = its.objects.manual_capture_request(sens, exp_time, True)
+ req = its.objects.manual_capture_request(sens, exp_time, True, props)
for i in [0,1,2]:
cap = cam.do_capture(req)
img = its.image.convert_capture_to_rgb_image(cap)
diff --git a/apps/CameraITS/tests/scene1/test_yuv_jpeg_all.py b/apps/CameraITS/tests/scene1/test_yuv_jpeg_all.py
index 1b278ef..0c428fc 100644
--- a/apps/CameraITS/tests/scene1/test_yuv_jpeg_all.py
+++ b/apps/CameraITS/tests/scene1/test_yuv_jpeg_all.py
@@ -35,7 +35,7 @@
# Use a manual request with a linear tonemap so that the YUV and JPEG
# should look the same (once converted by the its.image module).
e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"]
- req = its.objects.manual_capture_request(s, e, True)
+ req = its.objects.manual_capture_request(s, e, True, props)
rgbs = []
diff --git a/apps/CameraITS/tests/scene1/test_yuv_plus_jpeg.py b/apps/CameraITS/tests/scene1/test_yuv_plus_jpeg.py
index 6daa243..9ce8d76 100644
--- a/apps/CameraITS/tests/scene1/test_yuv_plus_jpeg.py
+++ b/apps/CameraITS/tests/scene1/test_yuv_plus_jpeg.py
@@ -37,7 +37,7 @@
# Use a manual request with a linear tonemap so that the YUV and JPEG
# should look the same (once converted by the its.image module).
e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"]
- req = its.objects.manual_capture_request(s, e, True)
+ req = its.objects.manual_capture_request(s, e, True, props)
cap_yuv, cap_jpeg = cam.do_capture(req, [fmt_yuv, fmt_jpeg])
diff --git a/apps/CameraITS/tests/scene1/test_yuv_plus_raw.py b/apps/CameraITS/tests/scene1/test_yuv_plus_raw.py
index eb01c1a..f13801b 100644
--- a/apps/CameraITS/tests/scene1/test_yuv_plus_raw.py
+++ b/apps/CameraITS/tests/scene1/test_yuv_plus_raw.py
@@ -36,7 +36,7 @@
# Use a manual request with a linear tonemap so that the YUV and RAW
# should look the same (once converted by the its.image module).
e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"]
- req = its.objects.manual_capture_request(s, e, True)
+ req = its.objects.manual_capture_request(s, e, True, props)
cap_raw, cap_yuv = cam.do_capture(req, cam.CAP_RAW_YUV)
diff --git a/apps/CameraITS/tests/scene1/test_yuv_plus_raw10.py b/apps/CameraITS/tests/scene1/test_yuv_plus_raw10.py
index 910a8ea..e52946d 100644
--- a/apps/CameraITS/tests/scene1/test_yuv_plus_raw10.py
+++ b/apps/CameraITS/tests/scene1/test_yuv_plus_raw10.py
@@ -36,7 +36,7 @@
# Use a manual request with a linear tonemap so that the YUV and RAW
# should look the same (once converted by the its.image module).
e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"]
- req = its.objects.manual_capture_request(s, e, True)
+ req = its.objects.manual_capture_request(s, e, True, props)
cap_raw, cap_yuv = cam.do_capture(req,
[{"format":"raw10"}, {"format":"yuv"}])
diff --git a/apps/CameraITS/tests/scene1/test_yuv_plus_raw12.py b/apps/CameraITS/tests/scene1/test_yuv_plus_raw12.py
index bbd9144..c5c3c73 100644
--- a/apps/CameraITS/tests/scene1/test_yuv_plus_raw12.py
+++ b/apps/CameraITS/tests/scene1/test_yuv_plus_raw12.py
@@ -36,7 +36,7 @@
# Use a manual request with a linear tonemap so that the YUV and RAW
# should look the same (once converted by the its.image module).
e, s = its.target.get_target_exposure_combos(cam)["midExposureTime"]
- req = its.objects.manual_capture_request(s, e, True)
+ req = its.objects.manual_capture_request(s, e, True, props)
cap_raw, cap_yuv = cam.do_capture(req,
[{"format":"raw12"}, {"format":"yuv"}])