1 2<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 3<html><head><title>Python: module telemetry.internal.image_processing.screen_finder</title> 4<meta charset="utf-8"> 5</head><body bgcolor="#f0f0f8"> 6 7<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> 8<tr bgcolor="#7799ee"> 9<td valign=bottom> <br> 10<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong><a href="telemetry.html"><font color="#ffffff">telemetry</font></a>.<a href="telemetry.internal.html"><font color="#ffffff">internal</font></a>.<a href="telemetry.internal.image_processing.html"><font color="#ffffff">image_processing</font></a>.screen_finder</strong></big></big></font></td 11><td align=right valign=bottom 12><font color="#ffffff" face="helvetica, arial"><a href=".">index</a><br><a href="../telemetry/internal/image_processing/screen_finder.py">telemetry/internal/image_processing/screen_finder.py</a></font></td></tr></table> 13 <p><tt># Copyright 2014 The Chromium Authors. All rights reserved.<br> 14# Use of this source code is governed by a BSD-style license that can be<br> 15# found in the LICENSE file.<br> 16#<br> 17# This script attempts to detect the region of a camera's field of view that<br> 18# contains the screen of the device we are testing.<br> 19#<br> 20# Usage: ./screen_finder.py path_to_video 0 0 --verbose</tt></p> 21<p> 22<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 23<tr bgcolor="#aa55cc"> 24<td colspan=3 valign=bottom> <br> 25<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> 26 27<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> 28<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="copy.html">copy</a><br> 29<a href="cv2.html">cv2</a><br> 30<a href="telemetry.internal.image_processing.cv_util.html">telemetry.internal.image_processing.cv_util</a><br> 31</td><td width="25%" valign=top><a href="telemetry.internal.util.external_modules.html">telemetry.internal.util.external_modules</a><br> 32<a href="telemetry.internal.image_processing.frame_generator.html">telemetry.internal.image_processing.frame_generator</a><br> 33<a href="logging.html">logging</a><br> 34</td><td width="25%" valign=top><a href="numpy.html">numpy</a><br> 35<a href="os.html">os</a><br> 36<a href="sys.html">sys</a><br> 37</td><td width="25%" valign=top><a href="telemetry.internal.image_processing.video_file_frame_generator.html">telemetry.internal.image_processing.video_file_frame_generator</a><br> 38</td></tr></table></td></tr></table><p> 39<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 40<tr bgcolor="#ee77aa"> 41<td colspan=3 valign=bottom> <br> 42<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> 43 44<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> 45<td width="100%"><dl> 46<dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> 47</font></dt><dd> 48<dl> 49<dt><font face="helvetica, arial"><a href="telemetry.internal.image_processing.screen_finder.html#ScreenFinder">ScreenFinder</a> 50</font></dt></dl> 51</dd> 52</dl> 53 <p> 54<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 55<tr bgcolor="#ffc8d8"> 56<td colspan=3 valign=bottom> <br> 57<font color="#000000" face="helvetica, arial"><a name="ScreenFinder">class <strong>ScreenFinder</strong></a>(<a href="__builtin__.html#object">__builtin__.object</a>)</font></td></tr> 58 59<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> 60<td colspan=2><tt>Finds and extracts device screens from video.<br> 61 <br> 62Sample Usage:<br> 63 sf = <a href="#ScreenFinder">ScreenFinder</a>(sys.argv[1])<br> 64 while sf.<a href="#ScreenFinder-HasNext">HasNext</a>():<br> 65 ret, screen = sf.<a href="#ScreenFinder-GetNext">GetNext</a>()<br> 66 <br> 67Attributes:<br> 68 _lost_corners: Each index represents whether or not we lost track of that<br> 69 corner on the previous frame. Ordered by [top-right, top-left,<br> 70 bottom-left, bottom-right]<br> 71 _frame: An unmodified copy of the frame we're currently processing.<br> 72 _frame_debug: A copy of the frame we're currently processing, may be<br> 73 modified at any time, used for debugging.<br> 74 _frame_grey: A greyscale copy of the frame we're currently processing.<br> 75 _frame_edges: A Canny Edge detected copy of the frame we're currently<br> 76 processing.<br> 77 _screen_size: The size of device screen in the video when first detected.<br> 78 _avg_corners: Exponentially weighted average of the previous corner<br> 79 locations.<br> 80 _prev_corners: The location of the corners in the previous frame.<br> 81 _lost_corner_frames: A counter of the number of successive frames in which<br> 82 we've lost a corner location.<br> 83 _border: See |border| above.<br> 84 _min_line_length: The minimum length a line must be before we consider it<br> 85 a possible screen edge.<br> 86 _frame_generator: See |frame_generator| above.<br> 87 _width, _height: The width and height of the frame.<br> 88 _anglesp5, _anglesm5: The angles for each point we look at in the grid<br> 89 when computing brightness, constant across frames.<br> </tt></td></tr> 90<tr><td> </td> 91<td width="100%">Methods defined here:<br> 92<dl><dt><a name="ScreenFinder-GetNext"><strong>GetNext</strong></a>(self)</dt><dd><tt>Gets the next screen image.<br> 93 <br> 94Returns:<br> 95 A numpy matrix containing the screen surrounded by the number of border<br> 96 pixels specified in initialization, and the location of the detected<br> 97 screen corners in the current frame, if a screen is found. The returned<br> 98 screen is guaranteed to be the same size at each frame.<br> 99 'None' and 'None' if no screen was found on the current frame.<br> 100 <br> 101Raises:<br> 102 FrameReadError: An error occurred in the FrameGenerator.<br> 103 RuntimeError: This method was called when no frames were available.</tt></dd></dl> 104 105<dl><dt><a name="ScreenFinder-HasNext"><strong>HasNext</strong></a>(self)</dt><dd><tt>True if there are more frames available to process.</tt></dd></dl> 106 107<dl><dt><a name="ScreenFinder-__init__"><strong>__init__</strong></a>(self, frame_generator, border<font color="#909090">=5</font>)</dt><dd><tt>Initializes the <a href="#ScreenFinder">ScreenFinder</a> <a href="__builtin__.html#object">object</a>.<br> 108 <br> 109Args:<br> 110 frame_generator: FrameGenerator, An initialized Video Frame Generator.<br> 111 border: int, number of pixels of border to be kept when cropping the<br> 112 detected screen.<br> 113 <br> 114Raises:<br> 115 FrameReadError: The frame generator may output a read error during<br> 116 initialization.</tt></dd></dl> 117 118<hr> 119Data descriptors defined here:<br> 120<dl><dt><strong>__dict__</strong></dt> 121<dd><tt>dictionary for instance variables (if defined)</tt></dd> 122</dl> 123<dl><dt><strong>__weakref__</strong></dt> 124<dd><tt>list of weak references to the object (if defined)</tt></dd> 125</dl> 126<hr> 127Data and other attributes defined here:<br> 128<dl><dt><strong>CANNY_HYSTERESIS_THRESH_HIGH</strong> = 500</dl> 129 130<dl><dt><strong>CANNY_HYSTERESIS_THRESH_LOW</strong> = 300</dl> 131 132<dl><dt><strong>CORNER_AVERAGE_WEIGHT</strong> = 0.5</dl> 133 134<dl><dt><strong>CornerData</strong> = <class 'telemetry.internal.image_processing.screen_finder.CornerData'></dl> 135 136<dl><dt><strong>DEBUG</strong> = False</dl> 137 138<dl><dt><strong>MAX_INTERFRAME_MOTION</strong> = 25</dl> 139 140<dl><dt><strong>MIN_CORNER_ABSOLUTE_BRIGHTNESS</strong> = 60</dl> 141 142<dl><dt><strong>MIN_RELATIVE_BRIGHTNESS_FACTOR</strong> = 1.5</dl> 143 144<dl><dt><strong>MIN_SCREEN_WIDTH</strong> = 40</dl> 145 146<dl><dt><strong>RESET_AFTER_N_BAD_FRAMES</strong> = 2</dl> 147 148<dl><dt><strong>SMALL_ANGLE</strong> = 0.08726646259971647</dl> 149 150<dl><dt><strong>ScreenNotFoundError</strong> = <class 'telemetry.internal.image_processing.screen_finder.ScreenNotFoundError'></dl> 151 152</td></tr></table></td></tr></table><p> 153<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 154<tr bgcolor="#eeaa77"> 155<td colspan=3 valign=bottom> <br> 156<font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> 157 158<tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> 159<td width="100%"><dl><dt><a name="-main"><strong>main</strong></a>()</dt></dl> 160</td></tr></table><p> 161<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> 162<tr bgcolor="#55aa55"> 163<td colspan=3 valign=bottom> <br> 164<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> 165 166<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> 167<td width="100%"><strong>division</strong> = _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)</td></tr></table> 168</body></html>