CameraITS: updates to support openCV 3.2.0 & python 2.7.13
Bug: 74345857
Bug: 72652590
Change-Id: I856cb9e652befcc050f5136c1792fc6f17f6ca82
diff --git a/apps/CameraITS/build/envsetup.sh b/apps/CameraITS/build/envsetup.sh
index de50ad8..753a90d 100644
--- a/apps/CameraITS/build/envsetup.sh
+++ b/apps/CameraITS/build/envsetup.sh
@@ -37,6 +37,17 @@
echo ">> Require Python $M module" >&2
done
+CV2_VER=$(python -c "\
+try:
+ import cv2
+ print cv2.__version__
+except:
+ print \"N/A\"
+")
+
+echo $CV2_VER | grep -q -e "^2.4" -e "^3.2" || \
+ echo ">> Require python opencv 2.4. or 3.2. Got $CV2_VER" >&2
+
export PYTHONPATH="$PWD/pymodules:$PYTHONPATH"
for M in device objects image caps dng target error
diff --git a/apps/CameraITS/pymodules/its/image.py b/apps/CameraITS/pymodules/its/image.py
index a5ac60b..259bcdb 100644
--- a/apps/CameraITS/pymodules/its/image.py
+++ b/apps/CameraITS/pymodules/its/image.py
@@ -587,10 +587,10 @@
"""
hfull = img.shape[0]
wfull = img.shape[1]
- xtile = math.ceil(xnorm * wfull)
- ytile = math.ceil(ynorm * hfull)
- wtile = math.floor(wnorm * wfull)
- htile = math.floor(hnorm * hfull)
+ xtile = int(math.ceil(xnorm * wfull))
+ ytile = int(math.ceil(ynorm * hfull))
+ wtile = int(math.floor(wnorm * wfull))
+ htile = int(math.floor(hnorm * hfull))
return img[ytile:ytile+htile,xtile:xtile+wtile,:].copy()
def compute_image_means(img):
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 9642061..8bebfae 100644
--- a/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py
+++ b/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py
@@ -261,8 +261,13 @@
cv2.THRESH_BINARY + cv2.THRESH_OTSU)
# connected component
- contours, hierarchy = cv2.findContours(255-img_bw, cv2.RETR_TREE,
- cv2.CHAIN_APPROX_SIMPLE)
+ cv2_version = cv2.__version__
+ if cv2_version.startswith('2.4.'):
+ contours, hierarchy = cv2.findContours(255-img_bw, cv2.RETR_TREE,
+ cv2.CHAIN_APPROX_SIMPLE)
+ elif cv2_version.startswith('3.2.'):
+ _, contours, hierarchy = cv2.findContours(255-img_bw, cv2.RETR_TREE,
+ cv2.CHAIN_APPROX_SIMPLE)
# Check each component and find the black circle
min_cmpt = size[0] * size[1] * 0.005