CameraITS: use preCorrectionActiveArraySize not activeArraySize
Add tolerance on activeArraySize for full images in test_crop_region_raw to allow
for rounding.
Small gpylint fixes in areas affected.
bug: 110943471
Change-Id: I1dbc238a67ac3d326156491d5617801cb3e08a9c
diff --git a/apps/CameraITS/pymodules/its/image.py b/apps/CameraITS/pymodules/its/image.py
index 1654faa8..3ea6fa3 100644
--- a/apps/CameraITS/pymodules/its/image.py
+++ b/apps/CameraITS/pymodules/its/image.py
@@ -151,7 +151,7 @@
lsbs = img[::, 4::5].reshape(h,w/4)
lsbs = numpy.right_shift(
numpy.packbits(numpy.unpackbits(lsbs).reshape(h,w/4,4,2),3), 6)
- # Pair the LSB bits group to pixel 0 instead of pixel 3
+ # Pair the LSB bits group to 0th pixel instead of 3rd pixel
lsbs = lsbs.reshape(h,w/4,4)[:,:,::-1]
lsbs = lsbs.reshape(h,w)
# Fuse the MSBs and LSBs back together
@@ -267,8 +267,8 @@
buffer=cap["data"][0:w*h*2])
img = img.astype(numpy.float32).reshape(h,w) / white_level
# Crop the raw image to the active array region.
- if props.has_key("android.sensor.info.activeArraySize") \
- and props["android.sensor.info.activeArraySize"] is not None \
+ if props.has_key("android.sensor.info.preCorrectionActiveArraySize") \
+ and props["android.sensor.info.preCorrectionActiveArraySize"] is not None \
and props.has_key("android.sensor.info.pixelArraySize") \
and props["android.sensor.info.pixelArraySize"] is not None:
# Note that the Rect class is defined such that the left,top values
@@ -277,10 +277,10 @@
# computed as right-left, rather than right-left+1, etc.
wfull = props["android.sensor.info.pixelArraySize"]["width"]
hfull = props["android.sensor.info.pixelArraySize"]["height"]
- xcrop = props["android.sensor.info.activeArraySize"]["left"]
- ycrop = props["android.sensor.info.activeArraySize"]["top"]
- wcrop = props["android.sensor.info.activeArraySize"]["right"]-xcrop
- hcrop = props["android.sensor.info.activeArraySize"]["bottom"]-ycrop
+ xcrop = props["android.sensor.info.preCorrectionActiveArraySize"]["left"]
+ ycrop = props["android.sensor.info.preCorrectionActiveArraySize"]["top"]
+ wcrop = props["android.sensor.info.preCorrectionActiveArraySize"]["right"]-xcrop
+ hcrop = props["android.sensor.info.preCorrectionActiveArraySize"]["bottom"]-ycrop
assert(wfull >= wcrop >= 0)
assert(hfull >= hcrop >= 0)
assert(wfull - wcrop >= xcrop >= 0)
diff --git a/apps/CameraITS/tests/scene1/test_crop_region_raw.py b/apps/CameraITS/tests/scene1/test_crop_region_raw.py
index 8754a8c..26cdc74 100644
--- a/apps/CameraITS/tests/scene1/test_crop_region_raw.py
+++ b/apps/CameraITS/tests/scene1/test_crop_region_raw.py
@@ -12,21 +12,22 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import its.image
+import os.path
import its.caps
import its.device
+import its.image
import its.objects
import its.target
import numpy
-import os.path
+
+CROP_FULL_ERROR_THRESHOLD = 3 # pixels
+CROP_REGION_ERROR_THRESHOLD = 0.01 # reltol
+DIFF_THRESH = 0.05 # reltol
+NAME = os.path.basename(__file__).split(".")[0]
+
def main():
- """Test that raw streams are not croppable.
- """
- NAME = os.path.basename(__file__).split(".")[0]
-
- DIFF_THRESH = 0.05
- CROP_REGION_ERROR_THRESHOLD = 0.01
+ """Test that raw streams are not croppable."""
with its.device.ItsSession() as cam:
props = cam.get_camera_properties()
@@ -36,7 +37,7 @@
not its.caps.mono_camera(props))
# Calculate the active sensor region for a full (non-cropped) image.
- a = props['android.sensor.info.activeArraySize']
+ a = props["android.sensor.info.activeArraySize"]
ax, ay = a["left"], a["top"]
aw, ah = a["right"] - a["left"], a["bottom"] - a["top"]
print "Active sensor region: (%d,%d %dx%d)" % (ax, ay, aw, ah)
@@ -79,10 +80,10 @@
# need to perfectly match the one that was requested.
imgs = {}
for s, cap, cr_expected, err_delta in [
- ("yuv_full",cap1_yuv,full_region,0),
- ("raw_full",cap1_raw,full_region,0),
- ("yuv_crop",cap2_yuv,crop_region,CROP_REGION_ERROR_THRESHOLD),
- ("raw_crop",cap2_raw,crop_region,CROP_REGION_ERROR_THRESHOLD)]:
+ ("yuv_full", cap1_yuv, full_region, CROP_FULL_ERROR_THRESHOLD),
+ ("raw_full", cap1_raw, full_region, CROP_FULL_ERROR_THRESHOLD),
+ ("yuv_crop", cap2_yuv, crop_region, CROP_REGION_ERROR_THRESHOLD),
+ ("raw_crop", cap2_raw, crop_region, CROP_REGION_ERROR_THRESHOLD)]:
# Convert the capture to RGB and dump to a file.
img = its.image.convert_capture_to_rgb_image(cap, props=props)
diff --git a/apps/CameraITS/tests/scene1/test_dng_noise_model.py b/apps/CameraITS/tests/scene1/test_dng_noise_model.py
index 6c11692..c447ae5 100644
--- a/apps/CameraITS/tests/scene1/test_dng_noise_model.py
+++ b/apps/CameraITS/tests/scene1/test_dng_noise_model.py
@@ -51,10 +51,10 @@
white_level = float(props['android.sensor.info.whiteLevel'])
cfa_idxs = its.image.get_canonical_cfa_order(props)
- aax = props['android.sensor.info.activeArraySize']['left']
- aay = props['android.sensor.info.activeArraySize']['top']
- aaw = props['android.sensor.info.activeArraySize']['right']-aax
- aah = props['android.sensor.info.activeArraySize']['bottom']-aay
+ aax = props['android.sensor.info.preCorrectionActiveArraySize']['left']
+ aay = props['android.sensor.info.preCorrectionActiveArraySize']['top']
+ aaw = props['android.sensor.info.preCorrectionActiveArraySize']['right']-aax
+ aah = props['android.sensor.info.preCorrectionActiveArraySize']['bottom']-aay
# Expose for the scene with min sensitivity
sens_min, sens_max = props['android.sensor.info.sensitivityRange']
diff --git a/apps/CameraITS/tests/scene1/test_exposure.py b/apps/CameraITS/tests/scene1/test_exposure.py
index 870dc62..ed469a3 100644
--- a/apps/CameraITS/tests/scene1/test_exposure.py
+++ b/apps/CameraITS/tests/scene1/test_exposure.py
@@ -36,10 +36,10 @@
def get_raw_active_array_size(props):
"""Return the active array w, h from props."""
- aaw = (props['android.sensor.info.activeArraySize']['right'] -
- props['android.sensor.info.activeArraySize']['left'])
- aah = (props['android.sensor.info.activeArraySize']['bottom'] -
- props['android.sensor.info.activeArraySize']['top'])
+ aaw = (props['android.sensor.info.preCorrectionActiveArraySize']['right'] -
+ props['android.sensor.info.preCorrectionActiveArraySize']['left'])
+ aah = (props['android.sensor.info.preCorrectionActiveArraySize']['bottom'] -
+ props['android.sensor.info.preCorrectionActiveArraySize']['top'])
return aaw, aah
diff --git a/apps/CameraITS/tests/scene1/test_raw_burst_sensitivity.py b/apps/CameraITS/tests/scene1/test_raw_burst_sensitivity.py
index 04a3386..b6b0514 100644
--- a/apps/CameraITS/tests/scene1/test_raw_burst_sensitivity.py
+++ b/apps/CameraITS/tests/scene1/test_raw_burst_sensitivity.py
@@ -63,10 +63,10 @@
caps = cam.do_capture(reqs, cam.CAP_RAW)
else:
# Get the active array width and height.
- aax = props["android.sensor.info.activeArraySize"]["left"]
- aay = props["android.sensor.info.activeArraySize"]["top"]
- aaw = props["android.sensor.info.activeArraySize"]["right"]-aax
- aah = props["android.sensor.info.activeArraySize"]["bottom"]-aay
+ aax = props["android.sensor.info.preCorrectionActiveArraySize"]["left"]
+ aay = props["android.sensor.info.preCorrectionActiveArraySize"]["top"]
+ aaw = props["android.sensor.info.preCorrectionActiveArraySize"]["right"]-aax
+ aah = props["android.sensor.info.preCorrectionActiveArraySize"]["bottom"]-aay
# Compute stats on a grid across each image.
caps = cam.do_capture(reqs,
{"format": "rawStats",
diff --git a/apps/CameraITS/tests/scene1/test_raw_exposure.py b/apps/CameraITS/tests/scene1/test_raw_exposure.py
index 8fafe4a..b3004a7 100644
--- a/apps/CameraITS/tests/scene1/test_raw_exposure.py
+++ b/apps/CameraITS/tests/scene1/test_raw_exposure.py
@@ -55,10 +55,10 @@
white_level = float(props["android.sensor.info.whiteLevel"])
black_levels = [its.image.get_black_level(i,props) for i in range(4)]
# Get the active array width and height.
- aax = props["android.sensor.info.activeArraySize"]["left"]
- aay = props["android.sensor.info.activeArraySize"]["top"]
- aaw = props["android.sensor.info.activeArraySize"]["right"]-aax
- aah = props["android.sensor.info.activeArraySize"]["bottom"]-aay
+ aax = props["android.sensor.info.preCorrectionActiveArraySize"]["left"]
+ aay = props["android.sensor.info.preCorrectionActiveArraySize"]["top"]
+ aaw = props["android.sensor.info.preCorrectionActiveArraySize"]["right"]-aax
+ aah = props["android.sensor.info.preCorrectionActiveArraySize"]["bottom"]-aay
raw_stat_fmt = {"format": "rawStats",
"gridWidth": aaw/IMG_STATS_GRID,
"gridHeight": aah/IMG_STATS_GRID}
diff --git a/apps/CameraITS/tests/scene1/test_raw_sensitivity.py b/apps/CameraITS/tests/scene1/test_raw_sensitivity.py
index 44a3b41..db69e36 100644
--- a/apps/CameraITS/tests/scene1/test_raw_sensitivity.py
+++ b/apps/CameraITS/tests/scene1/test_raw_sensitivity.py
@@ -68,10 +68,10 @@
(NAME, s, var))
else:
# Get the active array width and height.
- aax = props["android.sensor.info.activeArraySize"]["left"]
- aay = props["android.sensor.info.activeArraySize"]["top"]
- aaw = props["android.sensor.info.activeArraySize"]["right"]-aax
- aah = props["android.sensor.info.activeArraySize"]["bottom"]-aay
+ aax = props["android.sensor.info.preCorrectionActiveArraySize"]["left"]
+ aay = props["android.sensor.info.preCorrectionActiveArraySize"]["top"]
+ aaw = props["android.sensor.info.preCorrectionActiveArraySize"]["right"]-aax
+ aah = props["android.sensor.info.preCorrectionActiveArraySize"]["bottom"]-aay
white_level = float(props["android.sensor.info.whiteLevel"])
cap = cam.do_capture(req,
{"format": "rawStats",
diff --git a/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py b/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py
index ee55002..92dfd0d 100644
--- a/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py
+++ b/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py
@@ -56,7 +56,7 @@
matched entry in AR_CHECKED
"""
match_ar = None
- sensor_size = props["android.sensor.info.activeArraySize"]
+ sensor_size = props["android.sensor.info.preCorrectionActiveArraySize"]
sensor_ar = (float(abs(sensor_size["right"] - sensor_size["left"])) /
abs(sensor_size["bottom"] - sensor_size["top"]))
for ar_string in AR_CHECKED: