<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><head><title>Python: module telemetry.internal.image_processing.screen_finder</title> <meta charset="utf-8"> </head><body bgcolor="#f0f0f8"> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading"> <tr bgcolor="#7799ee"> <td valign=bottom> <br> <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 ><td align=right valign=bottom ><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> <p><tt># Copyright 2014 The Chromium Authors. All rights reserved.<br> # Use of this source code is governed by a BSD-style license that can be<br> # found in the LICENSE file.<br> #<br> # This script attempts to detect the region of a camera's field of view that<br> # contains the screen of the device we are testing.<br> #<br> # Usage: ./screen_finder.py path_to_video 0 0 --verbose</tt></p> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#aa55cc"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr> <tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td> <td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="copy.html">copy</a><br> <a href="cv2.html">cv2</a><br> <a href="telemetry.internal.image_processing.cv_util.html">telemetry.internal.image_processing.cv_util</a><br> </td><td width="25%" valign=top><a href="telemetry.internal.util.external_modules.html">telemetry.internal.util.external_modules</a><br> <a href="telemetry.internal.image_processing.frame_generator.html">telemetry.internal.image_processing.frame_generator</a><br> <a href="logging.html">logging</a><br> </td><td width="25%" valign=top><a href="numpy.html">numpy</a><br> <a href="os.html">os</a><br> <a href="sys.html">sys</a><br> </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> </td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ee77aa"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr> <tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td> <td width="100%"><dl> <dt><font face="helvetica, arial"><a href="__builtin__.html#object">__builtin__.object</a> </font></dt><dd> <dl> <dt><font face="helvetica, arial"><a href="telemetry.internal.image_processing.screen_finder.html#ScreenFinder">ScreenFinder</a> </font></dt></dl> </dd> </dl> <p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#ffc8d8"> <td colspan=3 valign=bottom> <br> <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> <tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td> <td colspan=2><tt>Finds and extracts device screens from video.<br> <br> Sample Usage:<br> sf = <a href="#ScreenFinder">ScreenFinder</a>(sys.argv[1])<br> while sf.<a href="#ScreenFinder-HasNext">HasNext</a>():<br> ret, screen = sf.<a href="#ScreenFinder-GetNext">GetNext</a>()<br> <br> Attributes:<br> _lost_corners: Each index represents whether or not we lost track of that<br> corner on the previous frame. Ordered by [top-right, top-left,<br> bottom-left, bottom-right]<br> _frame: An unmodified copy of the frame we're currently processing.<br> _frame_debug: A copy of the frame we're currently processing, may be<br> modified at any time, used for debugging.<br> _frame_grey: A greyscale copy of the frame we're currently processing.<br> _frame_edges: A Canny Edge detected copy of the frame we're currently<br> processing.<br> _screen_size: The size of device screen in the video when first detected.<br> _avg_corners: Exponentially weighted average of the previous corner<br> locations.<br> _prev_corners: The location of the corners in the previous frame.<br> _lost_corner_frames: A counter of the number of successive frames in which<br> we've lost a corner location.<br> _border: See |border| above.<br> _min_line_length: The minimum length a line must be before we consider it<br> a possible screen edge.<br> _frame_generator: See |frame_generator| above.<br> _width, _height: The width and height of the frame.<br> _anglesp5, _anglesm5: The angles for each point we look at in the grid<br> when computing brightness, constant across frames.<br> </tt></td></tr> <tr><td> </td> <td width="100%">Methods defined here:<br> <dl><dt><a name="ScreenFinder-GetNext"><strong>GetNext</strong></a>(self)</dt><dd><tt>Gets the next screen image.<br> <br> Returns:<br> A numpy matrix containing the screen surrounded by the number of border<br> pixels specified in initialization, and the location of the detected<br> screen corners in the current frame, if a screen is found. The returned<br> screen is guaranteed to be the same size at each frame.<br> 'None' and 'None' if no screen was found on the current frame.<br> <br> Raises:<br> FrameReadError: An error occurred in the FrameGenerator.<br> RuntimeError: This method was called when no frames were available.</tt></dd></dl> <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> <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> <br> Args:<br> frame_generator: FrameGenerator, An initialized Video Frame Generator.<br> border: int, number of pixels of border to be kept when cropping the<br> detected screen.<br> <br> Raises:<br> FrameReadError: The frame generator may output a read error during<br> initialization.</tt></dd></dl> <hr> Data descriptors defined here:<br> <dl><dt><strong>__dict__</strong></dt> <dd><tt>dictionary for instance variables (if defined)</tt></dd> </dl> <dl><dt><strong>__weakref__</strong></dt> <dd><tt>list of weak references to the object (if defined)</tt></dd> </dl> <hr> Data and other attributes defined here:<br> <dl><dt><strong>CANNY_HYSTERESIS_THRESH_HIGH</strong> = 500</dl> <dl><dt><strong>CANNY_HYSTERESIS_THRESH_LOW</strong> = 300</dl> <dl><dt><strong>CORNER_AVERAGE_WEIGHT</strong> = 0.5</dl> <dl><dt><strong>CornerData</strong> = <class 'telemetry.internal.image_processing.screen_finder.CornerData'></dl> <dl><dt><strong>DEBUG</strong> = False</dl> <dl><dt><strong>MAX_INTERFRAME_MOTION</strong> = 25</dl> <dl><dt><strong>MIN_CORNER_ABSOLUTE_BRIGHTNESS</strong> = 60</dl> <dl><dt><strong>MIN_RELATIVE_BRIGHTNESS_FACTOR</strong> = 1.5</dl> <dl><dt><strong>MIN_SCREEN_WIDTH</strong> = 40</dl> <dl><dt><strong>RESET_AFTER_N_BAD_FRAMES</strong> = 2</dl> <dl><dt><strong>SMALL_ANGLE</strong> = 0.08726646259971647</dl> <dl><dt><strong>ScreenNotFoundError</strong> = <class 'telemetry.internal.image_processing.screen_finder.ScreenNotFoundError'></dl> </td></tr></table></td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#eeaa77"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr> <tr><td bgcolor="#eeaa77"><tt> </tt></td><td> </td> <td width="100%"><dl><dt><a name="-main"><strong>main</strong></a>()</dt></dl> </td></tr></table><p> <table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section"> <tr bgcolor="#55aa55"> <td colspan=3 valign=bottom> <br> <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr> <tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td> <td width="100%"><strong>division</strong> = _Feature((2, 2, 0, 'alpha', 2), (3, 0, 0, 'alpha', 0), 8192)</td></tr></table> </body></html>