summaryrefslogtreecommitdiff
path: root/test-cli/test/helpers/cv_display_test.py
diff options
context:
space:
mode:
authorManel Caro <mcaro@iatec.biz>2021-11-06 16:28:38 +0100
committerManel Caro <mcaro@iatec.biz>2021-11-06 16:28:38 +0100
commitcf19bfe18cbd283b188a858ee1629f9909c924f4 (patch)
tree1efb23519727130058401df090ab1b5f4cc8ba99 /test-cli/test/helpers/cv_display_test.py
parentb6932fbaf898724ae87c29f8965621610f377084 (diff)
parentd5b273a3b58a250742049df4ca0ef0ba54f53d33 (diff)
downloadboard-cf19bfe18cbd283b188a858ee1629f9909c924f4.zip
board-cf19bfe18cbd283b188a858ee1629f9909c924f4.tar.gz
board-cf19bfe18cbd283b188a858ee1629f9909c924f4.tar.bz2
Merge branch 'sopa-test'rel.0.1sopa-test
Diffstat (limited to 'test-cli/test/helpers/cv_display_test.py')
-rw-r--r--test-cli/test/helpers/cv_display_test.py28
1 files changed, 10 insertions, 18 deletions
diff --git a/test-cli/test/helpers/cv_display_test.py b/test-cli/test/helpers/cv_display_test.py
index b54a698..3a3004f 100644
--- a/test-cli/test/helpers/cv_display_test.py
+++ b/test-cli/test/helpers/cv_display_test.py
@@ -14,8 +14,7 @@ def pattern_detect(cam_device=0):
# RETURN 0 only if the test is ok
msg="0"
# Capture the corresponding camera device [0,1]
- #capture = cv2.VideoCapture(0)
- capture = cv2.VideoCapture("/dev/v4l/by-id/usb-Creative_Technology_Ltd._Live__Cam_Sync_HD_VF0770-video-index0")
+ capture = cv2.VideoCapture(0)
try:
_, image = capture.read()
except:
@@ -64,12 +63,10 @@ def pattern_detect(cam_device=0):
# After testing the gamma factor correction is computed with the green color
# gamma = gamma_factor / blue+red into green part
# gamma factor = 50-100
- #gamma = (100 / (avg_color_rawg[0] + avg_color_rawg[2] + 1))
- gamma=1
+ gamma = (100 / (avg_color_rawg[0] + avg_color_rawg[2] + 1))
# Adjust the image acording to this gamma value
adjusted = adjust_gamma(image, gamma=gamma)
-# adjusted=image
- cv2.imwrite( "/home/root/result_hdmi_img.jpg", adjusted);
+
# Calculate again the average color using the gamma adjusted image
# Crop the gamma adjusted image for wach color section
red_cal = adjusted[y1:y2, xr1:xr2]
@@ -109,19 +106,14 @@ def pattern_detect(cam_device=0):
mask_r = mask0 + mask1
# mask_r = cv2.inRange(hsv, lower_red, upper_red)
# Perform a morphological open to expand
-# kernel = np.ones((5, 5), np.uint8)
-# closing_r = cv2.morphologyEx(mask_r, cv2.MORPH_OPEN, kernel)
-# closing_b = cv2.morphologyEx(mask_b, cv2.MORPH_OPEN, kernel)
-# closing_g = cv2.morphologyEx(mask_g, cv2.MORPH_OPEN, kernel)
+ kernel = np.ones((15, 15), np.uint8)
+ closing_r = cv2.morphologyEx(mask_r, cv2.MORPH_OPEN, kernel)
+ closing_b = cv2.morphologyEx(mask_b, cv2.MORPH_OPEN, kernel)
+ closing_g = cv2.morphologyEx(mask_g, cv2.MORPH_OPEN, kernel)
# Count the number of pixels that are not of the corresponding color (black)
-# count_r = cv2.countNonZero(closing_r)
-# count_b = cv2.countNonZero(closing_b)
-# count_g = cv2.countNonZero(closing_g)
- #-----------
- count_r = cv2.countNonZero(mask_r)
- count_b = cv2.countNonZero(mask_b)
- count_g = cv2.countNonZero(mask_g)
- #-------
+ count_r = cv2.countNonZero(closing_r)
+ count_b = cv2.countNonZero(closing_b)
+ count_g = cv2.countNonZero(closing_g)
if (count_r < 5):
msg = "RED COUNT FAIL"
return msg