diff options
author | Sylvain Pineau <sylvain.pineau@canonical.com> | 2016-01-05 14:41:30 +0000 |
---|---|---|
committer | Sylvain Pineau <> | 2016-01-05 14:41:30 +0000 |
commit | d2594002f2faeef746f596f9d5e818407171578d (patch) | |
tree | 04c2c2612cb59777d09fbafd81d1af127cc5095f | |
parent | ca6edab30361f5a871e82b83e2012662089fb312 (diff) | |
parent | 603fb26366703d5039f678629147329e70a7045b (diff) |
"automatic merge of lp:~sylvain-pineau/checkbox/sru_provider/ by tarmac [r=sylvain-pineau,pwlars][bug=][author=sylvain-pineau]"
-rwxr-xr-x | bin/screenshot_validation | 161 | ||||
-rw-r--r-- | jobs/graphics.txt.in | 23 | ||||
-rw-r--r-- | units/sru.pxu | 116 |
3 files changed, 0 insertions, 300 deletions
diff --git a/bin/screenshot_validation b/bin/screenshot_validation deleted file mode 100755 index 5529f79..0000000 --- a/bin/screenshot_validation +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/env python2.7 -# Copyright 2014 Canonical Ltd. -# Written by: -# Sylvain Pineau <sylvain.pineau@canonical.com> -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3, -# as published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -from __future__ import absolute_import, print_function - -import argparse -import imghdr -import os - -import cv2 - - -def create_capture(args): - try: - device_no = int(os.path.realpath(args.device)[-1]) - except ValueError: - raise SystemExit( - "ERROR: video source not found: {}".format(args.device)) - cap = cv2.VideoCapture(device_no) - # The camera driver will adjust the capture size - cap.set(cv2.cv.CV_CAP_PROP_FRAME_WIDTH, args.width) - cap.set(cv2.cv.CV_CAP_PROP_FRAME_HEIGHT, args.height) - if cap is None or not cap.isOpened(): - raise SystemExit( - "ERROR: unable to open video source: {}".format(args.device)) - return cap - -parser = argparse.ArgumentParser( - description=''' -Automatically validates a screenshot captured with an external camera using -OpenCV ORB detection and a FLANN Matcher (Fast Approximate Nearest Neighbor -Search Library) - -Put your camera (HD recommended) in front of your monitor. -A query image (the INPUT positional argument) is displayed on your primary -device and several captures (see -F) are analyzed to find a positive match. - -On success returns 0. Otherwise a non-zero value is returned and a -diagnostic message is printed on standard error. -''', - formatter_class=argparse.RawDescriptionHelpFormatter -) -parser.add_argument('input', - metavar='INPUT', - help='Input file to use as query image') -parser.add_argument('--min_matches', - type=int, - default=20, - help='Minimum threshold value to validate a \ - positive match') -parser.add_argument('-F', '--frames', - type=int, - default=10, - help='Set the number of frames to capture and analyze \ - Minimum: 3') -parser.add_argument('-d', '--device', - default='/dev/video0', - help='Set the device to use') -parser.add_argument('--height', - type=int, - default=900, - help='Set the capture height') -parser.add_argument('--width', - type=int, - default=1600, - help='Set the capture width') -parser.add_argument('-o', '--output', - default=None, - help='Save the screenshot to the specified filename') -args = parser.parse_args() - -if args.frames < 3: - parser.print_help() - raise SystemExit(1) -if not imghdr.what(args.input): - raise SystemExit( - "ERROR: unable to read the input file: {}".format(args.input)) -queryImage = cv2.imread(args.input, cv2.CV_LOAD_IMAGE_GRAYSCALE) - -cv2.namedWindow("test", cv2.WND_PROP_FULLSCREEN) -cv2.setWindowProperty("test", - cv2.WND_PROP_FULLSCREEN, - cv2.cv.CV_WINDOW_FULLSCREEN) -cv2.imshow("test", queryImage) -cv2.waitKey(1000) - -# Initiate ORB features detector -orb = cv2.ORB(nfeatures=100000) - -# Find the keypoints and descriptors with ORB -kp1, des1 = orb.detectAndCompute(queryImage, None) - -# Use the FLANN Matcher (Fast Approximate Nearest Neighbor Search Library) -flann_params = dict(algorithm=6, # FLANN_INDEX_LSH - table_number=6, - key_size=12, - multi_probe_level=1) - -flann = cv2.FlannBasedMatcher(flann_params, {}) - -source = 0 -cap = create_capture(args) -results = [] -img = None - -for i in range(args.frames): - - ret, img = cap.read() - if ret is False: - raise SystemExit( - "ERROR: unable to capture from video source: {}".format(source)) - trainImage = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) - - # Find the keypoints and descriptors with ORB - kp2, des2 = orb.detectAndCompute(trainImage, None) - if des2 is None: - raise SystemExit( - "ERROR: Not enough keypoints in video capture, aborting...") - - matches = flann.knnMatch(des1, des2, k=2) - - # store all the good matches as per Lowe's ratio test - good_matches = [m[0] for m in matches if len(m) == 2 and - m[0].distance < m[1].distance * 0.7] - - results.append(len(good_matches)) - cv2.waitKey(1000) - -cv2.destroyAllWindows() - -if args.output: - cv2.imwrite(args.output, img) - print('Screenshot saved to: {}'.format(args.output)) - -# Remove Max and Min values from results -results.remove(max(results)) -results.remove(min(results)) - -avg = sum(results) / len(results) - -if avg > args.min_matches: - print("Match found! ({} > {})".format(avg, args.min_matches)) -else: - raise SystemExit( - "ERROR: Not enough matches are found - {} < {}".format( - avg, - args.min_matches)) diff --git a/jobs/graphics.txt.in b/jobs/graphics.txt.in index 24b603f..690b8ee 100644 --- a/jobs/graphics.txt.in +++ b/jobs/graphics.txt.in @@ -551,29 +551,6 @@ command: plugin: shell category_id: 2013.com.canonical.plainbox::graphics -id: graphics/screenshot_opencv_validation -requires: package.name == 'python-opencv' -environ: EXTERNAL_WEBCAM_DEVICE -command: - screenshot_validation \ - ${PLAINBOX_PROVIDER_DATA}/images/logo_Ubuntu_stacked_black.png \ - --device=${EXTERNAL_WEBCAM_DEVICE:-/dev/external_webcam} \ - -o ${PLAINBOX_SESSION_SHARE}/screenshot_opencv_validation.jpg -_summary: Test that a screenshot is valid, automatically -_description: - Take a screengrab of the screen displaying a black and white Ubuntu logo. - Check that the screenshot matches the original file using OpenCV ORB detection. - -plugin: attachment -category_id: 2013.com.canonical.plainbox::graphics -id: screenshot_opencv_validation.jpg -depends: graphics/screenshot_opencv_validation -command: base64 ${PLAINBOX_SESSION_SHARE}/screenshot_opencv_validation.jpg -_description: Attaches the screenshot captured in graphics/screenshot_opencv_validation. -_summary: Attach the screenshot captured for the automatically validated screenshot test - -plugin: shell -category_id: 2013.com.canonical.plainbox::graphics id: graphics/screen-capture-internal _summary: Obtains a simple screen capture estimated_duration: 1.0 diff --git a/units/sru.pxu b/units/sru.pxu deleted file mode 100644 index 6c18f48..0000000 --- a/units/sru.pxu +++ /dev/null @@ -1,116 +0,0 @@ -id: sru -_name: All SRU Tests -unit: test plan -description: - This test plan contains tests that are useful for validating a Stable - Release Update (SRU) on Ubuntu Certified systems. This test plan is not - recommended for, nor will it be accepted for self-testing purposes. -include: - IEEE_80211 - block_device - cdimage - cpuinfo - device - dmi - dpkg - efi - environment - gconf - lsb - meminfo - module - package - rtc - sleep - uname - xinput - acpi_sleep_attachment - codecs_attachment - cpuinfo_attachment - dmesg_attachment - dmi_attachment - dmidecode_attachment - efi_attachment - lspci_attachment - meminfo_attachment - modprobe_attachment - modules_attachment - sysctl_attachment - sysfs_attachment - udev_attachment - lsmod_attachment - audio/alsa_record_playback_automated - bluetooth/detect-output - camera/detect - camera/multiple-resolution-images - cpu/scaling_test - cpu/scaling_test-log-attach - cpu/offlining_test - cpu/topology - disk/read_performance_.* - graphics/xorg-version - graphics/1_compiz_check_.* - graphics/xorg-failsafe - graphics/xorg-process - graphics/1_screenshot_.* - 1_screenshot_.*.jpg - graphics/1_screenshot_fullscreen_video_.* - 1_screenshot_fullscreen_video_.*.jpg - graphics/screenshot_opencv_validation - screenshot_opencv_validation.jpg - install/apt-get-gets-updates - mediacard/sd-preinserted - memory/info - memory/check - ethernet/detect - ethernet/info_automated - networking/http - networking/gateway_ping - power-management/tickless_idle - power-management/rtc - power-management/fwts_wakealarm - power-management/fwts_wakealarm-log-attach - usb/detect - usb/storage-preinserted - wireless/wireless_scanning - wireless/wireless_connection_wpa_bg - wireless/wireless_connection_open_bg - wireless/wireless_connection_wpa_n - wireless/wireless_connection_open_n - wireless/monitor_wireless_connection_udp - suspend/audio_before_suspend - suspend/bluetooth_obex_send_before_suspend - suspend/bluetooth_obex_browse_before_suspend - suspend/bluetooth_obex_get_before_suspend - suspend/cpu_before_suspend - suspend/network_before_suspend - suspend/memory_before_suspend - suspend/suspend_advanced_auto - suspend/suspend-single-log-check - suspend/suspend-single-log-attach - suspend/audio_after_suspend_auto - suspend/network_resume_time_auto - suspend/wifi_resume_time_auto - suspend/usb_storage_preinserted_after_suspend - suspend/record_playback_after_suspend_auto - suspend/bluetooth_obex_send_after_suspend_auto - suspend/bluetooth_obex_browse_after_suspend_auto - suspend/bluetooth_obex_get_after_suspend_auto - suspend/cpu_after_suspend_auto - suspend/memory_after_suspend_auto - suspend/wireless_connection_after_suspend_wpa_bg_auto - suspend/wireless_connection_after_suspend_open_bg_auto - suspend/wireless_connection_after_suspend_wpa_n_auto - suspend/wireless_connection_after_suspend_open_n_auto - suspend/gpu_lockup_after_suspend - suspend/screenshot_after_suspend - screenshot_after_suspend.jpg -bootstrap_include: - disk/read_performance - graphics/generator_compiz_check - graphics/generator_screenshot - graphics/generator_screenshot.jpg - graphics/generator_screenshot_fullscreen_video - graphics/generator_screenshot_fullscreen_video.jpg - graphics/generator_screenshot_fullscreen_video - graphics/generator_screenshot_fullscreen_video.jpg |