Home | History | Annotate | Download | only in pydoc
      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>&nbsp;<br>
     10 <font color="#ffffff" face="helvetica, arial">&nbsp;<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>#&nbsp;Copyright&nbsp;2014&nbsp;The&nbsp;Chromium&nbsp;Authors.&nbsp;All&nbsp;rights&nbsp;reserved.<br>
     14 #&nbsp;Use&nbsp;of&nbsp;this&nbsp;source&nbsp;code&nbsp;is&nbsp;governed&nbsp;by&nbsp;a&nbsp;BSD-style&nbsp;license&nbsp;that&nbsp;can&nbsp;be<br>
     15 #&nbsp;found&nbsp;in&nbsp;the&nbsp;LICENSE&nbsp;file.<br>
     16 #<br>
     17 #&nbsp;This&nbsp;script&nbsp;attempts&nbsp;to&nbsp;detect&nbsp;the&nbsp;region&nbsp;of&nbsp;a&nbsp;camera's&nbsp;field&nbsp;of&nbsp;view&nbsp;that<br>
     18 #&nbsp;contains&nbsp;the&nbsp;screen&nbsp;of&nbsp;the&nbsp;device&nbsp;we&nbsp;are&nbsp;testing.<br>
     19 #<br>
     20 #&nbsp;Usage:&nbsp;./screen_finder.py&nbsp;path_to_video&nbsp;0&nbsp;0&nbsp;--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>&nbsp;<br>
     25 <font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
     26     
     27 <tr><td bgcolor="#aa55cc"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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>&nbsp;<br>
     42 <font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
     43     
     44 <tr><td bgcolor="#ee77aa"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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>&nbsp;<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>&nbsp;&nbsp;&nbsp;</tt></td>
     60 <td colspan=2><tt>Finds&nbsp;and&nbsp;extracts&nbsp;device&nbsp;screens&nbsp;from&nbsp;video.<br>
     61 &nbsp;<br>
     62 Sample&nbsp;Usage:<br>
     63 &nbsp;&nbsp;sf&nbsp;=&nbsp;<a href="#ScreenFinder">ScreenFinder</a>(sys.argv[1])<br>
     64 &nbsp;&nbsp;while&nbsp;sf.<a href="#ScreenFinder-HasNext">HasNext</a>():<br>
     65 &nbsp;&nbsp;&nbsp;&nbsp;ret,&nbsp;screen&nbsp;=&nbsp;sf.<a href="#ScreenFinder-GetNext">GetNext</a>()<br>
     66 &nbsp;<br>
     67 Attributes:<br>
     68 &nbsp;&nbsp;_lost_corners:&nbsp;Each&nbsp;index&nbsp;represents&nbsp;whether&nbsp;or&nbsp;not&nbsp;we&nbsp;lost&nbsp;track&nbsp;of&nbsp;that<br>
     69 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;corner&nbsp;on&nbsp;the&nbsp;previous&nbsp;frame.&nbsp;Ordered&nbsp;by&nbsp;[top-right,&nbsp;top-left,<br>
     70 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;bottom-left,&nbsp;bottom-right]<br>
     71 &nbsp;&nbsp;_frame:&nbsp;An&nbsp;unmodified&nbsp;copy&nbsp;of&nbsp;the&nbsp;frame&nbsp;we're&nbsp;currently&nbsp;processing.<br>
     72 &nbsp;&nbsp;_frame_debug:&nbsp;A&nbsp;copy&nbsp;of&nbsp;the&nbsp;frame&nbsp;we're&nbsp;currently&nbsp;processing,&nbsp;may&nbsp;be<br>
     73 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;modified&nbsp;at&nbsp;any&nbsp;time,&nbsp;used&nbsp;for&nbsp;debugging.<br>
     74 &nbsp;&nbsp;_frame_grey:&nbsp;A&nbsp;greyscale&nbsp;copy&nbsp;of&nbsp;the&nbsp;frame&nbsp;we're&nbsp;currently&nbsp;processing.<br>
     75 &nbsp;&nbsp;_frame_edges:&nbsp;A&nbsp;Canny&nbsp;Edge&nbsp;detected&nbsp;copy&nbsp;of&nbsp;the&nbsp;frame&nbsp;we're&nbsp;currently<br>
     76 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;processing.<br>
     77 &nbsp;&nbsp;_screen_size:&nbsp;The&nbsp;size&nbsp;of&nbsp;device&nbsp;screen&nbsp;in&nbsp;the&nbsp;video&nbsp;when&nbsp;first&nbsp;detected.<br>
     78 &nbsp;&nbsp;_avg_corners:&nbsp;Exponentially&nbsp;weighted&nbsp;average&nbsp;of&nbsp;the&nbsp;previous&nbsp;corner<br>
     79 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;locations.<br>
     80 &nbsp;&nbsp;_prev_corners:&nbsp;The&nbsp;location&nbsp;of&nbsp;the&nbsp;corners&nbsp;in&nbsp;the&nbsp;previous&nbsp;frame.<br>
     81 &nbsp;&nbsp;_lost_corner_frames:&nbsp;A&nbsp;counter&nbsp;of&nbsp;the&nbsp;number&nbsp;of&nbsp;successive&nbsp;frames&nbsp;in&nbsp;which<br>
     82 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;we've&nbsp;lost&nbsp;a&nbsp;corner&nbsp;location.<br>
     83 &nbsp;&nbsp;_border:&nbsp;See&nbsp;|border|&nbsp;above.<br>
     84 &nbsp;&nbsp;_min_line_length:&nbsp;The&nbsp;minimum&nbsp;length&nbsp;a&nbsp;line&nbsp;must&nbsp;be&nbsp;before&nbsp;we&nbsp;consider&nbsp;it<br>
     85 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;a&nbsp;possible&nbsp;screen&nbsp;edge.<br>
     86 &nbsp;&nbsp;_frame_generator:&nbsp;See&nbsp;|frame_generator|&nbsp;above.<br>
     87 &nbsp;&nbsp;_width,&nbsp;_height:&nbsp;The&nbsp;width&nbsp;and&nbsp;height&nbsp;of&nbsp;the&nbsp;frame.<br>
     88 &nbsp;&nbsp;_anglesp5,&nbsp;_anglesm5:&nbsp;The&nbsp;angles&nbsp;for&nbsp;each&nbsp;point&nbsp;we&nbsp;look&nbsp;at&nbsp;in&nbsp;the&nbsp;grid<br>
     89 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;when&nbsp;computing&nbsp;brightness,&nbsp;constant&nbsp;across&nbsp;frames.<br>&nbsp;</tt></td></tr>
     90 <tr><td>&nbsp;</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&nbsp;the&nbsp;next&nbsp;screen&nbsp;image.<br>
     93 &nbsp;<br>
     94 Returns:<br>
     95 &nbsp;&nbsp;A&nbsp;numpy&nbsp;matrix&nbsp;containing&nbsp;the&nbsp;screen&nbsp;surrounded&nbsp;by&nbsp;the&nbsp;number&nbsp;of&nbsp;border<br>
     96 &nbsp;&nbsp;pixels&nbsp;specified&nbsp;in&nbsp;initialization,&nbsp;and&nbsp;the&nbsp;location&nbsp;of&nbsp;the&nbsp;detected<br>
     97 &nbsp;&nbsp;screen&nbsp;corners&nbsp;in&nbsp;the&nbsp;current&nbsp;frame,&nbsp;if&nbsp;a&nbsp;screen&nbsp;is&nbsp;found.&nbsp;The&nbsp;returned<br>
     98 &nbsp;&nbsp;screen&nbsp;is&nbsp;guaranteed&nbsp;to&nbsp;be&nbsp;the&nbsp;same&nbsp;size&nbsp;at&nbsp;each&nbsp;frame.<br>
     99 &nbsp;&nbsp;'None'&nbsp;and&nbsp;'None'&nbsp;if&nbsp;no&nbsp;screen&nbsp;was&nbsp;found&nbsp;on&nbsp;the&nbsp;current&nbsp;frame.<br>
    100 &nbsp;<br>
    101 Raises:<br>
    102 &nbsp;&nbsp;FrameReadError:&nbsp;An&nbsp;error&nbsp;occurred&nbsp;in&nbsp;the&nbsp;FrameGenerator.<br>
    103 &nbsp;&nbsp;RuntimeError:&nbsp;This&nbsp;method&nbsp;was&nbsp;called&nbsp;when&nbsp;no&nbsp;frames&nbsp;were&nbsp;available.</tt></dd></dl>
    104 
    105 <dl><dt><a name="ScreenFinder-HasNext"><strong>HasNext</strong></a>(self)</dt><dd><tt>True&nbsp;if&nbsp;there&nbsp;are&nbsp;more&nbsp;frames&nbsp;available&nbsp;to&nbsp;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&nbsp;the&nbsp;<a href="#ScreenFinder">ScreenFinder</a>&nbsp;<a href="__builtin__.html#object">object</a>.<br>
    108 &nbsp;<br>
    109 Args:<br>
    110 &nbsp;&nbsp;frame_generator:&nbsp;FrameGenerator,&nbsp;An&nbsp;initialized&nbsp;Video&nbsp;Frame&nbsp;Generator.<br>
    111 &nbsp;&nbsp;border:&nbsp;int,&nbsp;number&nbsp;of&nbsp;pixels&nbsp;of&nbsp;border&nbsp;to&nbsp;be&nbsp;kept&nbsp;when&nbsp;cropping&nbsp;the<br>
    112 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;detected&nbsp;screen.<br>
    113 &nbsp;<br>
    114 Raises:<br>
    115 &nbsp;&nbsp;FrameReadError:&nbsp;The&nbsp;frame&nbsp;generator&nbsp;may&nbsp;output&nbsp;a&nbsp;read&nbsp;error&nbsp;during<br>
    116 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;initialization.</tt></dd></dl>
    117 
    118 <hr>
    119 Data descriptors defined here:<br>
    120 <dl><dt><strong>__dict__</strong></dt>
    121 <dd><tt>dictionary&nbsp;for&nbsp;instance&nbsp;variables&nbsp;(if&nbsp;defined)</tt></dd>
    122 </dl>
    123 <dl><dt><strong>__weakref__</strong></dt>
    124 <dd><tt>list&nbsp;of&nbsp;weak&nbsp;references&nbsp;to&nbsp;the&nbsp;object&nbsp;(if&nbsp;defined)</tt></dd>
    125 </dl>
    126 <hr>
    127 Data 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> = &lt;class 'telemetry.internal.image_processing.screen_finder.CornerData'&gt;</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> = &lt;class 'telemetry.internal.image_processing.screen_finder.ScreenNotFoundError'&gt;</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>&nbsp;<br>
    156 <font color="#ffffff" face="helvetica, arial"><big><strong>Functions</strong></big></font></td></tr>
    157     
    158 <tr><td bgcolor="#eeaa77"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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>&nbsp;<br>
    164 <font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
    165     
    166 <tr><td bgcolor="#55aa55"><tt>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</tt></td><td>&nbsp;</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>