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 03b45d1..13c907c 100644
--- a/apps/CameraITS/build/envsetup.sh
+++ b/apps/CameraITS/build/envsetup.sh
@@ -45,8 +45,8 @@
print \"N/A\"
")
-echo $CV2_VER | grep -q "^2.4" || \
- echo ">> Require python opencv 2.4. Got $CV2_VER" >&2
+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"
diff --git a/apps/CameraITS/pymodules/its/image.py b/apps/CameraITS/pymodules/its/image.py
index 0057eb7..4b69791 100644
--- a/apps/CameraITS/pymodules/its/image.py
+++ b/apps/CameraITS/pymodules/its/image.py
@@ -608,10 +608,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 13dbe84..06db8bb 100644
--- a/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py
+++ b/apps/CameraITS/tests/scene4/test_aspect_ratio_and_crop.py
@@ -272,8 +272,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